From: Hypolite Petovan Date: Tue, 26 Mar 2019 01:52:35 +0000 (-0400) Subject: Add cover code block encoding edge case in smilies replacement tests X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9210767518b5231d21db3e5003012ae3affff850;p=friendica.git Add cover code block encoding edge case in smilies replacement tests --- diff --git a/tests/src/Content/SmiliesTest.php b/tests/src/Content/SmiliesTest.php new file mode 100644 index 0000000000..40d126e005 --- /dev/null +++ b/tests/src/Content/SmiliesTest.php @@ -0,0 +1,69 @@ +setUpVfsDir(); + $this->mockApp($this->root); + $this->app->videowidth = 425; + $this->app->videoheight = 350; + $this->configMock->shouldReceive('get') + ->with('system', 'no_smilies') + ->andReturn(false); + $this->configMock->shouldReceive('get') + ->with(false, 'system', 'no_smilies') + ->andReturn(false); + } + + public function dataLinks() + { + return [ + /** @see https://github.com/friendica/friendica/pull/6933 */ + 'bug-6933-1' => [ + 'data' => '/', + 'smilies' => ['texts' => [], 'icons' => []], + 'expected' => '/', + ], + 'bug-6933-2' => [ + 'data' => 'code', + 'smilies' => ['texts' => [], 'icons' => []], + 'expected' => 'code', + ], + ]; + } + + /** + * Test replace smilies in different texts + * @dataProvider dataLinks + * + * @param string $text Test string + * @param array $smilies List of smilies to replace + * @param string $expected Expected result + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + */ + public function testReplaceFromArray($text, $smilies, $expected) + { + $output = Smilies::replaceFromArray($text, $smilies); + $this->assertEquals($expected, $output); + } +}