diff --git a/test/ItopDataTestCase.php b/test/ItopDataTestCase.php index 6f6cd21c9..89a0fd1d2 100644 --- a/test/ItopDataTestCase.php +++ b/test/ItopDataTestCase.php @@ -77,7 +77,7 @@ class ItopDataTestCase extends ItopTestCase /** * @throws Exception */ - protected function setUp() + protected function setUp(): void { parent::setUp(); require_once(APPROOT.'/application/startup.inc.php'); @@ -101,15 +101,12 @@ class ItopDataTestCase extends ItopTestCase /** * @throws Exception */ - protected function tearDown() + protected function tearDown(): void { - if (static::USE_TRANSACTION) - { + if (static::USE_TRANSACTION) { $this->debug("ROLLBACK !!!"); CMDBSource::Query('ROLLBACK'); - } - else - { + } else { $this->debug(""); $this->aCreatedObjects = array_reverse($this->aCreatedObjects); foreach ($this->aCreatedObjects as $oObject) diff --git a/test/ItopTestCase.php b/test/ItopTestCase.php index fbfac87d0..0e983fcec 100644 --- a/test/ItopTestCase.php +++ b/test/ItopTestCase.php @@ -34,10 +34,11 @@ class ItopTestCase extends TestCase { const TEST_LOG_DIR = 'test'; - protected function setUp() + /** @noinspection UsingInclusionOnceReturnValueInspection avoid errors for approot includes */ + protected function setUp(): void { @include_once '../approot.inc.php'; - @include_once '../../approot.inc.php'; + @include_once '../../approot.inc.php'; @include_once '../../../approot.inc.php'; @include_once '../../../../approot.inc.php'; @include_once '../../../../../approot.inc.php'; @@ -45,7 +46,7 @@ class ItopTestCase extends TestCase @include_once '../../../../../../../approot.inc.php'; @include_once '../../../../../../../../approot.inc.php'; - $this->debug("\n----------\n---------- ".$this->getName()."\n----------\n"); + $this->debug("\n----------\n---------- ".$this->getName()."\n----------\n"); } @@ -57,9 +58,9 @@ class ItopTestCase extends TestCase { echo "$sMsg\n"; } - else - { - print_r($sMsg); + else { + /** @noinspection ForgottenDebugOutputInspection */ + print_r($sMsg); } } } diff --git a/test/OQL/DataLocalizerTest.php b/test/OQL/DataLocalizerTest.php index e2a7f8370..26a2f2069 100644 --- a/test/OQL/DataLocalizerTest.php +++ b/test/OQL/DataLocalizerTest.php @@ -17,10 +17,10 @@ class DataLocalizerTest extends ItopDataTestCase const USE_TRANSACTION = false; const TEST_CSV_RESULT = 'DataLocalizerTest.csv'; - public function setUp() + protected function setUp(): void { parent::setUp(); - require_once(APPROOT.'application/startup.inc.php'); + ApplicationContext::SetPluginProperty('QueryLocalizerPlugin', 'language_code', 'FR FR'); SetupUtils::builddir(APPROOT.'log/test/OQLToSQL'); diff --git a/test/OQL/OQLToSQLAllClassesTest.php b/test/OQL/OQLToSQLAllClassesTest.php index ab021885c..09bf54d3a 100644 --- a/test/OQL/OQLToSQLAllClassesTest.php +++ b/test/OQL/OQLToSQLAllClassesTest.php @@ -22,10 +22,9 @@ class OQLToSQLAllCLassesTest extends ItopDataTestCase { const USE_TRANSACTION = false; - public function setUp() + public function setUp(): void { parent::setUp(); - require_once(APPROOT.'application/startup.inc.php'); SetupUtils::builddir(APPROOT.'log/test/OQLToSQL'); } diff --git a/test/OQL/OQLToSQLGroupByTest.php b/test/OQL/OQLToSQLGroupByTest.php index 62c279f5a..8db7239a4 100644 --- a/test/OQL/OQLToSQLGroupByTest.php +++ b/test/OQL/OQLToSQLGroupByTest.php @@ -17,10 +17,9 @@ class OQLToSQLTest extends ItopDataTestCase const USE_TRANSACTION = false; const TEST_CSV_RESULT = 'OQLToSQLTest.csv'; - public function setUp() + public function setUp(): void { parent::setUp(); - require_once(APPROOT.'application/startup.inc.php'); SetupUtils::builddir(APPROOT.'log/test/OQLToSQL'); } diff --git a/test/OQL/OQLToSQLNestedSelectTest.php b/test/OQL/OQLToSQLNestedSelectTest.php index 38383b351..296147c6a 100644 --- a/test/OQL/OQLToSQLNestedSelectTest.php +++ b/test/OQL/OQLToSQLNestedSelectTest.php @@ -22,10 +22,9 @@ class OQLToSQLNestedSelectTest extends ItopDataTestCase const USE_TRANSACTION = false; const TEST_CSV_RESULT = 'OQLToSQLTest.csv'; - public function setUp() + public function setUp(): void { parent::setUp(); - require_once(APPROOT.'application/startup.inc.php'); SetupUtils::builddir(APPROOT.'log/test/OQLToSQL'); } diff --git a/test/OQL/OQLToSQLTest.php b/test/OQL/OQLToSQLTest.php index dec00c31e..d7bb621f1 100644 --- a/test/OQL/OQLToSQLTest.php +++ b/test/OQL/OQLToSQLTest.php @@ -22,10 +22,9 @@ class OQLToSQLTest extends ItopDataTestCase const USE_TRANSACTION = false; const TEST_CSV_RESULT = 'OQLToSQLTest.csv'; - public function setUp() + public function setUp(): void { parent::setUp(); - require_once(APPROOT.'application/startup.inc.php'); SetupUtils::builddir(APPROOT.'log/test/OQLToSQL'); } diff --git a/test/application/DashboardLayoutTest.php b/test/application/DashboardLayoutTest.php index fc4e2dcc0..b6a552cd5 100644 --- a/test/application/DashboardLayoutTest.php +++ b/test/application/DashboardLayoutTest.php @@ -24,13 +24,6 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase; */ class DashboardLayoutTest extends ItopTestCase { - public function setUp() - { - parent::setUp(); - - require_once APPROOT.'application/dashboardlayout.class.inc.php'; - } - /** * @return array */ diff --git a/test/application/UtilsTest.php b/test/application/UtilsTest.php index 39c08405f..f2d671fad 100644 --- a/test/application/UtilsTest.php +++ b/test/application/UtilsTest.php @@ -24,12 +24,6 @@ */ class UtilsTest extends \Combodo\iTop\Test\UnitTest\ItopTestCase { - public function setUp() - { - parent::setUp(); - require_once(APPROOT.'application/utils.inc.php'); - } - public function testEndsWith() { $this->assertFalse(utils::EndsWith('a', 'bbbb')); diff --git a/test/application/composer/iTopComposerTest.php b/test/application/composer/iTopComposerTest.php index b3bcd356d..30e66c2a2 100644 --- a/test/application/composer/iTopComposerTest.php +++ b/test/application/composer/iTopComposerTest.php @@ -27,7 +27,7 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase; class iTopComposerTest extends ItopTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); clearstatcache(); diff --git a/test/application/privUITransactionFileTest.php b/test/application/privUITransactionFileTest.php index de36678d9..adfb86cbf 100644 --- a/test/application/privUITransactionFileTest.php +++ b/test/application/privUITransactionFileTest.php @@ -32,13 +32,6 @@ class privUITransactionFileTest extends ItopDataTestCase const USER1_TEST_LOGIN = 'user1_support_test_privUITransaction'; const USER2_TEST_LOGIN = 'user2_support_test_privUITransaction'; - public function setUp() - { - parent::setUp(); - require_once(APPROOT.'/application/startup.inc.php'); -// require_once(APPROOT.'application/utils.inc.php'); - } - /** * @dataProvider cleanupOldTransactionsProvider */ diff --git a/test/application/search/CriterionConversionTest.php b/test/application/search/CriterionConversionTest.php index a3d988d0f..ed1f86bf2 100644 --- a/test/application/search/CriterionConversionTest.php +++ b/test/application/search/CriterionConversionTest.php @@ -50,16 +50,6 @@ class CriterionConversionTest extends ItopDataTestCase { const CREATE_TEST_ORG = true; - /** - * @throws \Exception - */ - protected function setUp() - { - parent::setUp(); - - require_once(APPROOT."sources/application/search/criterionconversionabstract.class.inc.php"); - } - /** * @dataProvider ToOqlProvider * diff --git a/test/application/search/CriterionParserTest.php b/test/application/search/CriterionParserTest.php index 8bc6bfd23..ed31adb61 100644 --- a/test/application/search/CriterionParserTest.php +++ b/test/application/search/CriterionParserTest.php @@ -29,23 +29,15 @@ namespace Combodo\iTop\Test\UnitTest\Application\Search; use Combodo\iTop\Application\Search\CriterionParser; -use Combodo\iTop\Test\UnitTest\ItopTestCase; +use Combodo\iTop\Test\UnitTest\ItopDataTestCase; /** * @runTestsInSeparateProcesses * @preserveGlobalState disabled * @backupGlobals disabled */ -class CriterionParserTest extends ItopTestCase +class CriterionParserTest extends ItopDataTestCase { - protected function setUp() - { - parent::setUp(); - - require_once(APPROOT."application/startup.inc.php"); - require_once(APPROOT."sources/application/search/criterionparser.class.inc.php"); - } - public function testParse() { $sBaseOql = 'SELECT UserRequest'; diff --git a/test/application/search/SearchFormTest.php b/test/application/search/SearchFormTest.php index aac17df86..1cedd0312 100644 --- a/test/application/search/SearchFormTest.php +++ b/test/application/search/SearchFormTest.php @@ -36,16 +36,6 @@ class SearchFormTest extends ItopDataTestCase { const CREATE_TEST_ORG = true; - /** - * @throws Exception - */ - protected function setUp() - { - parent::setUp(); - - require_once(APPROOT."sources/application/search/searchform.class.inc.php"); - } - /** * @dataProvider GetFieldsProvider * @throws \OQLException diff --git a/test/core/BulkChangeTest.inc.php b/test/core/BulkChangeTest.inc.php index 7ceb0d06f..8fc3c93d0 100644 --- a/test/core/BulkChangeTest.inc.php +++ b/test/core/BulkChangeTest.inc.php @@ -2,8 +2,8 @@ namespace Combodo\iTop\Test\UnitTest\Core; -use Combodo\iTop\Test\UnitTest\ItopDataTestCase; use CMDBSource; +use Combodo\iTop\Test\UnitTest\ItopDataTestCase; use MetaModel; /** @@ -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/coreexception.class.inc.php'); require_once(APPROOT.'core/bulkchange.class.inc.php'); diff --git a/test/core/CMDBSource/CMDBSourceTest.php b/test/core/CMDBSource/CMDBSourceTest.php index 592786b02..106bbd91d 100644 --- a/test/core/CMDBSource/CMDBSourceTest.php +++ b/test/core/CMDBSource/CMDBSourceTest.php @@ -20,7 +20,7 @@ use utils; */ class CMDBSourceTest extends ItopTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/test/core/CMDBSource/TransactionsTest.php b/test/core/CMDBSource/TransactionsTest.php index b5f548e7e..335ab2938 100644 --- a/test/core/CMDBSource/TransactionsTest.php +++ b/test/core/CMDBSource/TransactionsTest.php @@ -26,10 +26,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'; diff --git a/test/core/ConfigPlaceholdersResolverTest.php b/test/core/ConfigPlaceholdersResolverTest.php index a9589360a..a4c6868ea 100644 --- a/test/core/ConfigPlaceholdersResolverTest.php +++ b/test/core/ConfigPlaceholdersResolverTest.php @@ -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 diff --git a/test/core/ConfigTest.php b/test/core/ConfigTest.php index f990cda08..0088ab374 100644 --- a/test/core/ConfigTest.php +++ b/test/core/ConfigTest.php @@ -23,19 +23,18 @@ namespace Combodo\iTop\Test\UnitTest\Core; use Combodo\iTop\Test\UnitTest\ItopTestCase; use Config; -use PHPUnit\Framework\TestCase; - /** +/** * @runTestsInSeparateProcesses * @preserveGlobalState disabled * @backupGlobals disabled */ 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'); } /** diff --git a/test/core/DBObjectTest.php b/test/core/DBObjectTest.php index 3b11d1ca6..50d47d67f 100644 --- a/test/core/DBObjectTest.php +++ b/test/core/DBObjectTest.php @@ -40,7 +40,7 @@ class DBObjectTest extends ItopDataTestCase { const CREATE_TEST_ORG = true; - protected function setUp() + protected function setUp(): void { parent::setUp(); require_once(APPROOT.'core/coreexception.class.inc.php'); diff --git a/test/core/DBSearchIntersectTest.php b/test/core/DBSearchIntersectTest.php index daa3f4929..44c609ab9 100644 --- a/test/core/DBSearchIntersectTest.php +++ b/test/core/DBSearchIntersectTest.php @@ -18,7 +18,7 @@ use DBSearch; class DBSearchIntersectTest extends ItopTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); require_once(APPROOT.'application/startup.inc.php'); diff --git a/test/core/DBSearchJoinTest.php b/test/core/DBSearchJoinTest.php index e71c9ee92..e590eaa53 100644 --- a/test/core/DBSearchJoinTest.php +++ b/test/core/DBSearchJoinTest.php @@ -19,7 +19,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'); diff --git a/test/core/DBSearchTest.php b/test/core/DBSearchTest.php index f6e10ddbd..8d29bfc99 100644 --- a/test/core/DBSearchTest.php +++ b/test/core/DBSearchTest.php @@ -53,7 +53,7 @@ class DBSearchTest extends ItopDataTestCase /** * @throws \Exception */ - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/test/core/DBSearchUpdateRealiasingMapTest.php b/test/core/DBSearchUpdateRealiasingMapTest.php index dd090bdc9..7187e466d 100644 --- a/test/core/DBSearchUpdateRealiasingMapTest.php +++ b/test/core/DBSearchUpdateRealiasingMapTest.php @@ -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'); diff --git a/test/core/LogAPITest.php b/test/core/LogAPITest.php index 1a47561ba..7f253ddf9 100644 --- a/test/core/LogAPITest.php +++ b/test/core/LogAPITest.php @@ -17,7 +17,7 @@ class LogAPITest extends ItopTestCase private $mockFileLog; private $oMetaModelConfig; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->mockFileLog = $this->createMock('FileLog'); diff --git a/test/core/LogFileNameBuilderTest.php b/test/core/LogFileNameBuilderTest.php index 6144a6f32..09f91e61c 100644 --- a/test/core/LogFileNameBuilderTest.php +++ b/test/core/LogFileNameBuilderTest.php @@ -25,21 +25,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); } } diff --git a/test/core/MetaModelTest.php b/test/core/MetaModelTest.php index c0bd95fa9..58b406043 100644 --- a/test/core/MetaModelTest.php +++ b/test/core/MetaModelTest.php @@ -23,7 +23,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'; diff --git a/test/core/TriggerTest.php b/test/core/TriggerTest.php index 768f1fb3b..87b41001e 100644 --- a/test/core/TriggerTest.php +++ b/test/core/TriggerTest.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; /** @@ -22,7 +20,7 @@ class TriggerTest extends ItopDataTestCase const USE_TRANSACTION = false; - protected function setUp() + protected function setUp(): void { parent::setUp(); } diff --git a/test/core/UniquenessConstraintTest.php b/test/core/UniquenessConstraintTest.php index 8411eefe5..1b724c749 100644 --- a/test/core/UniquenessConstraintTest.php +++ b/test/core/UniquenessConstraintTest.php @@ -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'); diff --git a/test/core/UserRightsTest.php b/test/core/UserRightsTest.php index ef38e1e68..317d3c9d4 100644 --- a/test/core/UserRightsTest.php +++ b/test/core/UserRightsTest.php @@ -36,16 +36,15 @@ use UserRights; */ class UserRightsTest extends ItopDataTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub - try{ - \utils::GetConfig()->SetModuleSetting('authent-local', 'password_validation.pattern', '' ); + try { + \utils::GetConfig()->SetModuleSetting('authent-local', 'password_validation.pattern', ''); self::CreateUser('admin', 1); } - catch(\CoreCannotSaveObjectException $e) - { + catch (\CoreCannotSaveObjectException $e) { } } diff --git a/test/core/WeeklyScheduledProcessTest.php b/test/core/WeeklyScheduledProcessTest.php index b1c31c4c4..e7a85f62b 100644 --- a/test/core/WeeklyScheduledProcessTest.php +++ b/test/core/WeeklyScheduledProcessTest.php @@ -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'); diff --git a/test/core/apcEmulationTest.php b/test/core/apcEmulationTest.php index 65a1d6f13..abc1296c4 100644 --- a/test/core/apcEmulationTest.php +++ b/test/core/apcEmulationTest.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(); } diff --git a/test/core/dictApcuTest.php b/test/core/dictApcuTest.php index cce8060f9..de6e6623c 100644 --- a/test/core/dictApcuTest.php +++ b/test/core/dictApcuTest.php @@ -28,7 +28,6 @@ namespace Combodo\iTop\Test\UnitTest\Core; use Combodo\iTop\Test\UnitTest\ItopTestCase; use Dict; -use Exception; /** @@ -42,12 +41,12 @@ class dictApcuTest extends ItopTestCase private $oApcService; private $sDictionaryFolder; - protected function setUp() + protected function setUp(): void { parent::setUp(); - require_once (APPROOT.'core' . DIRECTORY_SEPARATOR . 'coreexception.class.inc.php'); - require_once (APPROOT.'core' . DIRECTORY_SEPARATOR . 'dict.class.inc.php'); - require_once (APPROOT.'core' . DIRECTORY_SEPARATOR . 'apc-service.class.inc.php'); + require_once(APPROOT.'core'.DIRECTORY_SEPARATOR.'coreexception.class.inc.php'); + require_once(APPROOT.'core'.DIRECTORY_SEPARATOR.'dict.class.inc.php'); + require_once(APPROOT.'core'.DIRECTORY_SEPARATOR.'apc-service.class.inc.php'); $this->sEnvName = time(); $_SESSION['itop_env'] = $this->sEnvName; @@ -110,12 +109,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"); } diff --git a/test/core/dictTest.php b/test/core/dictTest.php index 5bea10386..8d66ae5f8 100644 --- a/test/core/dictTest.php +++ b/test/core/dictTest.php @@ -39,14 +39,14 @@ use Exception; class dictTest extends ItopTestCase { private $sEnvName; - protected function setUp() + protected function setUp(): void { parent::setUp(); - require_once (APPROOT.'core'. DIRECTORY_SEPARATOR . 'coreexception.class.inc.php'); - require_once (APPROOT.'core'. DIRECTORY_SEPARATOR . 'dict.class.inc.php'); - require_once (APPROOT.'core'. DIRECTORY_SEPARATOR . 'apc-service.class.inc.php'); + require_once(APPROOT.'core'.DIRECTORY_SEPARATOR.'coreexception.class.inc.php'); + require_once(APPROOT.'core'.DIRECTORY_SEPARATOR.'dict.class.inc.php'); + require_once(APPROOT.'core'.DIRECTORY_SEPARATOR.'apc-service.class.inc.php'); $this->sEnvName = time(); - $sDictionaryFolder = APPROOT."env-$this->sEnvName" . DIRECTORY_SEPARATOR . "dictionaries"; + $sDictionaryFolder = APPROOT."env-$this->sEnvName".DIRECTORY_SEPARATOR."dictionaries"; @mkdir($sDictionaryFolder, 0777, true); $sContent = <<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"); } diff --git a/test/core/iTopConfigParserTest.php b/test/core/iTopConfigParserTest.php index 0461f6391..1669ea2af 100644 --- a/test/core/iTopConfigParserTest.php +++ b/test/core/iTopConfigParserTest.php @@ -13,14 +13,14 @@ class iTopConfigParserTest extends ItopTestCase private $tmpSavePath; private $sConfigPath; - public function setUp() + public function setUp(): void { parent::setUp(); require_once APPROOT.'/core/iTopConfigParser.php'; clearstatcache(); $this->sConfigPath = utils::GetConfigFilePath(); - $this->tmpSavePath = tempnam( '/tmp/', 'config-itop'); + $this->tmpSavePath = tempnam('/tmp/', 'config-itop'); $this->conf_exists = is_file($this->sConfigPath); if ($this->conf_exists) @@ -30,11 +30,10 @@ class iTopConfigParserTest extends ItopTestCase clearstatcache(); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); // TODO: Change the autogenerated stub - if ($this->conf_exists) - { + if ($this->conf_exists) { rename($this->tmpSavePath, $this->sConfigPath); } } diff --git a/test/core/ormLinkSetTest.php b/test/core/ormLinkSetTest.php index efa2f6cb8..ad9ab9b99 100644 --- a/test/core/ormLinkSetTest.php +++ b/test/core/ormLinkSetTest.php @@ -47,9 +47,9 @@ class ormLinkSetTest extends ItopDataTestCase /** * @throws Exception */ - protected function setUp() + protected function setUp(): void { - parent::setUp(); + parent::setUp(); } /** diff --git a/test/core/ormTagSetTest.php b/test/core/ormTagSetTest.php index 1cdc0f49a..ce8779689 100644 --- a/test/core/ormTagSetTest.php +++ b/test/core/ormTagSetTest.php @@ -49,7 +49,7 @@ class ormTagSetTest extends ItopDataTestCase /** * @throws Exception */ - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/test/core/sanitizer/AbstractDOMSanitizerTest.php b/test/core/sanitizer/AbstractDOMSanitizerTest.php index bff69cf43..082f54e01 100644 --- a/test/core/sanitizer/AbstractDOMSanitizerTest.php +++ b/test/core/sanitizer/AbstractDOMSanitizerTest.php @@ -9,7 +9,7 @@ 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'); diff --git a/test/coreExtensions/UserLocalTest.php b/test/coreExtensions/UserLocalTest.php index c765d909b..889a44813 100644 --- a/test/coreExtensions/UserLocalTest.php +++ b/test/coreExtensions/UserLocalTest.php @@ -21,13 +21,12 @@ use UserLocal; class UserLocalTest extends ItopDataTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); - require_once(APPROOT.'application/startup.inc.php'); - require_once (APPROOT.'test/coreExtensions/UserLocalTest/UserLocalPasswordPolicyMock.php'); - require_once (APPROOT.'env-production/authent-local/model.authent-local.php'); + require_once(APPROOT.'test/coreExtensions/UserLocalTest/UserLocalPasswordPolicyMock.php'); + require_once(APPROOT.'env-production/authent-local/model.authent-local.php'); } /** diff --git a/test/integration/iTopModulesXmlVersionChecklistTest.php b/test/integration/iTopModulesXmlVersionChecklistTest.php index 45a0f0a82..b6dfcb289 100644 --- a/test/integration/iTopModulesXmlVersionChecklistTest.php +++ b/test/integration/iTopModulesXmlVersionChecklistTest.php @@ -29,7 +29,7 @@ use iTopDesignFormat; */ class iTopModulesXmlVersionIntegrationTest extends ItopTestCase { - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/test/itop-config/Validator/iTopConfigAstValidatorTest.php b/test/itop-config/Validator/iTopConfigAstValidatorTest.php index e06f7e0b6..c29d285d6 100644 --- a/test/itop-config/Validator/iTopConfigAstValidatorTest.php +++ b/test/itop-config/Validator/iTopConfigAstValidatorTest.php @@ -15,7 +15,7 @@ use PhpParser\PrettyPrinter\Standard; class iTopConfigAstValidatorTest extends ItopTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/test/itop-config/Validator/iTopConfigSyntaxValidatorTest.php b/test/itop-config/Validator/iTopConfigSyntaxValidatorTest.php index 74e779c38..77427cd94 100644 --- a/test/itop-config/Validator/iTopConfigSyntaxValidatorTest.php +++ b/test/itop-config/Validator/iTopConfigSyntaxValidatorTest.php @@ -16,7 +16,7 @@ use PhpParser\PrettyPrinter\Standard; class iTopConfigSyntaxValidatorTest extends ItopTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/test/itop-tickets/itopTicketTest.php b/test/itop-tickets/itopTicketTest.php index fbddcca04..486f1eb55 100644 --- a/test/itop-tickets/itopTicketTest.php +++ b/test/itop-tickets/itopTicketTest.php @@ -39,14 +39,6 @@ class ItopTicketTest extends ItopDataTestCase { const CREATE_TEST_ORG = true; - /** - * @throws Exception - */ - protected function setUp() - { - parent::setUp(); - } - /** *
 	 * Given:
diff --git a/test/postbuild_integration/iTopDesignFormatChecklistTest.php b/test/postbuild_integration/iTopDesignFormatChecklistTest.php
index 48e7a77f6..20b1063c1 100644
--- a/test/postbuild_integration/iTopDesignFormatChecklistTest.php
+++ b/test/postbuild_integration/iTopDesignFormatChecklistTest.php
@@ -17,7 +17,7 @@ use PHPUnit\Exception;
  */
 class TestForITopDesignFormatClass extends ItopTestCase
 {
-	protected function setUp()
+	protected function setUp(): void
 	{
 		parent::setUp();
 
@@ -148,6 +148,7 @@ class TestForITopDesignFormatClass extends ItopTestCase
 			{
 				if (is_dir($sPath))
 				{
+					/** @noinspection SlowArrayOperationsInLoopInspection */
 					$aDataModelFiles = array_merge($aDataModelFiles, $this->GetDataModelFiles($sPath));
 				}
 				else if (preg_match("/datamodel\..*\.xml/", basename($sPath)))
diff --git a/test/replay_query_log.php b/test/replay_query_log.php
index 4e9ba7847..fed149b0c 100644
--- a/test/replay_query_log.php
+++ b/test/replay_query_log.php
@@ -147,6 +147,7 @@ class QueryLogEntry
 			$iRepeat = utils::ReadParam('repeat', 3);
 			try
 			{
+				$resQuery = null;
 				$fRefTime = MyHelpers::getmicrotime();
 				for($i = 0 ; $i < $iRepeat ; $i++)
 				{
@@ -167,7 +168,6 @@ class QueryLogEntry
 			catch (Exception $e)
 			{
 				$this->aErrors[] = "Failed to execute the SQL:".$e->getMessage();
-				$resQuery = null;
 			}
 			if ($resQuery)
 			{
diff --git a/test/setup/DBBackupTest.php b/test/setup/DBBackupTest.php
index 7f767f439..3ad7a2115 100644
--- a/test/setup/DBBackupTest.php
+++ b/test/setup/DBBackupTest.php
@@ -19,12 +19,10 @@ class DBBackupTest extends ItopTestCase
 	 * @throws \MySQLException
 	 * @throws \ConfigException
 	 */
-	protected function setUp()
+	protected function setUp(): void
 	{
 		parent::setUp();
-		require_once(APPROOT.'core/config.class.inc.php');
 		require_once(APPROOT.'setup/backup.class.inc.php');
-		require_once(APPROOT.'core/cmdbsource.class.inc.php'); // DBBackup dependency
 
 		// We need a connection to the DB, so let's open it !
 		// We are using the default config file... as the server might not be configured for all the combination we are testing
diff --git a/test/setup/SetupUtilsTest.php b/test/setup/SetupUtilsTest.php
index c2c43221a..b93a9a5f0 100644
--- a/test/setup/SetupUtilsTest.php
+++ b/test/setup/SetupUtilsTest.php
@@ -17,7 +17,7 @@ use SetupUtils;
  */
 class SetupUtilsTest extends ItopTestCase
 {
-	protected function setUp()
+	protected function setUp(): void
 	{
 		parent::setUp();
 
diff --git a/test/setup/iTopDesignFormat/iTopDesignFormatTest.php b/test/setup/iTopDesignFormat/iTopDesignFormatTest.php
index 7b94ddd0f..74ee553ef 100644
--- a/test/setup/iTopDesignFormat/iTopDesignFormatTest.php
+++ b/test/setup/iTopDesignFormat/iTopDesignFormatTest.php
@@ -17,7 +17,7 @@ use iTopDesignFormat;
  */
 class TestForITopDesignFormatClass extends ItopTestCase
 {
-	protected function setUp()
+	protected function setUp(): void
 	{
 		parent::setUp();
 
diff --git a/test/status/StatusIncTest.php b/test/status/StatusIncTest.php
index fbf72af1e..645c9ded5 100644
--- a/test/status/StatusIncTest.php
+++ b/test/status/StatusIncTest.php
@@ -30,19 +30,16 @@ if (!defined('DEBUG_UNIT_TEST')) {
 class StatusIncTest extends TestCase {
 
     /**
-     *
-     * @var string 
+     * @var string
      */
     protected $sAppRoot = '';
 
-    /**
-     * 
-     */
-    protected function setUp() {
-        //AppRoot is the directory containing the directory 
-        //Assume getcwd() is runned inside APPROOT/test
-        $this->sAppRoot = __DIR__ . '/../../sources/application/status';
-    }
+	protected function setUp(): void
+	{
+		//AppRoot is the directory containing the directory
+		//Assume getcwd() is runned inside APPROOT/test
+		$this->sAppRoot = __DIR__.'/../../sources/application/status';
+	}
 
     /**
      * @expectedException \Exception
diff --git a/test/webservices/RestTest.php b/test/webservices/RestTest.php
index d600660db..16604009d 100644
--- a/test/webservices/RestTest.php
+++ b/test/webservices/RestTest.php
@@ -24,16 +24,16 @@ class RestTest extends ItopDataTestCase
 	/**
      * @throws Exception
      */
-    protected function setUp()
-	{
-		parent::setUp();
-		require_once(APPROOT.'application/startup.inc.php');
-		$this->sLogin = "rest-user-" . date('dmYHis');
-		$this->CreateTestOrganization();
+    protected function setUp(): void
+    {
+	    parent::setUp();
 
-		if (!empty($this->sTmpFile)){
-			unlink($this->sTmpFile);
-		}
+	    $this->sLogin = "rest-user-".date('dmYHis');
+	    $this->CreateTestOrganization();
+
+	    if (!empty($this->sTmpFile)) {
+		    unlink($this->sTmpFile);
+	    }
 
 		$sConfigFile = \utils::GetConfig()->GetLoadedFile();
 		@chmod($sConfigFile, 0770);