N°6658 - Boost PHPUnit tests execution

This commit is contained in:
Romain Quetiez
2023-08-04 14:06:44 +02:00
parent d951d3b872
commit 65bb76b9e3
74 changed files with 690 additions and 416 deletions

View File

@@ -9,9 +9,6 @@ use MetaModel;
use utils;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
* @covers \ActionEmail
*/
class ActionEmailTest extends ItopDataTestCase

View File

@@ -5,11 +5,6 @@ namespace Combodo\iTop\Test\UnitTest\Core;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use MetaModel;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class AttributeDefinitionTest extends ItopDataTestCase {
const CREATE_TEST_ORG = true;

View File

@@ -7,9 +7,7 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use MetaModel;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
* @runClassInSeparateProcess
*/
class BulkChangeTest extends ItopDataTestCase {
const CREATE_TEST_ORG = true;

View File

@@ -15,11 +15,6 @@ use MetaModel;
*/
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class CMDBObjectTest extends ItopDataTestCase
{
private $sAdminLogin;
@@ -99,6 +94,7 @@ class CMDBObjectTest extends ItopDataTestCase
* @covers CMDBObject::SetCurrentChange
* @since 3.0.1 N°5135 - Impersonate: history of changes versus log entries
*
* @runInSeparateProcess
* @dataProvider CurrentChangeUnderImpersonationProvider
*/
public function testCurrentChangeUnderImpersonation($sTrackInfo=null, $sExpectedChangeLogWhenImpersonation=null) {

View File

@@ -17,11 +17,6 @@ use utils;
* @package Combodo\iTop\Test\UnitTest\Core
*/
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class CMDBSourceTest extends ItopTestCase
{
protected function setUp(): void
@@ -126,6 +121,8 @@ class CMDBSourceTest extends ItopTestCase
* @throws \CoreException
* @throws \MySQLException
* @since 3.0.0 N°4215
*
* @runInSeparateProcess Resetting DB connection, thus making other tests to fail!
*/
public function testIsOpenedDbConnectionUsingTls()
{

View File

@@ -14,10 +14,6 @@ use MetaModel;
use MySQLTransactionNotClosedException;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*
* @group itopRequestMgmt
* @group specificOrgInSampleData
* Class TransactionsTest
@@ -108,6 +104,15 @@ class TransactionsTest extends ItopTestCase
}
}
/**
* This test case was originaly in DBInsertProvider
* @runInSeparateProcess Failing when run in the same process as other...
*/
public function testDBInsertCaseHistory38()
{
$this->testDBInsert(40, false);
}
public function DBInsertProvider()
{
return [
@@ -151,7 +156,6 @@ class TransactionsTest extends ItopTestCase
"History 35" => ['iFailAt' => 37, 'bIsInDB' => false],
"History 36" => ['iFailAt' => 38, 'bIsInDB' => false],
"History 37" => ['iFailAt' => 39, 'bIsInDB' => false],
"History 38" => ['iFailAt' => 40, 'bIsInDB' => false],
];
}
@@ -276,6 +280,7 @@ class TransactionsTest extends ItopTestCase
protected function tearDown(): void
{
try {
DbConnectionWrapper::SetDbConnectionMockForQuery();
parent::tearDown();
}
catch (MySQLTransactionNotClosedException $e) {

View File

@@ -33,10 +33,6 @@ use MetaModel;
/**
* @group specificOrgInSampleData
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class DBObjectTest extends ItopDataTestCase
{

View File

@@ -17,10 +17,6 @@ use DBSearch;
* <ul>
* <li>MakeGroupByQuery</li>
* </ul>
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class DBSearchCommitTest extends ItopDataTestCase
{

View File

@@ -11,10 +11,6 @@ use DBSearch;
* Class DBSearchIntersectTest
*
* @package Combodo\iTop\Test\UnitTest\Core
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class DBSearchIntersectTest extends ItopTestCase
{
@@ -72,16 +68,16 @@ class DBSearchIntersectTest extends ItopTestCase
'result' => "SELECT `L`, `P` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id WHERE (`P`.`org_id` = 3)");
$aTests['Multiple selected classes inverted 1'] = array(
'left' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN PC AS D ON D.location_id = L.id JOIN Person AS P2 ON P.manager_id = P2.id WHERE 1",
'left' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN Server AS D ON D.location_id = L.id JOIN Person AS P2 ON P.manager_id = P2.id WHERE 1",
'right' => "SELECT Location WHERE org_id = 3",
'alias' => "L",
'result' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN PC AS `D` ON `D`.location_id = `L`.id JOIN Person AS `P2` ON `P`.manager_id = `P2`.id WHERE (`L`.`org_id` = 3)");
'result' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN Server AS `D` ON `D`.location_id = `L`.id JOIN Person AS `P2` ON `P`.manager_id = `P2`.id WHERE (`L`.`org_id` = 3)");
$aTests['Multiple selected classes inverted 2'] = array(
'left' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN PC AS D ON D.location_id = L.id JOIN Person AS P2 ON P.manager_id = P2.id WHERE (`L`.`org_id` = 3)",
'left' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN Server AS D ON D.location_id = L.id JOIN Person AS P2 ON P.manager_id = P2.id WHERE (`L`.`org_id` = 3)",
'right' => "SELECT Person WHERE org_id = 3",
'alias' => "P",
'result' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN PC AS `D` ON `D`.location_id = `L`.id JOIN Person AS `P2` ON `P`.manager_id = `P2`.id WHERE ((`L`.`org_id` = 3) AND (`P`.`org_id` = 3))");
'result' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN Server AS `D` ON `D`.location_id = `L`.id JOIN Person AS `P2` ON `P`.manager_id = `P2`.id WHERE ((`L`.`org_id` = 3) AND (`P`.`org_id` = 3))");
$aTests['Same class'] = array(
'left' => "SELECT Contact WHERE name = 'Christie'",
@@ -192,9 +188,9 @@ class DBSearchIntersectTest extends ItopTestCase
'result' => "SELECT `L`, `P` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id WHERE (`P`.`org_id` = 3)");
$aTests['Multiple selected classes inverted 2'] = array(
'left' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN PC AS D ON D.location_id = L.id JOIN Person AS P2 ON P.manager_id = P2.id WHERE (`L`.`org_id` = 3)",
'left' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN Server AS D ON D.location_id = L.id JOIN Person AS P2 ON P.manager_id = P2.id WHERE (`L`.`org_id` = 3)",
'right' => "SELECT Person WHERE org_id = 3",
'result' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN PC AS `D` ON `D`.location_id = `L`.id JOIN Person AS `P2` ON `P`.manager_id = `P2`.id WHERE ((`L`.`org_id` = 3) AND (`P`.`org_id` = 3))");
'result' => "SELECT `L`, `P`, `D` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id JOIN Server AS `D` ON `D`.location_id = `L`.id JOIN Person AS `P2` ON `P`.manager_id = `P2`.id WHERE ((`L`.`org_id` = 3) AND (`P`.`org_id` = 3))");
$aTests['Same class'] = array(
'left' => "SELECT Contact WHERE name = 'Christie'",

View File

@@ -11,10 +11,6 @@ use DBSearch;
* Class DBSearchIntersectTest
*
* @package Combodo\iTop\Test\UnitTest\Core
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class DBSearchJoinTest extends ItopDataTestCase {

View File

@@ -42,10 +42,6 @@ use FunctionExpression;
* <ul>
* <li>MakeGroupByQuery</li>
* </ul>
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class DBSearchTest extends ItopDataTestCase
{

View File

@@ -10,10 +10,6 @@ use DBObjectSearch;
* Class DBSearchUpdateRealiasingMapTest
*
* @package Combodo\iTop\Test\UnitTest\Core
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class DBSearchUpdateRealiasingMapTest extends ItopDataTestCase
{

View File

@@ -7,11 +7,6 @@
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class DBUnionSearchTest extends ItopDataTestCase
{

View File

@@ -13,11 +13,6 @@ use FunctionExpression;
use MetaModel;
use ScalarExpression;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ExpressionEvaluateTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;

View File

@@ -5,11 +5,6 @@ namespace Combodo\iTop\Test\UnitTest\Core;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use Expression;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ExpressionTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;

View File

@@ -17,10 +17,6 @@ use utils;
* @group specificOrgInSampleData
* Class GetSelectFilterTest
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*
* @package Combodo\iTop\Test\UnitTest\Webservices
*/
class GetSelectFilterTest extends ItopDataTestCase

View File

@@ -10,12 +10,6 @@ namespace Combodo\iTop\Test\UnitTest\Core;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use InlineImage;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class InlineImageTest extends ItopDataTestCase
{
/**

View File

@@ -39,6 +39,8 @@ class DeprecatedCallsLogTest extends ItopTestCase {
}
/**
* @runInSeparateProcess Necessary, due to the DeprecatedCallsLog being enabled (no mean to reset)
*
* The error handler set by DeprecatedCallsLog during startup was causing PHPUnit to miss PHP notices like "undefined offset"
*
* The error handler is now disabled when running PHPUnit

View File

@@ -21,11 +21,6 @@ use ExceptionLog;
require_once(__DIR__.'/ExceptionLogTest/Exceptions.php');
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ExceptionLogTest extends ItopDataTestCase
{
protected function setUp(): void
@@ -35,6 +30,8 @@ class ExceptionLogTest extends ItopDataTestCase
}
/**
* @runInSeparateProcess
*
* @dataProvider logProvider
*/
public function testLogInFile($aLevels, $aExceptions, $sChannel, $aExpectedWriteNumber, $logLevelMin, $aExpectedDbWriteNumber, $logLevelMinWriteInDb)

View File

@@ -16,11 +16,6 @@ namespace Combodo\iTop\Test\UnitTest\Core\Log;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class LogAPITest extends ItopDataTestCase
{
private $mockFileLog;
@@ -38,7 +33,6 @@ class LogAPITest extends ItopDataTestCase
/**
* @dataProvider LogApiProvider
* @test
* @backupGlobals disabled
*/
public function TestLogApi($oConfigObject, $sMessage, $Channel, $sExpectedLevel, $sExpectedMessage, $sExpectedChannel = '')
{
@@ -63,7 +57,6 @@ class LogAPITest extends ItopDataTestCase
/**
* @dataProvider LogWarningWithASpecificChannelProvider
* @test
* @backupGlobals disabled
*/
public function TestLogWarningWithASpecificChannel($expectedCallNb, $sExpectedLevel, $ConfigReturnedObject, $bExceptionRaised=false)
{
@@ -110,7 +103,6 @@ class LogAPITest extends ItopDataTestCase
/**
* @dataProvider LogOkWithASpecificChannel
* @test
* @backupGlobals disabled
*/
public function TestLogOkWithASpecificChannel($expectedCallNb, $sExpectedLevel, $ConfigReturnedObject, $bExceptionRaised=false)
{

View File

@@ -10,10 +10,6 @@ use MetaModel;
/**
* Class MetaModelTest
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*
* @since 2.6.0
* @package Combodo\iTop\Test\UnitTest\Core
*/
@@ -181,6 +177,8 @@ class MetaModelTest extends ItopDataTestCase
}
/**
* @runInSeparateProcess
*
* @dataProvider enumPluginsProvider
*
* @param $expectedResults
@@ -228,6 +226,8 @@ class MetaModelTest extends ItopDataTestCase
}
/**
* @runInSeparateProcess
*
* @dataProvider getPluginsProvider
*
* @param $expectedInstanciationCalls

View File

@@ -16,11 +16,6 @@ use OQLException;
use OqlInterpreter;
use OQLParserException;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class OQLParserTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;

View File

@@ -21,11 +21,6 @@ use QueryBuilderContext;
use SQLObjectQueryBuilder;
use utils;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class OQLTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;

View File

@@ -18,10 +18,6 @@ use TagSetFieldData;
/**
* @group itopFaqLight
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class TagSetFieldDataTest extends ItopDataTestCase
{

View File

@@ -14,10 +14,6 @@ use TriggerOnObjectCreate;
* Class TriggerTest
*
* @package Combodo\iTop\Test\UnitTest\Core
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class TriggerTest extends ItopDataTestCase
{
@@ -35,9 +31,9 @@ class TriggerTest extends ItopDataTestCase
$oTrigger = MetaModel::NewObject('TriggerOnObjectCreate');
$oTrigger->Set('context', ContextTag::TAG_PORTAL.', '.ContextTag::TAG_CRON);
$this->assertFalse($oTrigger->IsContextValid());
ContextTag::AddContext(ContextTag::TAG_SETUP);
$oC1 = new ContextTag(ContextTag::TAG_SETUP);
$this->assertFalse($oTrigger->IsContextValid());
ContextTag::AddContext(ContextTag::TAG_CRON);
$oC2 = new ContextTag(ContextTag::TAG_CRON);
$this->assertTrue($oTrigger->IsContextValid());
}
@@ -55,7 +51,7 @@ class TriggerTest extends ItopDataTestCase
}
catch (\CoreException $e1) {
$this->assertEquals('CoreException', get_class($e1));
$this->assertEquals('Unknown class \'Toto\' (<b title="Trigger">TriggerOnObjectCreate</b>::-1 ()<br/>)', $e1->getMessage());
$this->assertStringStartsWith('Unknown class \'Toto\' (<b title="Trigger">TriggerOnObjectCreate</b>::-', $e1->getMessage());
$fullStackTraceAsString = $e1->getFullStackTraceAsString();
$this->assertStringContainsString("MetaModel::NewObject", $fullStackTraceAsString,"new enriched exception should contain root cause method: " . $fullStackTraceAsString);

View File

@@ -41,10 +41,6 @@ use utils;
* @group itopRequestMgmt
* @group userRights
* @group defaultProfiles
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class UserRightsTest extends ItopDataTestCase
{
@@ -68,6 +64,25 @@ class UserRightsTest extends ItopDataTestCase
'ModuleInstallation' => ['class' => 'ModuleInstallation', 'attcode' => 'name'],
];
/**
* @param string $sLoginPrefix
* @param int $iProfileId initial profile
*
* @return \DBObject
* @throws \CoreException
* @throws \Exception
*/
protected function CreateUniqueUserAndLogin(string $sLoginPrefix, int $iProfileId): DBObject
{
static $iCount = 0;
$sLogin = $sLoginPrefix.$iCount;
$iCount++;
$oUser = self::CreateUser($sLogin, $iProfileId);
$_SESSION = array();
UserRights::Login($sLogin);
return $oUser;
}
public function testIsLoggedIn()
{
@@ -90,6 +105,7 @@ class UserRightsTest extends ItopDataTestCase
$_SESSION = [];
$this->assertEquals($bResult, UserRights::Login($sLogin));
$this->assertEquals($bResult, UserRights::IsLoggedIn());
UserRights::Logoff();
}
public function LoginProvider(): array
@@ -101,22 +117,6 @@ class UserRightsTest extends ItopDataTestCase
];
}
/**
* @param string $sLogin
* @param int $iProfileId initial profile
*
* @return \DBObject
* @throws \CoreException
* @throws \Exception
*/
protected function AddUser(string $sLogin, int $iProfileId): DBObject
{
$oUser = self::CreateUser($sLogin, $iProfileId);
$oUser->DBUpdate();
return $oUser;
}
/** Test IsActionAllowed when not logged => always true
*
* @dataProvider ActionAllowedNotLoggedProvider
@@ -145,8 +145,7 @@ class UserRightsTest extends ItopDataTestCase
return $aClassActions;
}
/** Test IsActionAllowed
*
/**
* @dataProvider ActionAllowedProvider
*
* @param int $iProfileId
@@ -158,11 +157,10 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testIsActionAllowed(int $iProfileId, array $aClassActionResult)
{
$this->AddUser('test1', $iProfileId);
$_SESSION = array();
UserRights::Login('test1');
$this->CreateUniqueUserAndLogin('test1', $iProfileId);
$bRes = UserRights::IsActionAllowed($aClassActionResult['class'], $aClassActionResult['action']) == UR_ALLOWED_YES;
$this->assertEquals($aClassActionResult['res'], $bRes);
UserRights::Logoff();
}
/*
@@ -239,12 +237,11 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testIsActionAllowedOnAttribute(int $iProfileId, array $aClassActionResult)
{
$this->AddUser('test1', $iProfileId);
$_SESSION = [];
UserRights::Login('test1');
$this->CreateUniqueUserAndLogin('test1', $iProfileId);
$sClass = $aClassActionResult['class'];
$bRes = UserRights::IsActionAllowedOnAttribute($sClass, self::$aClasses[$sClass]['attcode'], $aClassActionResult['action']) == UR_ALLOWED_YES;
$this->assertEquals($aClassActionResult['res'], $bRes);
UserRights::Logoff();
}
/*
@@ -291,9 +288,7 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testProfileDenyingConsole(int $iProfileId)
{
$oUser = $this->AddUser('test1', $iProfileId);
$_SESSION = [];
UserRights::Login('test1');
$oUser = $this->CreateUniqueUserAndLogin('test1', $iProfileId);
try {
$this->AddProfileToUser($oUser, 2);
@@ -303,6 +298,7 @@ class UserRightsTest extends ItopDataTestCase
// logout
$_SESSION = [];
UserRights::Logoff();
}
public function ProfileDenyingConsoleProvider(): array
@@ -322,9 +318,7 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testProfileCannotModifySelf(int $iProfileId)
{
$oUser = $this->AddUser('test1', $iProfileId);
$_SESSION = [];
UserRights::Login('test1');
$oUser = $this->CreateUniqueUserAndLogin('test1', $iProfileId);
try {
$this->AddProfileToUser($oUser, 1); // trying to become an admin
@@ -334,6 +328,7 @@ class UserRightsTest extends ItopDataTestCase
// logout
$_SESSION = [];
UserRights::Logoff();
}
public function ProfileCannotModifySelfProvider(): array
@@ -353,9 +348,7 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testDeletingSelfUser(int $iProfileId)
{
$oUser = $this->AddUser('test1', $iProfileId);
$_SESSION = [];
UserRights::Login('test1');
$oUser = $this->CreateUniqueUserAndLogin('test1', $iProfileId);
try {
$oUser->DBDelete();
@@ -365,6 +358,7 @@ class UserRightsTest extends ItopDataTestCase
// logout
$_SESSION = [];
UserRights::Logoff();
}
public function DeletingSelfUserProvider(): array
@@ -387,9 +381,7 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testRemovingOwnContact(int $iProfileId)
{
$oUser = $this->AddUser('test1', $iProfileId);
$_SESSION = [];
UserRights::Login('test1');
$oUser = $this->CreateUniqueUserAndLogin('test1', $iProfileId);
$oUser->Set('contactid', 0);
@@ -398,6 +390,8 @@ class UserRightsTest extends ItopDataTestCase
$this->fail('Current User cannot remove his own contact');
} catch (CoreCannotSaveObjectException $e) {
}
UserRights::Logoff();
}
public function RemovingOwnContactProvider(): array
@@ -417,9 +411,7 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testUpgradingToAdmin()
{
$oUser = $this->AddUser('test1', 3);
$_SESSION = [];
UserRights::Login('test1');
$oUser = $this->CreateUniqueUserAndLogin('test1', 3);
try {
$this->AddProfileToUser($oUser, 1);
@@ -430,6 +422,7 @@ class UserRightsTest extends ItopDataTestCase
// logout
$_SESSION = [];
UserRights::Logoff();
}
/**
@@ -441,9 +434,7 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testDenyingUserModification()
{
$oUser = $this->AddUser('test1', 1);
$_SESSION = [];
UserRights::Login('test1');
$oUser = $this->CreateUniqueUserAndLogin('test1', 1);
$this->AddProfileToUser($oUser, 3);
// Keep only the profile 3 (remove profile 1)
@@ -461,6 +452,7 @@ class UserRightsTest extends ItopDataTestCase
// logout
$_SESSION = [];
UserRights::Logoff();
}
/**
@@ -468,10 +460,8 @@ class UserRightsTest extends ItopDataTestCase
*/
public function testNonAdminCanListOwnProfiles($bHideAdministrators)
{
$oUser = $this->AddUser('test1', 2); // portal user
$_SESSION = [];
utils::GetConfig()->Set('security.hide_administrators', $bHideAdministrators);
UserRights::Login('test1');
$oUser = $this->CreateUniqueUserAndLogin('test1', 2); // portal user
// List the link between the User and the Profiles
$oSearch = new DBObjectSearch('URP_UserProfile');
@@ -486,6 +476,7 @@ class UserRightsTest extends ItopDataTestCase
// logout
$_SESSION = [];
UserRights::Logoff();
}
public function NonAdminCanListOwnProfilesProvider(): array
@@ -496,16 +487,15 @@ class UserRightsTest extends ItopDataTestCase
];
}
/**
* @runInSeparateProcess
*@dataProvider NonAdminCannotListAdminProfilesProvider
*/
public function testNonAdminCannotListAdminProfiles($bHideAdministrators, $iExpectedCount)
{
utils::GetConfig()->Set('security.hide_administrators', $bHideAdministrators);
$this->AddUser('test1', 2); // portal user
$oUserAdmin = $this->AddUser('admin1', 1);
$_SESSION = [];
UserRights::Login('test1');
$oUserAdmin = $this->CreateUser('admin1', 1);
$this->CreateUniqueUserAndLogin('test1', 2); // portal user
$oSearch = new DBObjectSearch('URP_UserProfile');
$oSearch->AddCondition('userid', $oUserAdmin->GetKey());
@@ -518,6 +508,7 @@ class UserRightsTest extends ItopDataTestCase
// logout
$_SESSION = [];
UserRights::Logoff();
}
public function NonAdminCannotListAdminProfilesProvider(): array

View File

@@ -11,11 +11,6 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
use MetaModel;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ValueSetObjectsTest extends ItopTestCase
{

View File

@@ -33,14 +33,10 @@ use MetaModel;
/**
* @group specificOrgInSampleData
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class XMLDataLoaderTest extends ItopDataTestCase
{
const CREATE_TEST_ORG = true;
const CREATE_TEST_ORG = false;
public function testDataLoader()
{

View File

@@ -33,8 +33,6 @@ define('UNIT_MAX_CACHE_FILES', 10);
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class apcEmulationTest extends ItopTestCase
{

View File

@@ -32,8 +32,6 @@ use Dict;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class dictApcuTest extends ItopTestCase
{

View File

@@ -30,11 +30,8 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
use Dict;
use Exception;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
* @runClassInSeparateProcess
*/
class dictTest extends ItopTestCase
{

View File

@@ -15,10 +15,6 @@ use ormCaseLog;
* Tests of the ormCaseLog class
*
* @covers \ormCaseLog
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ormCaseLogTest extends ItopDataTestCase
{

View File

@@ -37,10 +37,6 @@ use ormLinkSet;
* @group itopRequestMgmt
* @group itopConfigMgmt
* Tests of the ormLinkSet class using N-N links between FunctionalCI and Contact
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ormLinkSetTest extends ItopDataTestCase
{

View File

@@ -12,10 +12,6 @@ use Utils;
/**
* Tests of the ormPassword class
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ormPasswordTest extends ItopDataTestCase
{
@@ -32,9 +28,11 @@ class ormPasswordTest extends ItopDataTestCase
*/
public function testCheckHash($sToHashValues, $sToHashSalt, $sHashAlgo, $sExpectedHash)
{
$prevHashAlgo = utils::GetConfig()->GetPasswordHashAlgo($sHashAlgo);
utils::GetConfig()->SetPasswordHashAlgo($sHashAlgo);
$oPassword1 = new ormPassword($sExpectedHash, $sToHashSalt);
static::assertTrue($oPassword1->CheckPassword($sToHashValues));
utils::GetConfig()->SetPasswordHashAlgo($prevHashAlgo);
}
public function HashProvider()

View File

@@ -12,10 +12,6 @@ use utils;
/**
* Tests of the ormStyle class
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ormStyleTest extends ItopTestCase
{

View File

@@ -38,10 +38,6 @@ define('MAX_TAGS', 12);
/**
* @group itopFaqLight
* Tests of the ormTagSet class
*
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ormTagSetTest extends ItopDataTestCase
{