3 namespace Friendica\Test\src\Content\Text;
5 use Friendica\Content\Text\BBCode;
6 use Friendica\Test\MockedTest;
7 use Friendica\Test\Util\AppMockTrait;
8 use Friendica\Test\Util\L10nMockTrait;
9 use Friendica\Test\Util\VFSTrait;
12 * @runTestsInSeparateProcesses
13 * @preserveGlobalState disabled
15 class BBCodeTest extends MockedTest
21 protected function setUp()
25 $this->mockApp($this->root);
26 $this->app->videowidth = 425;
27 $this->app->videoheight = 350;
28 $this->configMock->shouldReceive('get')
29 ->with('system', 'remove_multiplicated_lines')
31 $this->configMock->shouldReceive('get')
32 ->with('system', 'no_oembed')
34 $this->configMock->shouldReceive('get')
35 ->with('system', 'allowed_link_protocols')
37 $this->configMock->shouldReceive('get')
38 ->with('system', 'itemcache_duration')
40 $this->configMock->shouldReceive('get')
41 ->with('system', 'url')
42 ->andReturn('friendica.local');
46 public function dataLinks()
49 /** @see https://github.com/friendica/friendica/issues/2487 */
51 'data' => 'https://de.wikipedia.org/wiki/Juha_Sipilä',
55 'data' => 'https://de.wikipedia.org/wiki/Dnepr_(Motorradmarke)',
59 'data' => 'https://friendica.wäckerlin.ch/friendica',
63 'data' => 'https://mastodon.social/@morevnaproject',
66 /** @see https://github.com/friendica/friendica/issues/5795 */
68 'data' => 'https://social.nasqueron.org/@liw/100798039015010628',
71 /** @see https://github.com/friendica/friendica/issues/6095 */
73 'data' => 'https://en.wikipedia.org/wiki/Solid_(web_decentralization_project)',
77 'data' => 'example.com/path',
81 'data' => 'ftp://example.com',
84 'wrong-domain-without-path' => [
85 'data' => 'http://example',
88 'wrong-domain-with-path' => [
89 'data' => 'http://example/path',
92 'bug-6857-domain-start' => [
93 'data' => "http://\nexample.com",
96 'bug-6857-domain-end' => [
97 'data' => "http://example\n.com",
101 'data' => "http://example.\ncom",
102 'assertHTML' => false
105 'data' => "http://example.com\ntest",
106 'assertHTML' => false
109 'data' => "http://example.com<ul>",
110 'assertHTML' => false
113 'data' => html_entity_decode('http://example.com ', ENT_QUOTES, 'UTF-8'),
114 'assertHTML' => false
120 * Test convert different links inside a text
121 * @dataProvider dataLinks
123 * @param string $data The data to text
124 * @param bool $assertHTML True, if the link is a HTML link (<a href...>...</a>)
125 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
127 public function testAutoLinking($data, $assertHTML)
129 $output = BBCode::convert($data);
130 $assert = '<a href="' . $data . '" target="_blank">' . $data . '</a>';
132 $this->assertEquals($assert, $output);
134 $this->assertNotEquals($assert, $output);