]> git.mxchange.org Git - friendica.git/commitdiff
Add cover code block encoding edge case in smilies replacement tests
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 26 Mar 2019 01:52:35 +0000 (21:52 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 26 Mar 2019 01:52:35 +0000 (21:52 -0400)
tests/src/Content/SmiliesTest.php [new file with mode: 0644]

diff --git a/tests/src/Content/SmiliesTest.php b/tests/src/Content/SmiliesTest.php
new file mode 100644 (file)
index 0000000..40d126e
--- /dev/null
@@ -0,0 +1,69 @@
+<?php\r
+/**\r
+ * Created by PhpStorm.\r
+ * User: benlo\r
+ * Date: 25/03/19\r
+ * Time: 21:36\r
+ */\r
+\r
+namespace Friendica\Test\src\Content;\r
+\r
+use Friendica\Content\Smilies;\r
+use Friendica\Test\MockedTest;\r
+use Friendica\Test\Util\AppMockTrait;\r
+use Friendica\Test\Util\L10nMockTrait;\r
+use Friendica\Test\Util\VFSTrait;\r
+\r
+class SmiliesTest extends MockedTest\r
+{\r
+       use VFSTrait;\r
+       use AppMockTrait;\r
+       use L10nMockTrait;\r
+\r
+       protected function setUp()\r
+       {\r
+               parent::setUp();\r
+               $this->setUpVfsDir();\r
+               $this->mockApp($this->root);\r
+               $this->app->videowidth = 425;\r
+               $this->app->videoheight = 350;\r
+               $this->configMock->shouldReceive('get')\r
+                       ->with('system', 'no_smilies')\r
+                       ->andReturn(false);\r
+               $this->configMock->shouldReceive('get')\r
+                       ->with(false, 'system', 'no_smilies')\r
+                       ->andReturn(false);\r
+       }\r
+\r
+       public function dataLinks()\r
+       {\r
+               return [\r
+                       /** @see https://github.com/friendica/friendica/pull/6933 */\r
+                       'bug-6933-1' => [\r
+                               'data' => '<code>/</code>',\r
+                               'smilies' => ['texts' => [], 'icons' => []],\r
+                               'expected' => '<code>/</code>',\r
+                       ],\r
+                       'bug-6933-2' => [\r
+                               'data' => '<code>code</code>',\r
+                               'smilies' => ['texts' => [], 'icons' => []],\r
+                               'expected' => '<code>code</code>',\r
+                       ],\r
+               ];\r
+       }\r
+\r
+       /**\r
+        * Test replace smilies in different texts\r
+        * @dataProvider dataLinks\r
+        *\r
+        * @param string $text     Test string\r
+        * @param array  $smilies  List of smilies to replace\r
+        * @param string $expected Expected result\r
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException\r
+        */\r
+       public function testReplaceFromArray($text, $smilies, $expected)\r
+       {\r
+               $output = Smilies::replaceFromArray($text, $smilies);\r
+               $this->assertEquals($expected, $output);\r
+       }\r
+}\r