mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
Merge remote-tracking branch 'origin/support/2.7' into support/3.0
# Conflicts: # tests/manual-visual-tests/Backoffice/RenderAllUiBlocks.php # tests/php-unit-tests/ItopDataTestCase.php # tests/php-unit-tests/ItopTestCase.php # tests/php-unit-tests/integration-tests/dictionaries-test/fr.dictionary.itop.core.KO.wrong_php # tests/php-unit-tests/integration-tests/dictionaries-test/fr.dictionary.itop.core.OK.php # tests/php-unit-tests/integration-tests/iTopModulesPhpVersionChecklistTest.php # tests/php-unit-tests/integration-tests/iTopXmlVersionChecklistTest.php # tests/php-unit-tests/phpunit.xml.dist # tests/php-unit-tests/unitary-tests/application/SCSSCompilationTest.php # tests/php-unit-tests/unitary-tests/application/Session/SessionTest.php # tests/php-unit-tests/unitary-tests/application/ThemeHandlerTest.php # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/DO_NOT_CHANGE.css-variables.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/DO_NOT_CHANGE.light-grey.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/README.md # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/_included_file3.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/cross_reference1.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/cross_reference2.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/feature1/_feature1.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/included_file1.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/included_scss/included_file2.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/included_scss/included_file4.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/multi_imports.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/shortcut.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/shortcut2.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/simple_import.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/simple_import2.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/typography.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/ui-lightness/DO_NOT_CHANGE.jqueryui.scss # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_1c94c4_256x240.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_222222_256x240.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_E87C1E_256x240.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_F26522_256x240.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_ffd27a_256x240.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_ffffff_256x240.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/ac-background.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/actions_right.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/bg.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/breadcrumb-separator.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/calendar.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/delete.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/desc.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/error.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-closed-555.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-closed-fff.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-open-555.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-open-fff.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/full-screen.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/green-header.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/green-square.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/indicator.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/info-mini.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/minus.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/ok.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/orange-header.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/plus.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/red-header.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/truncated.png # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-collapsable-last.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-collapsable.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-expandable-last.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-expandable.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-item-last.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-item.gif # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main.css # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_imagemodified.css # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_importmodified.css # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_stylesheet.css # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_testcompilethemes.css # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_varchanged.css # tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/theme-parameters.json # tests/php-unit-tests/unitary-tests/application/theme-handler/getimages/expected-getimages.json # tests/php-unit-tests/unitary-tests/application/theme-handler/getimages/test-getimages.scss # tests/php-unit-tests/unitary-tests/core/ActionEmailTest.php # tests/php-unit-tests/unitary-tests/core/AttributeDefTest.inc.php # tests/php-unit-tests/unitary-tests/core/AttributeURLDefaultPattern.php # tests/php-unit-tests/unitary-tests/core/AttributeURLTest.php # tests/php-unit-tests/unitary-tests/core/BulkChangeTest.inc.php # tests/php-unit-tests/unitary-tests/core/CSVParserTest.php # tests/php-unit-tests/unitary-tests/core/DBObjectTest.php # tests/php-unit-tests/unitary-tests/core/DBSearchAddConditionPointingTo.php # tests/php-unit-tests/unitary-tests/core/ExpressionEvaluateTest.php # tests/php-unit-tests/unitary-tests/core/GetSelectFilterTest.php # tests/php-unit-tests/unitary-tests/core/InlineImageTest.php # tests/php-unit-tests/unitary-tests/core/Log/ExceptionLogTest.php # tests/php-unit-tests/unitary-tests/core/Log/ExceptionLogTest/Exceptions.php # tests/php-unit-tests/unitary-tests/core/Log/LogAPITest.php # tests/php-unit-tests/unitary-tests/core/Log/LogFileNameBuilderTest.php # tests/php-unit-tests/unitary-tests/core/LogAPITest.php # tests/php-unit-tests/unitary-tests/core/LogFileNameBuilderTest.php # tests/php-unit-tests/unitary-tests/core/MetaModelTest.php # tests/php-unit-tests/unitary-tests/core/OQLTest.php # tests/php-unit-tests/unitary-tests/core/UniquenessConstraintTest.php # tests/php-unit-tests/unitary-tests/core/XMLDataLoaderTest.php # tests/php-unit-tests/unitary-tests/core/dictApcuTest.php # tests/php-unit-tests/unitary-tests/core/dictTest.php # tests/php-unit-tests/unitary-tests/core/ormCaseLogTest.php # tests/php-unit-tests/unitary-tests/core/ormPasswordTest.php # tests/php-unit-tests/unitary-tests/core/ormStyleTest.php # tests/php-unit-tests/unitary-tests/setup/MFCompilerTest.php # tests/php-unit-tests/unitary-tests/setup/SubMFCompiler.php # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/1.7_to_1.6.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/1.7_to_1.6.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.6_to_1.7_2.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.6_to_1.7_2.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6_2.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6_2.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_3.0.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_3.0.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.0_to_1.7.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.0_to_1.7.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/Bug_4569.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/Bug_4569.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_deleted.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_deleted.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_in-definition.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_in-definition.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_not-in-definition.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_not-in-definition.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_deleted.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_deleted.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_in-definition.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_in-definition.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_not-in-definition.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_not-in-definition.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_deleted.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_deleted.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_in-definition.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_in-definition.input.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_not-in-definition.expected.xml # tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_not-in-definition.input.xml # tests/php-unit-tests/unitary-tests/setup/ressources/datamodels/datamodel-branding.xml # tests/php-unit-tests/unitary-tests/sources/application/Helper/WebResourcesHelperTest.php # tests/php-unit-tests/unitary-tests/sources/application/status/StatusIncTest.php # tests/php-unit-tests/unitary-tests/sources/application/status/status.php # tests/php-unit-tests/unitary-tests/synchro/DataSynchroTest.php
This commit is contained in:
195
tests/php-unit-tests/unitary-tests/setup/MFCompilerTest.php
Normal file
195
tests/php-unit-tests/unitary-tests/setup/MFCompilerTest.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
* @covers \MFCompiler::UseLatestPrecompiledFile
|
||||
*/
|
||||
class MFCompilerTest extends ItopTestCase {
|
||||
/** @var array */
|
||||
private static $aFoldersToCleanup;
|
||||
|
||||
/** @var array */
|
||||
private static $aRessources;
|
||||
|
||||
/** @var \MFCompiler */
|
||||
private $oMFCompiler;
|
||||
|
||||
private $sTmpDir;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->RequireOnceItopFile('setup/compiler.class.inc.php');
|
||||
$this->RequireOnceItopFile('setup/modelfactory.class.inc.php');
|
||||
$this->RequireOnceUnitTestFile('./SubMFCompiler.php');
|
||||
|
||||
$this->sTmpDir = $this->CreateTmpdir();
|
||||
$this->oMFCompiler = new SubMFCompiler($this->createMock(\ModelFactory::class), '');
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
parent::tearDown();
|
||||
$this->RecurseRmdir($this->sTmpDir);
|
||||
}
|
||||
|
||||
public static function Init(){
|
||||
if (!is_null(self::$aFoldersToCleanup)){
|
||||
return;
|
||||
}
|
||||
clearstatcache();
|
||||
$sPrefix = 'scsstest_';
|
||||
$sAppRootForProvider = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR;
|
||||
$sTempTargetDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'UseLatestPrecompiledFileProvider';
|
||||
$sExtensionTargetDir = $sAppRootForProvider . 'extensions/UseLatestPrecompiledFileProvider';
|
||||
$sSourceDir = $sAppRootForProvider . 'datamodels' . DIRECTORY_SEPARATOR . '2.x';
|
||||
$sDatamodel2xTargetDir = $sSourceDir . DIRECTORY_SEPARATOR . '/UseLatestPrecompiledFileProvider';
|
||||
|
||||
mkdir($sTempTargetDir);
|
||||
mkdir($sExtensionTargetDir);
|
||||
mkdir($sDatamodel2xTargetDir);
|
||||
|
||||
self::$aFoldersToCleanup = [ $sTempTargetDir, $sExtensionTargetDir, $sDatamodel2xTargetDir ];
|
||||
|
||||
self::$aRessources['sPostCompilation1'] = tempnam($sTempTargetDir, $sPrefix);
|
||||
sleep(1);
|
||||
|
||||
//datamodel XML file in extension folder
|
||||
self::$aRessources['sPrecompiledInExtensionFile1'] = tempnam($sExtensionTargetDir, $sPrefix);
|
||||
self::$aRessources['sPrecompiledInExtensionFileUri1'] = "UseLatestPrecompiledFileProvider" . DIRECTORY_SEPARATOR . basename(self::$aRessources['sPrecompiledInExtensionFile1']);
|
||||
|
||||
//datamodel XML file in source dir /datamodels/2.x folder
|
||||
self::$aRessources['sPrecompiledInDataModelXXFile1'] = tempnam($sDatamodel2xTargetDir, $sPrefix);
|
||||
self::$aRessources['sPrecompiledInDataModelXXFileUri1'] = "UseLatestPrecompiledFileProvider" . DIRECTORY_SEPARATOR . basename(self::$aRessources['sPrecompiledInDataModelXXFile1']);
|
||||
|
||||
sleep(1);
|
||||
|
||||
|
||||
//generate ressources from a previous setup: called postcompiled
|
||||
self::$aRessources['sPostCompilation2'] = tempnam($sTempTargetDir, $sPrefix);
|
||||
sleep(1);
|
||||
|
||||
//simulate copy of /data/models.2.x or extensions ressources during setup in a temp directory
|
||||
self::$aRessources['sCopiedExtensionFile1'] = $sTempTargetDir . DIRECTORY_SEPARATOR . basename(self::$aRessources['sPrecompiledInExtensionFile1']);
|
||||
copy(self::$aRessources['sPrecompiledInExtensionFile1'], self::$aRessources['sCopiedExtensionFile1']);
|
||||
|
||||
self::$aRessources['sCopiedDataModelXXFile1'] = $sTempTargetDir . DIRECTORY_SEPARATOR . basename(self::$aRessources['sPrecompiledInDataModelXXFile1']);
|
||||
copy(self::$aRessources['sPrecompiledInDataModelXXFile1'], self::$aRessources['sCopiedDataModelXXFile1']);
|
||||
|
||||
self::$aRessources['sMissingFile'] = tempnam($sTempTargetDir, $sPrefix);
|
||||
unlink(self::$aRessources['sMissingFile']);
|
||||
|
||||
/*foreach (self::$aRessources as $sKey => $sRessource){
|
||||
if (is_file($sRessource)) {
|
||||
var_dump("$sKey $sRessource:" . filemtime($sRessource));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
if (is_null(self::$aFoldersToCleanup)){
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (self::$aFoldersToCleanup as $sFolder){
|
||||
if (is_dir($sFolder)){
|
||||
foreach (glob("$sFolder/**") as $sFile){
|
||||
unlink($sFile);
|
||||
}
|
||||
rmdir($sFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider UseLatestPrecompiledFileProvider
|
||||
*
|
||||
* @param string $sTempTargetDir
|
||||
* @param string $sPrecompiledFileUri
|
||||
* @param string $sPostCompilationLatestPrecompiledFile
|
||||
* @param string $sThemeDir
|
||||
* @param ?string $sExpectedReturn
|
||||
*/
|
||||
public function testUseLatestPrecompiledFile(string $sTempTargetDir, string $sPrecompiledFileUri, string $sPostCompilationLatestPrecompiledFile, string $sThemeDir, ?string $sExpectedReturn, bool $bDisableThemePrecompilationViaConf = false){
|
||||
if ($bDisableThemePrecompilationViaConf){
|
||||
utils::GetConfig()->Set('theme.enable_precompilation', false);
|
||||
}
|
||||
$sRes = $this->oMFCompiler->UseLatestPrecompiledFile($sTempTargetDir, $sPrecompiledFileUri, $sPostCompilationLatestPrecompiledFile, $sThemeDir);
|
||||
$this->assertEquals($sExpectedReturn, $sRes);
|
||||
}
|
||||
|
||||
public function UseLatestPrecompiledFileProvider(){
|
||||
self::init();
|
||||
return [
|
||||
'no precompiled file at all' => $this->BuildProviderUseCaseArray('', self::$aRessources['sMissingFile'], null),
|
||||
'deactivate precompilation via conf' => $this->BuildProviderUseCaseArray('', self::$aRessources['sPostCompilation1'], null, true),
|
||||
'no precompiled file configured in precompiled_stylesheet XM section' => $this->BuildProviderUseCaseArray('', self::$aRessources['sPostCompilation1'], self::$aRessources['sPostCompilation1']),
|
||||
'missing precompiled file in precompiled_stylesheet section' => $this->BuildProviderUseCaseArray(self::$aRessources['sMissingFile'], self::$aRessources['sPostCompilation1'], self::$aRessources['sPostCompilation1'] ),
|
||||
'no precompiled file generated in previous setup in /data/precompiled_styles' => $this->BuildProviderUseCaseArray(self::$aRessources['sPrecompiledInExtensionFileUri1'], self::$aRessources['sMissingFile'], self::$aRessources['sCopiedExtensionFile1'] ),
|
||||
'(extensions) XML precompiled_stylesheet file older than last post setup generated file in /data/precompiled_styles' => $this->BuildProviderUseCaseArray(self::$aRessources['sPrecompiledInExtensionFileUri1'], self::$aRessources['sPostCompilation2'], self::$aRessources['sPostCompilation2'] ),
|
||||
'last post setup generated file in /data/precompiled_styles older than (extensions) XML precompiled_stylesheet file' => $this->BuildProviderUseCaseArray(self::$aRessources['sPrecompiledInExtensionFileUri1'], self::$aRessources['sPostCompilation1'], self::$aRessources['sCopiedExtensionFile1'] ),
|
||||
'(datamodels/N.x) XML precompiled_stylesheet file older than last post setup generated file in /data/precompiled_styles' => $this->BuildProviderUseCaseArray(self::$aRessources['sPrecompiledInDataModelXXFileUri1'], self::$aRessources['sPostCompilation2'], self::$aRessources['sPostCompilation2'] ),
|
||||
'(datamodels/N.x) last post setup generated file in /data/precompiled_styles older than (extensions) XML precompiled_stylesheet file' => $this->BuildProviderUseCaseArray(self::$aRessources['sPrecompiledInDataModelXXFileUri1'], self::$aRessources['sPostCompilation1'], self::$aRessources['sCopiedDataModelXXFile1'] ),
|
||||
];
|
||||
}
|
||||
|
||||
private function BuildProviderUseCaseArray(string $sPrecompiledFileUri, string $sPostCompilationLatestPrecompiledFile, $sExpectedReturn, $bDisableThemePrecompilationViaConf = false) : array{
|
||||
return [
|
||||
"sTempTargetDir" => sys_get_temp_dir(),
|
||||
"sPrecompiledFileUri" => $sPrecompiledFileUri,
|
||||
"sPostCompilationLatestPrecompiledFile" => $sPostCompilationLatestPrecompiledFile,
|
||||
"sThemeDir" => "test",
|
||||
"sExpectedReturn" => $sExpectedReturn,
|
||||
"bDisableThemePrecompilationViaConf" => $bDisableThemePrecompilationViaConf
|
||||
];
|
||||
}
|
||||
|
||||
public function testCompileThemes(){
|
||||
$sFullmoonThemeCompiledFolder = $this->sTmpDir.DIRECTORY_SEPARATOR.'branding'.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.'fullmoon'.DIRECTORY_SEPARATOR;
|
||||
|
||||
$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($sFullmoonThemeCompiledFolder);
|
||||
file_put_contents($sFullmoonThemeCompiledFolder.'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"',
|
||||
],
|
||||
'variable_imports' => ['ok-because-xsi-type-variables' => 'ok-because-xsi-type-variables.scss'],
|
||||
'utility_imports' => ['ok-because-xsi-type-utilities' => 'ok-because-xsi-type-utilities.scss'],
|
||||
'stylesheets' => [
|
||||
"fullmoon" => '../css/backoffice/main.scss',
|
||||
"environment-banner" => '../css/backoffice/themes/page-banner.scss',
|
||||
"datamodel-compiled-scss-rules" => 'branding/themes/datamodel-compiled-scss-rules.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->InvokeNonPublicMethod(MFCompiler::class, 'CompileThemes', $this->oMFCompiler, [$oBrandingNode, $this->sTmpDir]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user