]> git.mxchange.org Git - friendica.git/blob - tests/src/Content/SmiliesTest.php
Simplify Contact::addRelationship call in ActivityPub\Processor::followUser
[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()
23         {
24                 parent::setUp();
25                 $this->setUpVfsDir();
26                 $this->mockApp($this->root);
27                 $this->app->videowidth = 425;
28                 $this->app->videoheight = 350;
29                 $this->configMock->shouldReceive('get')
30                         ->with('system', 'no_smilies')
31                         ->andReturn(false);
32                 $this->configMock->shouldReceive('get')
33                         ->with(false, 'system', 'no_smilies')
34                         ->andReturn(false);
35         }
36
37         public function dataLinks()
38         {
39                 return [
40                         /** @see https://github.com/friendica/friendica/pull/6933 */
41                         'bug-6933-1' => [
42                                 'data' => '<code>/</code>',
43                                 'smilies' => ['texts' => [], 'icons' => []],
44                                 'expected' => '<code>/</code>',
45                         ],
46                         'bug-6933-2' => [
47                                 'data' => '<code>code</code>',
48                                 'smilies' => ['texts' => [], 'icons' => []],
49                                 'expected' => '<code>code</code>',
50                         ],
51                 ];
52         }
53
54         /**
55          * Test replace smilies in different texts
56          *
57          * @dataProvider dataLinks
58          *
59          * @param string $text     Test string
60          * @param array  $smilies  List of smilies to replace
61          * @param string $expected Expected result
62          *
63          * @throws InternalServerErrorException
64          */
65         public function testReplaceFromArray(string $text, array $smilies, string $expected)
66         {
67                 $output = Smilies::replaceFromArray($text, $smilies);
68                 self::assertEquals($expected, $output);
69         }
70 }