]> git.mxchange.org Git - friendica.git/blob - tests/src/Content/SmiliesTest.php
Merge pull request #7765 from nupplaphil/task/move_text
[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\Test\MockedTest;
13 use Friendica\Test\Util\AppMockTrait;
14 use Friendica\Test\Util\VFSTrait;
15
16 class SmiliesTest extends MockedTest
17 {
18         use VFSTrait;
19         use AppMockTrait;
20
21         protected function setUp()
22         {
23                 parent::setUp();
24                 $this->setUpVfsDir();
25                 $this->mockApp($this->root);
26                 $this->app->videowidth = 425;
27                 $this->app->videoheight = 350;
28                 $this->configMock->shouldReceive('get')
29                         ->with('system', 'no_smilies')
30                         ->andReturn(false);
31                 $this->configMock->shouldReceive('get')
32                         ->with(false, 'system', 'no_smilies')
33                         ->andReturn(false);
34         }
35
36         public function dataLinks()
37         {
38                 return [
39                         /** @see https://github.com/friendica/friendica/pull/6933 */
40                         'bug-6933-1' => [
41                                 'data' => '<code>/</code>',
42                                 'smilies' => ['texts' => [], 'icons' => []],
43                                 'expected' => '<code>/</code>',
44                         ],
45                         'bug-6933-2' => [
46                                 'data' => '<code>code</code>',
47                                 'smilies' => ['texts' => [], 'icons' => []],
48                                 'expected' => '<code>code</code>',
49                         ],
50                 ];
51         }
52
53         /**
54          * Test replace smilies in different texts
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          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
61          */
62         public function testReplaceFromArray($text, $smilies, $expected)
63         {
64                 $output = Smilies::replaceFromArray($text, $smilies);
65                 $this->assertEquals($expected, $output);
66         }
67 }