2019-07-09 21:44:02 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: benlo
|
|
|
|
* Date: 25/03/19
|
|
|
|
* Time: 21:36
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Friendica\Test\src\Content;
|
|
|
|
|
|
|
|
use Friendica\Content\Smilies;
|
2020-10-18 20:31:57 +02:00
|
|
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
2019-07-09 21:44:02 +02:00
|
|
|
use Friendica\Test\MockedTest;
|
|
|
|
use Friendica\Test\Util\AppMockTrait;
|
|
|
|
use Friendica\Test\Util\VFSTrait;
|
|
|
|
|
|
|
|
class SmiliesTest extends MockedTest
|
|
|
|
{
|
|
|
|
use VFSTrait;
|
|
|
|
use AppMockTrait;
|
|
|
|
|
2021-04-01 23:04:30 +02:00
|
|
|
protected function setUp(): void
|
2019-07-09 21:44:02 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->setUpVfsDir();
|
|
|
|
$this->mockApp($this->root);
|
2021-07-25 21:39:10 +02:00
|
|
|
$this->app->setThemeInfoValue('videowidth', 425);
|
|
|
|
$this->app->setThemeInfoValue('videoheight', 350);
|
2019-07-09 21:44:02 +02:00
|
|
|
$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' => '<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 20:31:57 +02:00
|
|
|
*
|
2019-07-09 21:44:02 +02:00
|
|
|
* @dataProvider dataLinks
|
|
|
|
*
|
|
|
|
* @param string $text Test string
|
|
|
|
* @param array $smilies List of smilies to replace
|
|
|
|
* @param string $expected Expected result
|
2020-10-18 20:31:57 +02:00
|
|
|
*
|
|
|
|
* @throws InternalServerErrorException
|
2019-07-09 21:44:02 +02:00
|
|
|
*/
|
2020-10-18 20:31:57 +02:00
|
|
|
public function testReplaceFromArray(string $text, array $smilies, string $expected)
|
2019-07-09 21:44:02 +02:00
|
|
|
{
|
|
|
|
$output = Smilies::replaceFromArray($text, $smilies);
|
2020-10-17 14:19:57 +02:00
|
|
|
self::assertEquals($expected, $output);
|
2019-07-09 21:44:02 +02:00
|
|
|
}
|
|
|
|
}
|