3 namespace Friendica\Test\src\Content\Text;
\r
5 use Friendica\Content\Text\BBCode;
\r
6 use Friendica\Test\MockedTest;
\r
7 use Friendica\Test\Util\AppMockTrait;
\r
8 use Friendica\Test\Util\L10nMockTrait;
\r
9 use Friendica\Test\Util\VFSTrait;
\r
12 * @runTestsInSeparateProcesses
\r
13 * @preserveGlobalState disabled
\r
15 class BBCodeTest extends MockedTest
\r
21 protected function setUp()
\r
24 $this->setUpVfsDir();
\r
25 $this->mockApp($this->root);
\r
26 $this->app->videowidth = 425;
\r
27 $this->app->videoheight = 350;
\r
28 $this->configMock->shouldReceive('get')
\r
29 ->with('system', 'remove_multiplicated_lines')
\r
31 $this->configMock->shouldReceive('get')
\r
32 ->with('system', 'no_oembed')
\r
34 $this->configMock->shouldReceive('get')
\r
35 ->with('system', 'allowed_link_protocols')
\r
37 $this->configMock->shouldReceive('get')
\r
38 ->with('system', 'itemcache_duration')
\r
43 public function dataLinks()
\r
46 /** @see https://github.com/friendica/friendica/issues/2487 */
\r
48 'data' => 'https://de.wikipedia.org/wiki/Juha_Sipilä',
\r
49 'assertHTML' => true,
\r
52 'data' => 'https://de.wikipedia.org/wiki/Dnepr_(Motorradmarke)',
\r
53 'assertHTML' => true,
\r
56 'data' => 'https://friendica.wäckerlin.ch/friendica',
\r
57 'assertHTML' => true,
\r
60 'data' => 'https://mastodon.social/@morevnaproject',
\r
61 'assertHTML' => true,
\r
63 /** @see https://github.com/friendica/friendica/issues/5795 */
\r
65 'data' => 'https://social.nasqueron.org/@liw/100798039015010628',
\r
66 'assertHTML' => true,
\r
68 /** @see https://github.com/friendica/friendica/issues/6095 */
\r
70 'data' => 'https://en.wikipedia.org/wiki/Solid_(web_decentralization_project)',
\r
71 'assertHTML' => true,
\r
74 'data' => 'example.com/path',
\r
75 'assertHTML' => false
\r
77 'wrong-protocol' => [
\r
78 'data' => 'ftp://example.com',
\r
79 'assertHTML' => false
\r
81 'wrong-domain-without-path' => [
\r
82 'data' => 'http://example',
\r
83 'assertHTML' => false
\r
85 'wrong-domain-with-path' => [
\r
86 'data' => 'http://example/path',
\r
87 'assertHTML' => false
\r
93 * Test convert different links inside a text
\r
94 * @dataProvider dataLinks
\r
96 * @param string $data The data to text
\r
97 * @param bool $assertHTML True, if the link is a HTML link (<a href...>...</a>)
\r
98 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
\r
100 public function testAutoLinking($data, $assertHTML)
\r
102 $output = BBCode::convert($data);
\r
104 $assert = '<a href="' . $data . '" target="_blank">' . $data . '</a>';
\r
109 $this->assertEquals($assert, $output);
\r