]> git.mxchange.org Git - friendica.git/blob - tests/src/Content/SmiliesTest.php
"escapeTags" is finally removed
[friendica.git] / tests / src / Content / SmiliesTest.php
1 <?php
2 /**
3  * Created by PhpStorm.
4  * User: benlo
5  * Date: 25/03/19
6  * Time: 21:36
7  */
8
9 namespace Friendica\Test\src\Content;
10
11 use Friendica\Content\Smilies;
12 use Friendica\Network\HTTPException\InternalServerErrorException;
13 use Friendica\Test\MockedTest;
14 use Friendica\Test\Util\AppMockTrait;
15 use Friendica\Test\Util\VFSTrait;
16
17 class SmiliesTest extends MockedTest
18 {
19         use VFSTrait;
20         use AppMockTrait;
21
22         protected function setUp(): void
23         {
24                 parent::setUp();
25                 $this->setUpVfsDir();
26                 $this->mockApp($this->root);
27                 $this->configMock->shouldReceive('get')
28                         ->with('system', 'no_smilies')
29                         ->andReturn(false);
30                 $this->configMock->shouldReceive('get')
31                         ->with(false, 'system', 'no_smilies')
32                         ->andReturn(false);
33         }
34
35         public function dataLinks()
36         {
37                 return [
38                         /** @see https://github.com/friendica/friendica/pull/6933 */
39                         'bug-6933-1' => [
40                                 'data' => '<code>/</code>',
41                                 'smilies' => ['texts' => [], 'icons' => []],
42                                 'expected' => '<code>/</code>',
43                         ],
44                         'bug-6933-2' => [
45                                 'data' => '<code>code</code>',
46                                 'smilies' => ['texts' => [], 'icons' => []],
47                                 'expected' => '<code>code</code>',
48                         ],
49                 ];
50         }
51
52         /**
53          * Test replace smilies in different texts
54          *
55          * @dataProvider dataLinks
56          *
57          * @param string $text     Test string
58          * @param array  $smilies  List of smilies to replace
59          * @param string $expected Expected result
60          *
61          * @throws InternalServerErrorException
62          */
63         public function testReplaceFromArray(string $text, array $smilies, string $expected)
64         {
65                 $output = Smilies::replaceFromArray($text, $smilies);
66                 self::assertEquals($expected, $output);
67         }
68 }