mirror of
https://github.com/Combodo/iTop.git
synced 2026-07-12 17:56:38 +02:00
* WIP compileFrom * WIP compileFrom * WIP * Refactor DataFeatureRemovalController to improve setup redirection and add logging for selected extensions and modules * Refactor DataFeatureRemovalController to streamline parameter handling for extension management * Refactor DataFeatureRemovalController and related classes for improved session management and cleanup processes * N°9722 - replace GetMFModulesToCompile API by GetAdditionalMFModulesBeforeFinalDeltaToCompile + fix test * N°9722 - Refacto * N°9722 - remove extensions effectively * N°9722 - After review * N°9722 - After review * N°9722 - Analyze installation before compilation in extension management * ✅ N°9722 - Refactor and unit tests * N°9722 - ✅ * N°9722 - ✅ * N°9722 - cleanup + geptileia PR feedback --------- Co-authored-by: odain <olivier.dain@combodo.com>
70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Combodo\iTop\Test\UnitTest\Setup;
|
|
|
|
use Combodo\iTop\DataFeatureRemoval\Service\DataFeatureRemoverExtensionService;
|
|
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
|
use Config;
|
|
use CoreException;
|
|
use DOMFormatException;
|
|
use Exception;
|
|
use iTopExtensionsMap;
|
|
use RunTimeEnvironment;
|
|
use utils;
|
|
|
|
class RunTimeEnvironmentTest extends ItopTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->RequireOnceItopFile('/setup/runtimeenv.class.inc.php');
|
|
}
|
|
|
|
public function testDoCompileCallCheckExtensionsValidity(): void
|
|
{
|
|
[$sEnvironment, $sExtensionsDirRelative] = $this->CreateFixtureContext('env-missing-label-');
|
|
|
|
$sInvalidExtensionXml = <<<XML
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<extension format="1.0">
|
|
<description>Test extension without code and label</description>
|
|
<version>1.0.0</version>
|
|
<mandatory>false</mandatory>
|
|
<more_info_url/>
|
|
</extension>
|
|
XML;
|
|
$sExtensionsDirAbsolute = APPROOT.$sExtensionsDirRelative;
|
|
file_put_contents($sExtensionsDirAbsolute.'/extension.xml', $sInvalidExtensionXml);
|
|
|
|
$oRuntimeEnvironment = $this->CreateRunTimeEnvironment($sEnvironment);
|
|
$oExtensionMap = $this->createMock(ItopExtensionsMap::class);
|
|
$oExtensionMap->expects($this->once())->method('GetAllExtensions')->willReturn([]);
|
|
|
|
$this->SetNonPublicStaticProperty(iTopExtensionsMap::class, 'aInstancesByEnvironment', [$oRuntimeEnvironment->GetBuildEnv() => $oExtensionMap]);
|
|
|
|
$this->expectException(CoreException::class);
|
|
|
|
$oExtensionMap->expects($this->once())->method('CheckExtensionsValidity')->willThrowException(new CoreException(''));
|
|
$oRuntimeEnvironment->DoCompile([""], [], [], false);
|
|
}
|
|
|
|
private function CreateFixtureContext(string $sEnvPrefix): array
|
|
{
|
|
$sEnvironment = str_replace('.', '-', uniqid($sEnvPrefix, true));
|
|
$sExtensionsDirRelative = 'data/'.$sEnvironment.'-modules';
|
|
|
|
mkdir(APPROOT.$sExtensionsDirRelative, 0777, true);
|
|
$this->aFileToClean[] = APPROOT.$sExtensionsDirRelative;
|
|
|
|
return [$sEnvironment, $sExtensionsDirRelative];
|
|
}
|
|
|
|
private function CreateRunTimeEnvironment(string $sEnvironment): RunTimeEnvironment
|
|
{
|
|
$oRunTimeEnvironment = new RunTimeEnvironment($sEnvironment, false);
|
|
$this->aFileToClean[] = $oRunTimeEnvironment->GetBuildDir();
|
|
|
|
return $oRunTimeEnvironment;
|
|
}
|
|
}
|