mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
Merge branch 'develop' into feature/faf_event_service
This commit is contained in:
@@ -24,7 +24,7 @@ class ActionEmailTest extends ItopDataTestCase
|
||||
/** @var \ActionEmail|null Temp ActionEmail created for tests */
|
||||
protected static $oActionEmail = null;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use MetaModel;
|
||||
class AttributeDefTest extends ItopDataTestCase {
|
||||
const CREATE_TEST_ORG = true;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'core/attributedef.class.inc.php');
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ class AttributeURLDefaultPattern extends AttributeURL {
|
||||
{
|
||||
/** @noinspection OneTimeUseVariablesInspection */
|
||||
$oConfig = utils::GetConfig();
|
||||
return $oConfig->GetDefault('url_validation_pattern');
|
||||
return '^'.$oConfig->GetDefault('url_validation_pattern').'$';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class AttributeURLTest extends ItopTestCase {
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once APPROOT.'core/attributedef.class.inc.php';
|
||||
@@ -39,6 +39,7 @@ class AttributeURLTest extends ItopTestCase {
|
||||
'Sharepoint URL 2' => ['https://mydomain2.sharepoint.com/:u:/r/sites/DIS/ITSM/00_Admin_iTOP/iTop%20-%20Upgrade%20manuel/Procedure%20upgrade%20Combodo.url?csf=1&web=1&e=DAF0i3', 1],
|
||||
'Alfresco URL 2' => ['http://alfresco.mydomain3.org/share/page/site/books/document-details?nodeRef=workspace://SpacesStore/6274f55f-a25b-4762-a863-77f7066f2034', 1],
|
||||
'SF URL' => ['https://sourceforge.net/p/itop/discussion/customizing-itop/thread/707145b859/?limit=25#f53c', 1],
|
||||
'SF URL anchor starting with digit' => ['https://sourceforge.net/p/itop/discussion/customizing-itop/thread/b0a2d474ba/?limit=25#2b35', 1],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ use MetaModel;
|
||||
class BulkChangeTest extends ItopDataTestCase {
|
||||
const CREATE_TEST_ORG = true;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'core/bulkchange.class.inc.php');
|
||||
|
||||
|
||||
75
test/core/CMDBObjectTest.php
Normal file
75
test/core/CMDBObjectTest.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
|
||||
use CMDBObject;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use MetaModel;
|
||||
|
||||
/**
|
||||
* @since 2.7.7 3.0.2 3.1.0 N°3717 tests history objects creation
|
||||
*
|
||||
* @package Combodo\iTop\Test\UnitTest\Core
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class CMDBObjectTest extends ItopDataTestCase
|
||||
{
|
||||
/**
|
||||
* @covers CMDBObject::SetCurrentChange
|
||||
*/
|
||||
public function testCurrentChange()
|
||||
{
|
||||
// save initial conditions
|
||||
$oInitialCurrentChange = CMDBObject::GetCurrentChange();
|
||||
$sInitialTrackInfo = CMDBObject::GetTrackInfo();
|
||||
// reset current change
|
||||
CMDBObject::SetCurrentChange(null);
|
||||
|
||||
//-- new object with only track info
|
||||
$sTrackInfo = 'PHPUnit test';
|
||||
CMDBObject::SetTrackInfo($sTrackInfo);
|
||||
/** @var \DocumentWeb $oTestObject */
|
||||
$oTestObject = MetaModel::NewObject('DocumentWeb');
|
||||
$oTestObject->Set('name', 'PHPUnit test');
|
||||
$oTestObject->Set('org_id', 1);
|
||||
$oTestObject->Set('url', 'https://www.combodo.com');
|
||||
$oTestObject->DBWrite();
|
||||
self::assertFalse(CMDBObject::GetCurrentChange()->IsNew(), 'TrackInfo : Current change persisted');
|
||||
self::assertEquals($sTrackInfo, CMDBObject::GetCurrentChange()->Get('userinfo'),
|
||||
'TrackInfo : current change created with expected trackinfo');
|
||||
|
||||
//-- new object with non persisted current change
|
||||
$sTrackInfo2 = $sTrackInfo.'_2';
|
||||
/** @var \CMDBChange $oCustomChange */
|
||||
$oCustomChange = MetaModel::NewObject('CMDBChange');
|
||||
$oCustomChange->Set('date', time());
|
||||
$oCustomChange->Set('userinfo', $sTrackInfo2);
|
||||
CMDBObject::SetCurrentChange($oCustomChange);
|
||||
$oTestObject->Set('url', 'https://fr.wikipedia.org');
|
||||
$oTestObject->DBUpdate();
|
||||
self::assertFalse(CMDBObject::GetCurrentChange()->IsNew(), 'SetCurrentChange : Current change persisted');
|
||||
self::assertEquals($sTrackInfo2, CMDBObject::GetCurrentChange()->Get('userinfo'),
|
||||
'SetCurrentChange : current change created with expected trackinfo');
|
||||
|
||||
//-- new object with current change init using helper method
|
||||
$sTrackInfo3 = $sTrackInfo.'_3';
|
||||
CMDBObject::SetCurrentChangeFromParams($sTrackInfo3);
|
||||
$oTestObject->Set('url', 'https://en.wikipedia.org');
|
||||
$oTestObject->DBUpdate();
|
||||
self::assertFalse(CMDBObject::GetCurrentChange()->IsNew(), 'SetCurrentChangeFromParams : Current change persisted');
|
||||
self::assertEquals($sTrackInfo3, CMDBObject::GetCurrentChange()->Get('userinfo'),
|
||||
'SetCurrentChangeFromParams : current change created with expected trackinfo');
|
||||
|
||||
// restore initial conditions
|
||||
$oTestObject->DBDelete();
|
||||
CMDBObject::SetCurrentChange($oInitialCurrentChange);
|
||||
CMDBObject::SetTrackInfo($sInitialTrackInfo);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ use utils;
|
||||
*/
|
||||
class CMDBSourceTest extends ItopTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
||||
parent::setUp();
|
||||
|
||||
@@ -27,10 +27,10 @@ class TransactionsTest extends ItopTestCase
|
||||
/** @var DeadLockInjection */
|
||||
private $oMySQLiMock;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once ('DeadLockInjection.php');
|
||||
require_once('DeadLockInjection.php');
|
||||
require_once(APPROOT.'/core/cmdbsource.class.inc.php');
|
||||
$sEnv = 'production';
|
||||
$sConfigFile = APPCONF.$sEnv.'/config-itop.php';
|
||||
|
||||
@@ -8,7 +8,7 @@ use CSVParser;
|
||||
|
||||
class CSVParserTest extends ItopTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use ConfigPlaceholdersResolver;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
@@ -32,10 +31,10 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class ConfigPlaceholdersResolverTest extends ItopTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once (APPROOT.'core/config.class.inc.php');
|
||||
require_once(APPROOT.'core/config.class.inc.php');
|
||||
}
|
||||
/**
|
||||
* @dataProvider providerResolve
|
||||
|
||||
@@ -31,10 +31,10 @@ use Config;
|
||||
*/
|
||||
class ConfigTest extends ItopTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once (APPROOT.'core/config.class.inc.php');
|
||||
require_once(APPROOT.'core/config.class.inc.php');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ use Exception;
|
||||
|
||||
class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once APPROOT.'env-production/itop-config/src/Validator/iTopConfigAstValidator.php';
|
||||
@@ -31,9 +31,9 @@ class iTopConfigAstValidatorTest extends ItopTestCase
|
||||
$this->assertTrue(true, 'The file is valid and interpreted as such');
|
||||
}
|
||||
|
||||
//FIXME disabled test, is failing for now with error "Invalid configuration: LEVEL_WARNING of type Identifier is forbidden in line 152"
|
||||
public function __testValidateFileValidLogLevelMinConst()
|
||||
public function testValidateFileValidLogLevelMinConst()
|
||||
{
|
||||
$this->markTestSkipped(' disabled test, is failing for now with error "Invalid configuration: LEVEL_WARNING of type Identifier is forbidden in line 152"');
|
||||
try {
|
||||
$this->CallValidatorOnFile('config-itop_VALID_log-level-min_const.php');
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class DBObjectTest extends ItopDataTestCase
|
||||
{
|
||||
const CREATE_TEST_ORG = true;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'core/dbobject.class.php');
|
||||
|
||||
@@ -12,7 +12,7 @@ use DBSearch;
|
||||
class DBSearchAddConditionPointingToTest extends ItopTestCase
|
||||
{
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'application/startup.inc.php');
|
||||
|
||||
@@ -19,7 +19,7 @@ use DBSearch;
|
||||
class DBSearchIntersectTest extends ItopTestCase
|
||||
{
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'application/startup.inc.php');
|
||||
@@ -337,7 +337,6 @@ class DBSearchIntersectTest extends ItopTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider IntersectOptimizationProvider
|
||||
* @doesNotPerformAssertions
|
||||
*
|
||||
* @param string $sOQL
|
||||
* @param string $sResult
|
||||
|
||||
@@ -20,7 +20,7 @@ class DBSearchJoinTest extends ItopDataTestCase {
|
||||
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'application/startup.inc.php');
|
||||
|
||||
@@ -54,7 +54,7 @@ class DBSearchTest extends ItopDataTestCase
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class DBSearchUpdateRealiasingMapTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'application/startup.inc.php');
|
||||
|
||||
@@ -455,7 +455,11 @@ class ExpressionEvaluateTest extends iTopDataTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Systematically check all supported format specs, for a given date
|
||||
* For a given date,
|
||||
* for all different formats (1st array element returned by {@see static::TimeFormatsProvider}),
|
||||
* compare value returned by :
|
||||
* * DATE_FORMAT() SQL function,
|
||||
* * FunctionExpression('DATE_FORMAT', ...) result
|
||||
*
|
||||
* @covers FunctionExpression::Evaluate()
|
||||
* @dataProvider EveryTimeFormatProvider
|
||||
@@ -481,7 +485,8 @@ class ExpressionEvaluateTest extends iTopDataTestCase
|
||||
}
|
||||
$sSelects = "SELECT ".implode(', ', $aSelects);
|
||||
$aRes = CMDBSource::QueryToArray($sSelects);
|
||||
$aRow = $aRes[0];
|
||||
/** @var array $aMysqlDateFormatRsultsForAllFormats format as key, MySQL evaluated result as value */
|
||||
$aMysqlDateFormatRsultsForAllFormats = $aRes[0];
|
||||
foreach ($aFormats as $sFormatDesc => $aFormatSpec)
|
||||
{
|
||||
$sFormat = $aFormatSpec[0];
|
||||
@@ -489,8 +494,8 @@ class ExpressionEvaluateTest extends iTopDataTestCase
|
||||
if ($bProcessed)
|
||||
{
|
||||
$oExpression = new FunctionExpression('DATE_FORMAT', array(new ScalarExpression($sDate), new ScalarExpression("%$sFormat")));
|
||||
$res = $oExpression->Evaluate(array());
|
||||
static::assertEquals($aRow[$sFormat], $res, "Format %$sFormat not matching MySQL for '$sDate'");
|
||||
$itopExpressionResult = $oExpression->Evaluate(array());
|
||||
static::assertSame($aMysqlDateFormatRsultsForAllFormats[$sFormat], $itopExpressionResult, "Format %$sFormat not matching MySQL for '$sDate'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class GetSelectFilterTest extends ItopDataTestCase
|
||||
private $sPassword = "IAAuytrez9876[}543ç_è-(";
|
||||
private $oUser;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'application/startup.inc.php');
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace Combodo\iTop\Test\UnitTest\Core\Log;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use ExceptionLog;
|
||||
use MetaModel;
|
||||
|
||||
|
||||
require_once(__DIR__.'/ExceptionLogTest/Exceptions.php');
|
||||
@@ -29,16 +28,10 @@ require_once(__DIR__.'/ExceptionLogTest/Exceptions.php');
|
||||
*/
|
||||
class ExceptionLogTest extends ItopDataTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
require_once(__DIR__.'/ExceptionLogTest/Exceptions.php');
|
||||
parent::setUp();
|
||||
|
||||
// We are using PHPUnit\Framework\MockObject\Generator::generateMock that is throwing notice !
|
||||
// Changing config so that those won't be caught by \DeprecatedCallsLog::DeprecatedNoticesErrorHandler
|
||||
// disabling devenv is easier than changing log config O:)
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
$oConfig->Set('developer_mode.enabled', false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Combodo\iTop\Test\UnitTest\Core\Log;
|
||||
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use MetaModel;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
@@ -27,16 +26,10 @@ class LogAPITest extends ItopDataTestCase
|
||||
private $mockFileLog;
|
||||
private $oMetaModelConfig;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp():void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// We are using PHPUnit\Framework\MockObject\Generator::generateMock that is throwing notice !
|
||||
// Changing config so that those won't be caught by \DeprecatedCallsLog::DeprecatedNoticesErrorHandler
|
||||
// disabling devenv is easier than changing log config O:)
|
||||
$oConfig = MetaModel::GetConfig();
|
||||
$oConfig->Set('developer_mode.enabled', false);
|
||||
|
||||
$this->mockFileLog = $this->createMock('FileLog');
|
||||
$this->oMetaModelConfig = $this->createMock('Config');
|
||||
}
|
||||
|
||||
@@ -28,21 +28,20 @@ class LogFileNameBuilderTest extends ItopTestCase
|
||||
clearstatcache(true, $sLogFile);
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
require_once APPROOT.'core/log.class.inc.php';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
// remove log files created in the test
|
||||
$aTestLogFiles = glob(__DIR__.DIRECTORY_SEPARATOR.self::TEST_LOGFILE_PREFIX.'*.'.self::TEST_LOGFILE_EXTENSION);
|
||||
foreach ($aTestLogFiles as $sLogFile)
|
||||
{
|
||||
foreach ($aTestLogFiles as $sLogFile) {
|
||||
unlink($sLogFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class MetaModelTest extends ItopDataTestCase
|
||||
protected static $sDefaultUserRequestTitle = 'Unit test title';
|
||||
protected static $sDefaultUserRequestDescription = 'Unit test description';
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once APPROOT.'/core/metamodel.class.php';
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Portal\Controller\ObjectController;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use ContextTag;
|
||||
use MetaModel;
|
||||
use PHPUnit\Exception;
|
||||
use TriggerOnObjectCreate;
|
||||
|
||||
/**
|
||||
@@ -24,7 +22,7 @@ class TriggerTest extends ItopDataTestCase
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use MetaModel;
|
||||
*/
|
||||
class UniquenessConstraintTest extends ItopTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'/core/metamodel.class.php');
|
||||
|
||||
@@ -47,7 +47,7 @@ use utils;
|
||||
*/
|
||||
class UserRightsTest extends ItopDataTestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use DateTime;
|
||||
|
||||
class WeeklyScheduledProcessTest extends ItopTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'core/backgroundprocess.inc.php');
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
define('UNIT_MAX_CACHE_FILES', 10);
|
||||
|
||||
@@ -40,7 +39,7 @@ define('UNIT_MAX_CACHE_FILES', 10);
|
||||
class apcEmulationTest extends ItopTestCase
|
||||
{
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'core/apc-emulation.php');
|
||||
@@ -48,7 +47,7 @@ class apcEmulationTest extends ItopTestCase
|
||||
apc_clear_cache();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
apc_clear_cache();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class dictApcuTest extends ItopTestCase
|
||||
private $oApcService;
|
||||
private $sDictionaryFolder;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@@ -108,12 +108,12 @@ PHP;
|
||||
file_put_contents($sDictionaryFolder . DIRECTORY_SEPARATOR . "$sLanguageCodeInFilename.dict.php", $sContent);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
foreach (glob(APPROOT."env-$this->sEnvName" . DIRECTORY_SEPARATOR . "dictionaries" . DIRECTORY_SEPARATOR . "*") as $sFile){
|
||||
foreach (glob(APPROOT."env-$this->sEnvName".DIRECTORY_SEPARATOR."dictionaries".DIRECTORY_SEPARATOR."*") as $sFile) {
|
||||
unlink($sFile);
|
||||
}
|
||||
rmdir(APPROOT."env-$this->sEnvName" . DIRECTORY_SEPARATOR . "dictionaries");
|
||||
rmdir(APPROOT."env-$this->sEnvName".DIRECTORY_SEPARATOR."dictionaries");
|
||||
rmdir(APPROOT."env-$this->sEnvName");
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ use Exception;
|
||||
class dictTest extends ItopTestCase
|
||||
{
|
||||
private $sEnvName;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@@ -74,7 +73,7 @@ PHP;
|
||||
$_SESSION['itop_env'] = $this->sEnvName;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
foreach (glob(APPROOT."env-$this->sEnvName".DIRECTORY_SEPARATOR."dictionaries".DIRECTORY_SEPARATOR."*") as $sFile) {
|
||||
unlink($sFile);
|
||||
|
||||
@@ -14,10 +14,11 @@ class iTopConfigParserTest extends ItopTestCase
|
||||
private $tmpSavePath;
|
||||
private $sConfigPath;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once APPROOT.'/core/iTopConfigParser.php';
|
||||
require_once APPROOT.'/setup/runtimeenv.class.inc.php';
|
||||
|
||||
clearstatcache();
|
||||
$this->sConfigPath = utils::GetConfigFilePath();
|
||||
@@ -32,7 +33,7 @@ class iTopConfigParserTest extends ItopTestCase
|
||||
clearstatcache();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
if ($this->conf_exists) {
|
||||
@@ -150,8 +151,6 @@ class iTopConfigParserTest extends ItopTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
@@ -202,21 +201,15 @@ CONF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*
|
||||
* @throws \ConfigException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function testConfigWriteToFile_FromScratchInstallation()
|
||||
{
|
||||
$sConfigPath = utils::GetConfigFilePath();
|
||||
$oConfig = new Config($sConfigPath, false);
|
||||
try{
|
||||
clearstatcache();
|
||||
$oConfig->WriteToFile();
|
||||
}catch(\Exception $e)
|
||||
{
|
||||
$this->assertTrue(false, "failed writetofile with no initial file: " . $e->getMessage());
|
||||
}
|
||||
$oConfig = new Config();
|
||||
clearstatcache();
|
||||
$oTestEnv = new RunTimeEnvironment('test-phpunit');
|
||||
$oTestEnv->WriteConfigFileSafe($oConfig);
|
||||
$this->assertTrue(true, "Config file was written");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ class ormLinkSetTest extends ItopDataTestCase
|
||||
const CREATE_TEST_ORG = true;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -50,7 +50,7 @@ class ormTagSetTest extends ItopDataTestCase
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
@@ -9,12 +9,11 @@ abstract class AbstractDOMSanitizerTest extends ItopTestCase
|
||||
const INPUT_DIRECTORY = 'input';
|
||||
const OUTPUT_DIRECTORY = 'output';
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
require_once(APPROOT.'application/utils.inc.php');
|
||||
require_once(APPROOT.'core/htmlsanitizer.class.inc.php');
|
||||
require_once(APPROOT.'test/core/sanitizer/InlineImageMock.php');
|
||||
}
|
||||
|
||||
protected function ReadTestFile($sFileToTest, $sFolderName)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
/** @noinspection PhpUnused */
|
||||
/** @noinspection PhpIllegalPsrClassPathInspection */
|
||||
/**
|
||||
* Copyright (C) 2010-2021 Combodo SARL
|
||||
*
|
||||
@@ -20,10 +22,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mock class used by @see \Combodo\iTop\Test\UnitTest\Core\HTMLDOMSanitizerTest
|
||||
* Mock class used to count number of calls for the ProcessImage static method
|
||||
*
|
||||
* @used-by \Combodo\iTop\Test\UnitTest\Core\Sanitizer\HTMLDOMSanitizerTest::testDoSanitizeCallInlineImageProcessImageTag()
|
||||
*/
|
||||
class InlineImage
|
||||
class InlineImageMock
|
||||
{
|
||||
private static $iCallCounter = 0;
|
||||
|
||||
@@ -32,6 +35,11 @@ class InlineImage
|
||||
self::$iCallCounter++;
|
||||
}
|
||||
|
||||
public static function ResetCallCounter()
|
||||
{
|
||||
self::$iCallCounter = 0;
|
||||
}
|
||||
|
||||
public static function GetCallCounter()
|
||||
{
|
||||
return self::$iCallCounter;
|
||||
|
||||
Reference in New Issue
Block a user