N°2982 - fix delta xml variables not used in themes

This commit is contained in:
odain
2021-04-12 22:14:00 +02:00
parent c0f5906dce
commit 903afff687
10 changed files with 235 additions and 71 deletions

View File

@@ -18,12 +18,21 @@ class MFCompilerTest extends ItopTestCase {
/** @var \MFCompiler */
private $oMFCompiler;
public function setUp()
{
private $sTmpDir;
public function setUp() {
parent::setUp();
require_once(APPROOT.'setup/compiler.class.inc.php');
require_once(APPROOT.'setup/modelfactory.class.inc.php');
require_once(__DIR__.'/SubMFCompiler.php');
$this->oMFCompiler = new MFCompiler($this->createMock(\ModelFactory::class), '');
$this->sTmpDir = $this->CreateTmpdir();
$this->oMFCompiler = new SubMFCompiler($this->createMock(\ModelFactory::class), '');
}
public function tearDown() {
parent::tearDown();
$this->RecurseRmdir($this->sTmpDir);
}
public static function Init(){
@@ -133,5 +142,46 @@ class MFCompilerTest extends ItopTestCase {
];
}
public function testCompileThemes(){
$sXmlDataCustoFilePath = realpath(__DIR__ . '/ressources/datamodels/datamodel-branding.xml');
$oDom = new MFDocument();
$oDom->load($sXmlDataCustoFilePath);
/** @var \MFElement $oBrandingNode */
$oBrandingNode = $oDom->GetNodes('branding')->item(0);
$this->RecurseMkdir($this->sTmpDir.'/branding/themes/fullmoon/');
file_put_contents($this->sTmpDir.'/branding/themes/fullmoon/main.css', "");
$aImportsPaths = array(
APPROOT.'css/',
APPROOT.'css/backoffice/main.scss',
$this->sTmpDir.'//',
);
$aThemeParameters = [
'variables' => [
'ibo-page-banner--background-color' => '$ibo-color-red-600',
'ibo-page-banner--text-color' => '$ibo-color-red-100',
'ibo-page-banner--text-content' => '"THIS IS A TEST INSTANCE"',
],
'imports_variable' => [ 'style2' => 'style2.scss'],
'imports_utility' => [ 'style1' => 'style1.scss', 'style3' => 'style3.scss'],
'stylesheets' => [
"fullmoon" => '../css/backoffice/main.scss',
"environment-banner" => '../css/backoffice/themes/page-banner.scss'
],
];
$oThemeHandlerService = $this->createMock(\ThemeHandlerService::class);
$oThemeHandlerService->expects($this->exactly(1))
->method("CompileTheme")
->with("fullmoon", true, $this->oMFCompiler->GetCompilationTimeStamp(), $aThemeParameters, $aImportsPaths, $this->sTmpDir . '/');
//CompileTheme($sThemeId, $bSetup = false, $sSetupCompilationTimestamp="", $aThemeParameters = null, $aImportsPaths = null, $sWorkingPath = null)
MFCompiler::setThemeHandlerService($oThemeHandlerService);
$this->oMFCompiler->CompileThemes($oBrandingNode, $this->sTmpDir);
}
}