mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +02:00
N°8681 - PHP 8.1: Fix deprecated notice for null value passed to preg_match_all() (#803)
* N°8681 - PHP 8.1: Fix deprecated notice for null value passed to preg_match_all() * N°8681 - Add unit tests * N°8681 - Add unit tests
This commit is contained in:
@@ -59,4 +59,43 @@ class InlineImageTest extends ItopDataTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers InlineImage::FixUrls
|
||||
*/
|
||||
public function testFixUrls_shouldReturnAnEmptyStringIfNullOrEmptyStringPassed()
|
||||
{
|
||||
$sResult = InlineImage::FixUrls(null);
|
||||
$this->assertEquals('', $sResult);
|
||||
|
||||
$sResult = InlineImage::FixUrls('');
|
||||
$this->assertEquals('', $sResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers InlineImage::FixUrls
|
||||
*/
|
||||
public function testFixUrls_shouldReturnUnchangedValueIfValueContainsNoImage()
|
||||
{
|
||||
$sHtml = '<div><p>Texte sans image</p></div>';
|
||||
$sResult = InlineImage::FixUrls($sHtml);
|
||||
$this->assertEquals($sHtml, $sResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers InlineImage::FixUrls
|
||||
*/
|
||||
public function testFixUrls_shouldReplaceImagesSrcWithCurrentAppRootUrlAndSecret()
|
||||
{
|
||||
$sHtml = <<<HTML
|
||||
<div>
|
||||
<img src="/images/test1.png" data-img-id="123" data-img-secret="abc" />
|
||||
<img src="/images/test2.png" data-img-id="456" data-img-secret="def" />
|
||||
</div>
|
||||
HTML;
|
||||
$sResult = InlineImage::FixUrls($sHtml);
|
||||
$this->assertStringContainsString('<img', $sResult);
|
||||
$this->assertStringContainsString(\utils::EscapeHtml(\utils::GetAbsoluteUrlAppRoot().INLINEIMAGE_DOWNLOAD_URL.'123&s=abc'), $sResult);
|
||||
$this->assertStringContainsString(\utils::EscapeHtml(\utils::GetAbsoluteUrlAppRoot().INLINEIMAGE_DOWNLOAD_URL.'456&s=def'), $sResult);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user