mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°8760 - review tests
This commit is contained in:
@@ -79,7 +79,7 @@ class InstallationChoicesToModuleConverter
|
|||||||
$aInstalledModules[$sModuleName] = true;
|
$aInstalledModules[$sModuleName] = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->ProcessInstallationChoices($aInstallationChoices, $aInstallationDescription, $aInstalledModules);
|
$this->GetModuleNamesFromInstallationChoices($aInstallationChoices, $aInstallationDescription, $aInstalledModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ProcessAutoSelectModules($aPackageModules, $aInstalledModules);
|
$this->ProcessAutoSelectModules($aPackageModules, $aInstalledModules);
|
||||||
@@ -150,19 +150,19 @@ class InstallationChoicesToModuleConverter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function ProcessInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aInstalledModules): void
|
private function GetModuleNamesFromInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aModuleNames): void
|
||||||
{
|
{
|
||||||
foreach ($aInstallationDescription as $aStepInfo) {
|
foreach ($aInstallationDescription as $aStepInfo) {
|
||||||
$aOptions = $aStepInfo['options'] ?? null;
|
$aOptions = $aStepInfo['options'] ?? null;
|
||||||
if (is_array($aOptions)) {
|
if (is_array($aOptions)) {
|
||||||
foreach ($aOptions as $aChoiceInfo) {
|
foreach ($aOptions as $aChoiceInfo) {
|
||||||
$this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aInstalledModules);
|
$this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aModuleNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$aOptions = $aStepInfo['alternatives'] ?? null;
|
$aOptions = $aStepInfo['alternatives'] ?? null;
|
||||||
if (is_array($aOptions)) {
|
if (is_array($aOptions)) {
|
||||||
foreach ($aOptions as $aChoiceInfo) {
|
foreach ($aOptions as $aChoiceInfo) {
|
||||||
$this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aInstalledModules);
|
$this->ProcessSelectedChoice($aInstallationChoices, $aChoiceInfo, $aModuleNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
ModuleDiscovery::ResetCache();
|
ModuleDiscovery::ResetCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//integration test
|
||||||
public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithNonITIL()
|
public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithNonITIL()
|
||||||
{
|
{
|
||||||
$aSearchDirs = $this->GivenModuleDiscoveryInit();
|
$aSearchDirs = $this->GivenModuleDiscoveryInit();
|
||||||
@@ -78,6 +79,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
$this->assertEquals($aExpected, $aInstalledModules);
|
$this->assertEquals($aExpected, $aInstalledModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//integration test
|
||||||
public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithITIL()
|
public function testGetModulesWithXmlInstallationFile_UsualCustomerPackagesWithITIL()
|
||||||
{
|
{
|
||||||
$aSearchDirs = $this->GivenModuleDiscoveryInit();
|
$aSearchDirs = $this->GivenModuleDiscoveryInit();
|
||||||
@@ -134,6 +136,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
$this->assertEquals($aExpected, $aInstalledModules);
|
$this->assertEquals($aExpected, $aInstalledModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//integration test
|
||||||
public function testGetModulesWithXmlInstallationFile_LegacyPackages()
|
public function testGetModulesWithXmlInstallationFile_LegacyPackages()
|
||||||
{
|
{
|
||||||
$aSearchDirs = $this->GivenModuleDiscoveryInit();
|
$aSearchDirs = $this->GivenModuleDiscoveryInit();
|
||||||
@@ -167,35 +170,35 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
$this->assertEquals($aExpected, $aInstalledModules);
|
$this->assertEquals($aExpected, $aInstalledModules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsDefaultModule_RootModule()
|
public function testIsDefaultModule_RootModuleShouldNeverBeDefault()
|
||||||
{
|
{
|
||||||
$sModuleId = ROOT_MODULE;
|
$sModuleId = ROOT_MODULE;
|
||||||
$aModuleInfo = ['category' => 'authentication', 'visible' => false];
|
$aModuleInfo = ['category' => 'authentication', 'visible' => false];
|
||||||
$this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo));
|
$this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsDefaultModule_Autoselect()
|
public function testIsDefaultModule_AutoselectShouldNeverBeDefault()
|
||||||
{
|
{
|
||||||
$sModuleId = 'autoselect_module';
|
$sModuleId = 'autoselect_module';
|
||||||
$aModuleInfo = ['category' => 'authentication', 'visible' => false, 'auto_select' => true];
|
$aModuleInfo = ['category' => 'authentication', 'visible' => false, 'auto_select' => true];
|
||||||
$this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo));
|
$this->assertFalse($this->CallIsDefault($sModuleId, $aModuleInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsDefaultModule_AuthenticationModule()
|
public function testIsDefaultModule_AuthenticationModuleShouldBeDefault()
|
||||||
{
|
{
|
||||||
$sModuleId = 'authentication_module';
|
$sModuleId = 'authentication_module';
|
||||||
$aModuleInfo = ['category' => 'authentication', 'visible' => true];
|
$aModuleInfo = ['category' => 'authentication', 'visible' => true];
|
||||||
$this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo));
|
$this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsDefaultModule_HiddenModule()
|
public function testIsDefaultModule_HiddenModuleShouldBeDefault()
|
||||||
{
|
{
|
||||||
$sModuleId = 'hidden_module';
|
$sModuleId = 'hidden_module';
|
||||||
$aModuleInfo = ['category' => 'business', 'visible' => false];
|
$aModuleInfo = ['category' => 'business', 'visible' => false];
|
||||||
$this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo));
|
$this->assertTrue($this->CallIsDefault($sModuleId, $aModuleInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsDefaultModule_OtherTypeOfModules()
|
public function testIsDefaultModule_NonModuleDefaultCase()
|
||||||
{
|
{
|
||||||
$sModuleId = 'any_module';
|
$sModuleId = 'any_module';
|
||||||
$aModuleInfo = ['category' => 'business', 'visible' => true];
|
$aModuleInfo = ['category' => 'business', 'visible' => true];
|
||||||
@@ -207,34 +210,24 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
return $this->InvokeNonPublicMethod(InstallationChoicesToModuleConverter::class, 'IsDefaultModule', InstallationChoicesToModuleConverter::GetInstance(), [$sModuleId, $aModuleInfo]);
|
return $this->InvokeNonPublicMethod(InstallationChoicesToModuleConverter::class, 'IsDefaultModule', InstallationChoicesToModuleConverter::GetInstance(), [$sModuleId, $aModuleInfo]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsAutoSelectedModule_RootModule()
|
public function testIsAutoSelectedModule_RootModuleShouldNeverBeAutoSelect()
|
||||||
{
|
{
|
||||||
$sModuleId = ROOT_MODULE;
|
$sModuleId = ROOT_MODULE;
|
||||||
$aModuleInfo = ['auto_select' => true];
|
$aModuleInfo = ['auto_select' => true];
|
||||||
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
|
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsAutoSelectedModule_NoAutoselect()
|
public function testIsAutoSelectedModule_NoAutoselectByDefault()
|
||||||
{
|
{
|
||||||
$sModuleId = 'autoselect_module';
|
$sModuleId = 'autoselect_module';
|
||||||
$aModuleInfo = [];
|
$aModuleInfo = [];
|
||||||
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
|
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsAutoSelectedModule_BasicTrue()
|
/**
|
||||||
{
|
* @return void
|
||||||
$sModuleId = "any_module";
|
* cf DependencyExpression dedicated tests
|
||||||
$aModuleInfo = ['auto_select' => true];
|
*/
|
||||||
$this->assertTrue($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIsAutoSelectedModule_BasicFalse()
|
|
||||||
{
|
|
||||||
$sModuleId = "any_module";
|
|
||||||
$aModuleInfo = ['auto_select' => false];
|
|
||||||
$this->assertFalse($this->CallIsAutoSelectedModule([], $sModuleId, $aModuleInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIsAutoSelectedModule_UseInstalledModulesForComputation()
|
public function testIsAutoSelectedModule_UseInstalledModulesForComputation()
|
||||||
{
|
{
|
||||||
$sModuleId = "any_module";
|
$sModuleId = "any_module";
|
||||||
@@ -253,7 +246,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
$aRes = [];
|
$aRes = [];
|
||||||
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
|
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
|
||||||
|
|
||||||
$this->CallProcessInstallationChoices([], $aInstallationDescription, $aRes);
|
$this->CallGetModuleNamesFromInstallationChoices([], $aInstallationDescription, $aRes);
|
||||||
|
|
||||||
$aExpected = [
|
$aExpected = [
|
||||||
'combodo-backoffice-darkmoon-theme' => true,
|
'combodo-backoffice-darkmoon-theme' => true,
|
||||||
@@ -287,7 +280,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
$aRes = [];
|
$aRes = [];
|
||||||
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
|
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
|
||||||
|
|
||||||
$this->CallProcessInstallationChoices($this->GivenNonItilChoices(), $aInstallationDescription, $aRes);
|
$this->CallGetModuleNamesFromInstallationChoices($this->GivenNonItilChoices(), $aInstallationDescription, $aRes);
|
||||||
|
|
||||||
$aExpected = [
|
$aExpected = [
|
||||||
'combodo-backoffice-darkmoon-theme' => true,
|
'combodo-backoffice-darkmoon-theme' => true,
|
||||||
@@ -332,7 +325,7 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
$aRes = [];
|
$aRes = [];
|
||||||
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
|
$aInstallationDescription = $this->GivenInstallationChoiceDescription();
|
||||||
|
|
||||||
$this->CallProcessInstallationChoices($this->GivenItilChoices(), $aInstallationDescription, $aRes);
|
$this->CallGetModuleNamesFromInstallationChoices($this->GivenItilChoices(), $aInstallationDescription, $aRes);
|
||||||
|
|
||||||
$aExpected = [
|
$aExpected = [
|
||||||
'combodo-backoffice-darkmoon-theme' => true,
|
'combodo-backoffice-darkmoon-theme' => true,
|
||||||
@@ -371,13 +364,13 @@ class InstallationChoicesToModuleConverterTest extends ItopDataTestCase
|
|||||||
$this->assertEquals($aExpected, $aRes);
|
$this->assertEquals($aExpected, $aRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function CallProcessInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aInstalledModules)
|
private function CallGetModuleNamesFromInstallationChoices(array $aInstallationChoices, array $aInstallationDescription, array &$aModuleNames)
|
||||||
{
|
{
|
||||||
$this->InvokeNonPublicMethod(
|
$this->InvokeNonPublicMethod(
|
||||||
InstallationChoicesToModuleConverter::class,
|
InstallationChoicesToModuleConverter::class,
|
||||||
'ProcessInstallationChoices',
|
'GetModuleNamesFromInstallationChoices',
|
||||||
InstallationChoicesToModuleConverter::GetInstance(),
|
InstallationChoicesToModuleConverter::GetInstance(),
|
||||||
[$aInstallationChoices, $aInstallationDescription, &$aInstalledModules]
|
[$aInstallationChoices, $aInstallationDescription, &$aModuleNames]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user