Fix PHPunit errors with InlineImageMock.php and UtilsTest

HTMLDOMSanitizerTest : fix "Fatal error: Cannot declare class InlineImage, because the name is already in use in /var/www/html/iTop/test/core/sanitizer/InlineImageMock.php"
We are now injecting the class to mock, instead of declaring another class with the same name (was working before but why ?!???)

\UtilsTest::testSanitizer : no more testing the "class" filter, because it is a simple indirection, and we need to load datamodel which is causing multiple problems (see the comment in the test method dataprovider)
This commit is contained in:
Pierre Goiffon
2022-05-20 10:42:48 +02:00
parent 16fcddc249
commit f57d1f1de3
5 changed files with 76 additions and 50 deletions

View File

@@ -2,16 +2,12 @@
namespace Combodo\iTop\Test\UnitTest\Core\Sanitizer;
use HTMLDOMSanitizer;
use InlineImageMock;
require_once __DIR__.'/AbstractDOMSanitizerTest.php';
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class HTMLDOMSanitizerTest extends AbstractDOMSanitizerTest
{
/**
@@ -222,15 +218,17 @@ class HTMLDOMSanitizerTest extends AbstractDOMSanitizerTest
/**
* @dataProvider CallInlineImageProcessImageTagProvider
* @uses \InlineImageMock
*/
public function testDoSanitizeCallInlineImageProcessImageTag($sHtml, $iExpectedCount)
{
require_once APPROOT.'test/core/sanitizer/InlineImageMock.php';
InlineImageMock::ResetCallCounter();
$oSanitizer = new HTMLDOMSanitizer();
$oSanitizer = new HTMLDOMSanitizer(InlineImageMock::class);
$oSanitizer->DoSanitize($sHtml);
$iCalledCount = \InlineImage::GetCallCounter();
$iCalledCount = \InlineImageMock::GetCallCounter();
$this->assertEquals($iExpectedCount, $iCalledCount);
}