2019-07-09 15:44:02 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: benlo
|
|
|
|
* Date: 25/03/19
|
|
|
|
* Time: 21:36
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Friendica\Test\src\Content;
|
|
|
|
|
|
|
|
use Friendica\Content\Smilies;
|
2021-11-28 06:59:42 -05:00
|
|
|
use Friendica\DI;
|
2020-10-18 14:31:57 -04:00
|
|
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
2021-11-28 06:59:42 -05:00
|
|
|
use Friendica\Test\FixtureTest;
|
2019-07-09 15:44:02 -04:00
|
|
|
|
2021-11-28 06:59:42 -05:00
|
|
|
class SmiliesTest extends FixtureTest
|
2019-07-09 15:44:02 -04:00
|
|
|
{
|
2021-04-01 17:04:30 -04:00
|
|
|
protected function setUp(): void
|
2019-07-09 15:44:02 -04:00
|
|
|
{
|
|
|
|
parent::setUp();
|
2021-11-28 06:59:42 -05:00
|
|
|
|
|
|
|
DI::config()->set('system', 'no_smilies', false);
|
2019-07-09 15:44:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function dataLinks()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
/** @see https://github.com/friendica/friendica/pull/6933 */
|
|
|
|
'bug-6933-1' => [
|
|
|
|
'data' => '<code>/</code>',
|
|
|
|
'smilies' => ['texts' => [], 'icons' => []],
|
|
|
|
'expected' => '<code>/</code>',
|
|
|
|
],
|
|
|
|
'bug-6933-2' => [
|
|
|
|
'data' => '<code>code</code>',
|
|
|
|
'smilies' => ['texts' => [], 'icons' => []],
|
|
|
|
'expected' => '<code>code</code>',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test replace smilies in different texts
|
2020-10-18 14:31:57 -04:00
|
|
|
*
|
2019-07-09 15:44:02 -04:00
|
|
|
* @dataProvider dataLinks
|
|
|
|
*
|
|
|
|
* @param string $text Test string
|
|
|
|
* @param array $smilies List of smilies to replace
|
|
|
|
* @param string $expected Expected result
|
2020-10-18 14:31:57 -04:00
|
|
|
*
|
|
|
|
* @throws InternalServerErrorException
|
2019-07-09 15:44:02 -04:00
|
|
|
*/
|
2020-10-18 14:31:57 -04:00
|
|
|
public function testReplaceFromArray(string $text, array $smilies, string $expected)
|
2019-07-09 15:44:02 -04:00
|
|
|
{
|
|
|
|
$output = Smilies::replaceFromArray($text, $smilies);
|
2020-10-17 08:19:57 -04:00
|
|
|
self::assertEquals($expected, $output);
|
2019-07-09 15:44:02 -04:00
|
|
|
}
|
|
|
|
}
|