mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 22:18:46 +02:00
Merge remote-tracking branch 'origin/support/3.0' into support/3.1
# Conflicts: # tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php
This commit is contained in:
@@ -10,9 +10,6 @@ use utils;
|
||||
use Dict;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
* @covers \ActionEmail
|
||||
*/
|
||||
class ActionEmailTest extends ItopDataTestCase
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -21,11 +21,6 @@ use Person;
|
||||
use Team;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class CRUDEventTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = true;
|
||||
@@ -37,6 +32,8 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
static::$aEventCalls = [];
|
||||
static::$iEventCalls = 0;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
@@ -54,7 +51,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testDBInsert()
|
||||
{
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
|
||||
$oOrg = $this->CreateOrganization('Organization1');
|
||||
@@ -77,7 +74,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oOrg = $this->CreateOrganization('Organization1');
|
||||
$this->assertIsObject($oOrg);
|
||||
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
|
||||
$oOrg->Set('name', 'test');
|
||||
@@ -101,7 +98,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oOrg = $this->CreateOrganization('Organization1');
|
||||
$this->assertIsObject($oOrg);
|
||||
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
|
||||
$oOrg->DBUpdate();
|
||||
@@ -122,7 +119,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testComputeValuesOnInsert()
|
||||
{
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Set the person's first name during Compute Values
|
||||
$oEventReceiver->AddCallback(EVENT_DB_COMPUTE_VALUES, Person::class, 'SetPersonFirstName');
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_COMPUTE_VALUES);
|
||||
@@ -155,7 +152,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oPerson = $this->CreatePerson(1);
|
||||
$this->assertIsObject($oPerson);
|
||||
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Set the person's first name during Compute Values
|
||||
$oEventReceiver->AddCallback(EVENT_DB_COMPUTE_VALUES, Person::class, 'SetPersonFirstName');
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_COMPUTE_VALUES);
|
||||
@@ -180,7 +177,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testCheckToWriteProtectedOnInsert()
|
||||
{
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Modify the person's function
|
||||
$oEventReceiver->AddCallback(EVENT_DB_CHECK_TO_WRITE, Person::class, 'SetPersonFunction');
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_CHECK_TO_WRITE);
|
||||
@@ -201,7 +198,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$this->assertIsObject($oPerson);
|
||||
|
||||
// Modify the person's function
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->AddCallback(EVENT_DB_CHECK_TO_WRITE, Person::class, 'SetPersonFunction');
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_CHECK_TO_WRITE);
|
||||
|
||||
@@ -221,7 +218,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testModificationsDuringCreateDone()
|
||||
{
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Set the person's first name during Compute Values
|
||||
$oEventReceiver->AddCallback(EVENT_DB_AFTER_WRITE, Person::class, 'SetPersonFirstName');
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
@@ -254,7 +251,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oPerson = $this->CreatePerson(1);
|
||||
$this->assertIsObject($oPerson);
|
||||
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Set the person's first name during Compute Values
|
||||
$oEventReceiver->AddCallback(EVENT_DB_AFTER_WRITE, Person::class, 'SetPersonFirstName');
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
@@ -287,7 +284,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oPerson = $this->CreatePerson(1);
|
||||
$this->assertIsObject($oPerson);
|
||||
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Set the person's first name during Compute Values
|
||||
$oEventReceiver->AddCallback(EVENT_DB_AFTER_WRITE, Person::class, 'SetPersonFirstName', 100);
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_AFTER_WRITE);
|
||||
@@ -329,7 +326,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
|
||||
$this->debug("\n-------------> Test Starts HERE\n");
|
||||
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
|
||||
$oTeam = MetaModel::NewObject(Team::class, ['name' => 'TestTeam1', 'persons_list' => $oLinkSet, 'org_id' => $this->getTestOrgId()]);
|
||||
@@ -375,7 +372,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oLinkSet->AddItem($oLink);
|
||||
|
||||
$this->debug("\n-------------> Test Starts HERE\n");
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Create a new role and add it to the newly created lnkPersonToTeam
|
||||
$oEventReceiver->AddCallback(EVENT_DB_AFTER_WRITE, lnkPersonToTeam::class, 'AddRoleToLink');
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
@@ -411,13 +408,13 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
*/
|
||||
public function testPostponedUpdates()
|
||||
{
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Set the person's function after the creation
|
||||
$oEventReceiver->AddCallback(EVENT_DB_AFTER_WRITE, Person::class, 'SetPersonFunction');
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_AFTER_WRITE);
|
||||
|
||||
// Intentionally register twice so 2 modifications will be done
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->AddCallback(EVENT_DB_AFTER_WRITE, Person::class, 'SetPersonFirstName');
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_AFTER_WRITE);
|
||||
|
||||
@@ -444,7 +441,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
|
||||
public function testCrudStack()
|
||||
{
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
// Modify the person's function
|
||||
$oEventReceiver->AddCallback(EVENT_DB_COMPUTE_VALUES, Person::class, 'CheckCrudStack');
|
||||
$oEventReceiver->RegisterCRUDListeners(EVENT_DB_COMPUTE_VALUES);
|
||||
@@ -490,7 +487,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oTeam->DBInsert();
|
||||
|
||||
// Start receiving events
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
|
||||
// Create a link between Person and Team => generate 2 EVENT_DB_LINKS_CHANGED
|
||||
@@ -514,7 +511,7 @@ class CRUDEventTest extends ItopDataTestCase
|
||||
$oLnk->DBInsert();
|
||||
|
||||
// Start receiving events
|
||||
$oEventReceiver = new CRUDEventReceiver();
|
||||
$oEventReceiver = new CRUDEventReceiver($this);
|
||||
$oEventReceiver->RegisterCRUDListeners();
|
||||
|
||||
$oLnk->DBDelete();
|
||||
@@ -553,10 +550,16 @@ class ClassesWithDebug
|
||||
*/
|
||||
class CRUDEventReceiver extends ClassesWithDebug
|
||||
{
|
||||
private $oTestCase;
|
||||
private $aCallbacks = [];
|
||||
|
||||
public static $bIsObjectInCrudStack;
|
||||
|
||||
public function __construct(ItopDataTestCase $oTestCase)
|
||||
{
|
||||
$this->oTestCase = $oTestCase;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
@@ -613,30 +616,21 @@ class CRUDEventReceiver extends ClassesWithDebug
|
||||
{
|
||||
$this->Debug('Registering Test event listeners');
|
||||
if (is_null($sEvent)) {
|
||||
EventService::RegisterListener(EVENT_DB_COMPUTE_VALUES, [$this, 'OnEvent']);
|
||||
EventService::RegisterListener(EVENT_DB_CHECK_TO_WRITE, [$this, 'OnEvent']);
|
||||
EventService::RegisterListener(EVENT_DB_CHECK_TO_DELETE, [$this, 'OnEvent']);
|
||||
EventService::RegisterListener(EVENT_DB_BEFORE_WRITE, [$this, 'OnEvent']);
|
||||
EventService::RegisterListener(EVENT_DB_AFTER_WRITE, [$this, 'OnEvent']);
|
||||
EventService::RegisterListener(EVENT_DB_AFTER_DELETE, [$this, 'OnEvent']);
|
||||
EventService::RegisterListener(EVENT_DB_LINKS_CHANGED, [$this, 'OnEvent']);
|
||||
$this->oTestCase->EventService_RegisterListener(EVENT_DB_COMPUTE_VALUES, [$this, 'OnEvent']);
|
||||
$this->oTestCase->EventService_RegisterListener(EVENT_DB_CHECK_TO_WRITE, [$this, 'OnEvent']);
|
||||
$this->oTestCase->EventService_RegisterListener(EVENT_DB_CHECK_TO_DELETE, [$this, 'OnEvent']);
|
||||
$this->oTestCase->EventService_RegisterListener(EVENT_DB_BEFORE_WRITE, [$this, 'OnEvent']);
|
||||
$this->oTestCase->EventService_RegisterListener(EVENT_DB_AFTER_WRITE, [$this, 'OnEvent']);
|
||||
$this->oTestCase->EventService_RegisterListener(EVENT_DB_AFTER_DELETE, [$this, 'OnEvent']);
|
||||
$this->oTestCase->EventService_RegisterListener(EVENT_DB_LINKS_CHANGED, [$this, 'OnEvent']);
|
||||
|
||||
return;
|
||||
}
|
||||
EventService::RegisterListener($sEvent, [$this, 'OnEvent'], $mEventSource);
|
||||
$this->oTestCase->EventService_RegisterListener($sEvent, [$this, 'OnEvent'], $mEventSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $oObject
|
||||
*
|
||||
* @return void
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreCannotSaveObjectException
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \CoreWarning
|
||||
* @throws \MySQLException
|
||||
* @throws \OQLException
|
||||
* @noinspection PhpUnusedPrivateMethodInspection Used as a callback
|
||||
*/
|
||||
private function AddRoleToLink($oObject): void
|
||||
{
|
||||
@@ -646,26 +640,30 @@ class CRUDEventReceiver extends ClassesWithDebug
|
||||
$oObject->Set('role_id', $oContactType->GetKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnusedPrivateMethodInspection Used as a callback
|
||||
*/
|
||||
private function SetPersonFunction($oObject): void
|
||||
{
|
||||
$this->Debug(__METHOD__);
|
||||
$oObject->Set('function', 'CRUD_function_'.rand());
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnusedPrivateMethodInspection Used as a callback
|
||||
*/
|
||||
private function SetPersonFirstName($oObject): void
|
||||
{
|
||||
$this->Debug(__METHOD__);
|
||||
$oObject->Set('first_name', 'CRUD_first_name_'.rand());
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnusedPrivateMethodInspection Used as a callback
|
||||
*/
|
||||
private function CheckCrudStack(DBObject $oObject): void
|
||||
{
|
||||
self::$bIsObjectInCrudStack = DBObject::IsObjectCurrentlyInCrud(get_class($oObject), $oObject->GetKey());
|
||||
}
|
||||
|
||||
private function CheckUpdateInLnk(lnkPersonToTeam $oLnkPersonToTeam)
|
||||
{
|
||||
$iTeamId = $oLnkPersonToTeam->Get('team_id');
|
||||
self::$bIsObjectInCrudStack = DBObject::IsObjectCurrentlyInCrud(Team::class, $iTeamId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Service\Events\EventData;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use CoreException;
|
||||
use DBObject;
|
||||
@@ -36,19 +37,20 @@ use MetaModel;
|
||||
|
||||
/**
|
||||
* @group specificOrgInSampleData
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBObjectTest extends ItopDataTestCase
|
||||
{
|
||||
const CREATE_TEST_ORG = true;
|
||||
|
||||
// Counts
|
||||
public $aReloadCount = [];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->RequireOnceItopFile('core/dbobject.class.php');
|
||||
|
||||
$this->EventService_RegisterListener(EVENT_DB_OBJECT_RELOAD, [$this, 'CountObjectReload']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -897,4 +899,46 @@ class DBObjectTest extends ItopDataTestCase
|
||||
return $oPerson;
|
||||
}
|
||||
|
||||
public function ResetReloadCount()
|
||||
{
|
||||
$this->aReloadCount = [];
|
||||
}
|
||||
|
||||
public function DebugReloadCount($sMsg, $bResetCount = true)
|
||||
{
|
||||
$iTotalCount = 0;
|
||||
$aTotalPerClass = [];
|
||||
foreach ($this->aReloadCount as $sClass => $aCountByKeys) {
|
||||
$iClassCount = 0;
|
||||
foreach ($aCountByKeys as $iCount) {
|
||||
$iClassCount += $iCount;
|
||||
}
|
||||
$iTotalCount += $iClassCount;
|
||||
$aTotalPerClass[$sClass] = $iClassCount;
|
||||
}
|
||||
$this->debug("$sMsg - $iTotalCount reload(s)");
|
||||
foreach ($this->aReloadCount as $sClass => $aCountByKeys) {
|
||||
$this->debug(" $sClass => $aTotalPerClass[$sClass] reload(s)");
|
||||
foreach ($aCountByKeys as $sKey => $iCount) {
|
||||
$this->debug(" $sClass::$sKey => $iCount");
|
||||
}
|
||||
}
|
||||
if ($bResetCount) {
|
||||
$this->ResetReloadCount();
|
||||
}
|
||||
}
|
||||
|
||||
public function CountObjectReload(EventData $oData)
|
||||
{
|
||||
$oObject = $oData->Get('object');
|
||||
$sClass = get_class($oObject);
|
||||
$sKey = $oObject->GetKey();
|
||||
$iCount = $this->GetObjectReloadCount($sClass, $sKey);
|
||||
$this->aReloadCount[$sClass][$sKey] = 1 + $iCount;
|
||||
}
|
||||
|
||||
public function GetObjectReloadCount($sClass, $sKey)
|
||||
{
|
||||
return $this->aReloadCount[$sClass][$sKey] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,6 @@ use DBSearch;
|
||||
* <ul>
|
||||
* <li>MakeGroupByQuery</li>
|
||||
* </ul>
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBSearchCommitTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
@@ -11,10 +11,6 @@ use DBSearch;
|
||||
* Class DBSearchIntersectTest
|
||||
*
|
||||
* @package Combodo\iTop\Test\UnitTest\Core
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBSearchIntersectTest extends ItopTestCase
|
||||
{
|
||||
@@ -71,16 +67,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'",
|
||||
@@ -191,9 +187,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'",
|
||||
|
||||
@@ -11,10 +11,6 @@ use DBSearch;
|
||||
* Class DBSearchIntersectTest
|
||||
*
|
||||
* @package Combodo\iTop\Test\UnitTest\Core
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBSearchJoinTest extends ItopDataTestCase {
|
||||
|
||||
|
||||
@@ -43,10 +43,6 @@ use FunctionExpression;
|
||||
* <ul>
|
||||
* <li>MakeGroupByQuery</li>
|
||||
* </ul>
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBSearchTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
@@ -10,10 +10,6 @@ use DBObjectSearch;
|
||||
* Class DBSearchUpdateRealiasingMapTest
|
||||
*
|
||||
* @package Combodo\iTop\Test\UnitTest\Core
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBSearchUpdateRealiasingMapTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBUnionSearchTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
|
||||
@@ -13,11 +13,6 @@ use FunctionExpression;
|
||||
use MetaModel;
|
||||
use ScalarExpression;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class ExpressionEvaluateTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,10 +20,6 @@ use UserRightsProfile;
|
||||
* @group specificOrgInSampleData
|
||||
* Class GetSelectFilterTest
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*
|
||||
* @package Combodo\iTop\Test\UnitTest\Webservices
|
||||
*/
|
||||
class GetSelectFilterTest extends ItopDataTestCase
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -10,10 +10,6 @@ use MetaModel;
|
||||
/**
|
||||
* Class MetaModelTest
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @package Combodo\iTop\Test\UnitTest\Core
|
||||
*/
|
||||
@@ -220,6 +216,8 @@ class MetaModelTest extends ItopDataTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*
|
||||
* @dataProvider enumPluginsProvider
|
||||
*
|
||||
* @param $expectedResults
|
||||
@@ -267,6 +265,8 @@ class MetaModelTest extends ItopDataTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*
|
||||
* @dataProvider getPluginsProvider
|
||||
*
|
||||
* @param $expectedInstanciationCalls
|
||||
|
||||
@@ -16,11 +16,6 @@ use OQLException;
|
||||
use OqlInterpreter;
|
||||
use OQLParserException;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class OQLParserTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
@@ -21,11 +21,6 @@ use QueryBuilderContext;
|
||||
use SQLObjectQueryBuilder;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class OQLTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
@@ -18,10 +18,6 @@ use TagSetFieldData;
|
||||
|
||||
/**
|
||||
* @group itopFaqLight
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class TagSetFieldDataTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -12,10 +12,6 @@ use Team;
|
||||
/**
|
||||
* Class UniquenessMessageTest
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*
|
||||
* @package Combodo\iTop\Test\UnitTest\Core
|
||||
*/
|
||||
class UniquenessMessageTest extends ItopDataTestCase
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,11 +11,6 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use MetaModel;
|
||||
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class ValueSetObjectsTest extends ItopTestCase
|
||||
{
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -33,8 +33,6 @@ define('UNIT_MAX_CACHE_FILES', 10);
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class apcEmulationTest extends ItopTestCase
|
||||
{
|
||||
|
||||
@@ -32,8 +32,6 @@ use Dict;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class dictApcuTest extends ItopTestCase
|
||||
{
|
||||
|
||||
@@ -30,11 +30,8 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use Dict;
|
||||
use Exception;
|
||||
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
* @runClassInSeparateProcess
|
||||
*/
|
||||
class dictTest extends ItopTestCase
|
||||
{
|
||||
|
||||
@@ -15,10 +15,6 @@ use ormCaseLog;
|
||||
* Tests of the ormCaseLog class
|
||||
*
|
||||
* @covers \ormCaseLog
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class ormCaseLogTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -12,10 +12,6 @@ use utils;
|
||||
|
||||
/**
|
||||
* Tests of the ormStyle class
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class ormStyleTest extends ItopTestCase
|
||||
{
|
||||
|
||||
@@ -38,10 +38,6 @@ define('MAX_TAGS', 12);
|
||||
/**
|
||||
* @group itopFaqLight
|
||||
* Tests of the ormTagSet class
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class ormTagSetTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user