diff --git a/.make/build/afterBuild.php b/.make/build/afterBuild.php index e1ab17a1f..15071f2fd 100644 --- a/.make/build/afterBuild.php +++ b/.make/build/afterBuild.php @@ -4,7 +4,7 @@ $iBeginTime = time(); chdir(__DIR__); $aCommands = [ - 'php composer/rmDeniedTestDir.php', + 'php composer/rmUnnecessaryFolders.php', 'php build/commands/setupCssCompiler.php', // 'bash /tmp/gabuzomeu.sh', ]; diff --git a/.make/composer/listOutdated.php b/.make/dependencies/composer/listOutdated.php similarity index 98% rename from .make/composer/listOutdated.php rename to .make/dependencies/composer/listOutdated.php index 5c59a022f..79900528e 100644 --- a/.make/composer/listOutdated.php +++ b/.make/dependencies/composer/listOutdated.php @@ -26,7 +26,7 @@ * @link https://getcomposer.org/doc/03-cli.md#show */ -$iTopFolder = __DIR__."/../../"; +$iTopFolder = __DIR__."/../../../"; require_once("$iTopFolder/approot.inc.php"); $sApproot = APPROOT; diff --git a/.make/composer/tcpdf/droidsansfallback.ctg.z b/.make/dependencies/composer/tcpdf/droidsansfallback.ctg.z similarity index 100% rename from .make/composer/tcpdf/droidsansfallback.ctg.z rename to .make/dependencies/composer/tcpdf/droidsansfallback.ctg.z diff --git a/.make/composer/tcpdf/droidsansfallback.php b/.make/dependencies/composer/tcpdf/droidsansfallback.php similarity index 100% rename from .make/composer/tcpdf/droidsansfallback.php rename to .make/dependencies/composer/tcpdf/droidsansfallback.php diff --git a/.make/composer/tcpdf/droidsansfallback.z b/.make/dependencies/composer/tcpdf/droidsansfallback.z similarity index 100% rename from .make/composer/tcpdf/droidsansfallback.z rename to .make/dependencies/composer/tcpdf/droidsansfallback.z diff --git a/.make/composer/tcpdf/tcpdfDefaultFontsToKeepInItop.txt b/.make/dependencies/composer/tcpdf/tcpdfDefaultFontsToKeepInItop.txt similarity index 100% rename from .make/composer/tcpdf/tcpdfDefaultFontsToKeepInItop.txt rename to .make/dependencies/composer/tcpdf/tcpdfDefaultFontsToKeepInItop.txt diff --git a/.make/composer/tcpdf/tcpdfUpdateFonts.php b/.make/dependencies/composer/tcpdf/tcpdfUpdateFonts.php similarity index 98% rename from .make/composer/tcpdf/tcpdfUpdateFonts.php rename to .make/dependencies/composer/tcpdf/tcpdfUpdateFonts.php index f160eb462..668d9e793 100644 --- a/.make/composer/tcpdf/tcpdfUpdateFonts.php +++ b/.make/dependencies/composer/tcpdf/tcpdfUpdateFonts.php @@ -13,7 +13,7 @@ * @link https://github.com/tecnickcom/TCPDF?tab=readme-ov-file#note TCPDF is in support only mode */ -$sItopRootFolder = realpath(__DIR__ . "/../../../"); +$sItopRootFolder = realpath(__DIR__ . "/../../../../"); $sCurrentScriptFileName = basename(__FILE__); diff --git a/.make/composer/rmDeniedTestDir.php b/.make/dependencies/rmUnnecessaryFolders.php similarity index 60% rename from .make/composer/rmDeniedTestDir.php rename to .make/dependencies/rmUnnecessaryFolders.php index 4d57bfd73..b223c8ab4 100644 --- a/.make/composer/rmDeniedTestDir.php +++ b/.make/dependencies/rmUnnecessaryFolders.php @@ -19,8 +19,6 @@ * */ -use Combodo\iTop\Composer\iTopComposer; - $iTopFolder = __DIR__ . "/../../" ; require_once ("$iTopFolder/approot.inc.php"); @@ -33,13 +31,34 @@ if (php_sapi_name() !== 'cli') clearstatcache(); -$oiTopComposer = new iTopComposer(); -$aDeniedButStillPresent = $oiTopComposer->ListDeniedButStillPresent(); +// Read params +$key = array_search("--manager", $argv); +if (false === $key || false === isset($argv[$key + 1]) ) { + throw new \Exception("Usage: " . __FILE__ . " --manager composer|npm"); +} +$sDependenciesHandlerCode = $argv[$key + 1]; + +switch ($sDependenciesHandlerCode) { + case "composer": + $sDependenciesHandlerFQCN = \Combodo\iTop\Dependencies\Composer\iTopComposer::class; + break; + + case "npm": + $sDependenciesHandlerFQCN = \Combodo\iTop\Dependencies\NPM\iTopNPM::class; + break; + + default: + throw new \Exception("Invalid dependencies handler code, $sDependenciesHandlerCode given, expected composer|npm"); +} + +// Start handler +$oDependenciesHandler = new $sDependenciesHandlerFQCN(); +$aDeniedButStillPresent = $oDependenciesHandler->ListDeniedButStillPresent(); echo "\n"; foreach ($aDeniedButStillPresent as $sDir) { - if (false === iTopComposer::IsTestDir($sDir)) + if (false === $oDependenciesHandler::IsQuestionnableFolder($sDir)) { echo "ERROR found INVALID denied test dir: '$sDir'\n"; throw new \Exception("$sDir must end with /Test/ or /test/"); @@ -61,13 +80,13 @@ foreach ($aDeniedButStillPresent as $sDir) $aAllowedAndDeniedDirs = array_merge( - $oiTopComposer->ListAllowedTestDir(), - $oiTopComposer->ListDeniedTestDir() + $oDependenciesHandler->ListAllowedQuestionnableFoldersAbsPaths(), + $oDependenciesHandler->ListDeniedQuestionnableFolderAbsPaths() ); -$aExistingDirs = $oiTopComposer->ListAllTestDir(); +$aExistingDirs = $oDependenciesHandler->ListAllQuestionnableFoldersAbsPaths(); $aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs); if (false === empty($aMissing)) { echo "Some new tests dirs exists !\n" - .' They must be declared either in the allowed or denied list in '.iTopComposer::class." (see N°2651).\n" - .' List of dirs:'."\n".var_export($aMissing, true); + .' They must be declared either in the allowed or denied list in '.$sDependenciesHandlerFQCN." (see N°2651).\n" + .' List of dirs:'."\n".var_export($aMissing, true)."\n"; } \ No newline at end of file diff --git a/composer.json b/composer.json index d4456f324..851caa361 100644 --- a/composer.json +++ b/composer.json @@ -97,9 +97,9 @@ } }, "scripts": { - "post-install-cmd": ["@rmDeniedTestDir", "@tcpdfCustomFonts"], - "post-update-cmd": ["@rmDeniedTestDir", "@tcpdfCustomFonts"], - "rmDeniedTestDir": "@php .make/composer/rmDeniedTestDir.php", - "tcpdfCustomFonts": "@php .make/composer/tcpdf/tcpdfUpdateFonts.php" + "post-install-cmd": ["@rmUnnecessaryFolders", "@tcpdfCustomFonts"], + "post-update-cmd": ["@rmUnnecessaryFolders", "@tcpdfCustomFonts"], + "rmUnnecessaryFolders": "@php .make/dependencies/rmUnnecessaryFolders.php --manager composer", + "tcpdfCustomFonts": "@php .make/dependencies/composer/tcpdf/tcpdfUpdateFonts.php" } } diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 75334c1ce..b1e6f62f6 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -388,7 +388,6 @@ return array( 'Combodo\\iTop\\Application\\WebPage\\iTopPDF' => $baseDir . '/sources/Application/WebPage/iTopPDF.php', 'Combodo\\iTop\\Application\\WebPage\\iTopWebPage' => $baseDir . '/sources/Application/WebPage/iTopWebPage.php', 'Combodo\\iTop\\Application\\WebPage\\iTopWizardWebPage' => $baseDir . '/sources/Application/WebPage/iTopWizardWebPage.php', - 'Combodo\\iTop\\Composer\\iTopComposer' => $baseDir . '/sources/Composer/iTopComposer.php', 'Combodo\\iTop\\Controller\\AbstractAppController' => $baseDir . '/sources/Controller/AbstractAppController.php', 'Combodo\\iTop\\Controller\\AbstractController' => $baseDir . '/sources/Controller/AbstractController.php', 'Combodo\\iTop\\Controller\\AjaxRenderController' => $baseDir . '/sources/Controller/AjaxRenderController.php', @@ -418,6 +417,8 @@ return array( 'Combodo\\iTop\\Core\\MetaModel\\FriendlyNameType' => $baseDir . '/sources/Core/MetaModel/FriendlyNameType.php', 'Combodo\\iTop\\Core\\MetaModel\\HierarchicalKey' => $baseDir . '/sources/Core/MetaModel/HierarchicalKey.php', 'Combodo\\iTop\\Core\\Trigger\\Enum\\SubscriptionPolicy' => $baseDir . '/sources/Core/Trigger/Enum/SubscriptionPolicy.php', + 'Combodo\\iTop\\Dependencies\\AbstractHook' => $baseDir . '/sources/Dependencies/AbstractHook.php', + 'Combodo\\iTop\\Dependencies\\Composer\\iTopComposer' => $baseDir . '/sources/Dependencies/Composer/iTopComposer.php', 'Combodo\\iTop\\DesignDocument' => $baseDir . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\DesignElement' => $baseDir . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\Form\\Field\\AbstractSimpleField' => $baseDir . '/sources/Form/Field/AbstractSimpleField.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index 6c8d92a98..5422a3f3f 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -763,7 +763,6 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f 'Combodo\\iTop\\Application\\WebPage\\iTopPDF' => __DIR__ . '/../..' . '/sources/Application/WebPage/iTopPDF.php', 'Combodo\\iTop\\Application\\WebPage\\iTopWebPage' => __DIR__ . '/../..' . '/sources/Application/WebPage/iTopWebPage.php', 'Combodo\\iTop\\Application\\WebPage\\iTopWizardWebPage' => __DIR__ . '/../..' . '/sources/Application/WebPage/iTopWizardWebPage.php', - 'Combodo\\iTop\\Composer\\iTopComposer' => __DIR__ . '/../..' . '/sources/Composer/iTopComposer.php', 'Combodo\\iTop\\Controller\\AbstractAppController' => __DIR__ . '/../..' . '/sources/Controller/AbstractAppController.php', 'Combodo\\iTop\\Controller\\AbstractController' => __DIR__ . '/../..' . '/sources/Controller/AbstractController.php', 'Combodo\\iTop\\Controller\\AjaxRenderController' => __DIR__ . '/../..' . '/sources/Controller/AjaxRenderController.php', @@ -793,6 +792,8 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f 'Combodo\\iTop\\Core\\MetaModel\\FriendlyNameType' => __DIR__ . '/../..' . '/sources/Core/MetaModel/FriendlyNameType.php', 'Combodo\\iTop\\Core\\MetaModel\\HierarchicalKey' => __DIR__ . '/../..' . '/sources/Core/MetaModel/HierarchicalKey.php', 'Combodo\\iTop\\Core\\Trigger\\Enum\\SubscriptionPolicy' => __DIR__ . '/../..' . '/sources/Core/Trigger/Enum/SubscriptionPolicy.php', + 'Combodo\\iTop\\Dependencies\\AbstractHook' => __DIR__ . '/../..' . '/sources/Dependencies/AbstractHook.php', + 'Combodo\\iTop\\Dependencies\\Composer\\iTopComposer' => __DIR__ . '/../..' . '/sources/Dependencies/Composer/iTopComposer.php', 'Combodo\\iTop\\DesignDocument' => __DIR__ . '/../..' . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\DesignElement' => __DIR__ . '/../..' . '/core/designdocument.class.inc.php', 'Combodo\\iTop\\Form\\Field\\AbstractSimpleField' => __DIR__ . '/../..' . '/sources/Form/Field/AbstractSimpleField.php', diff --git a/lib/composer/installed.php b/lib/composer/installed.php index 675b1d875..54fa11a53 100644 --- a/lib/composer/installed.php +++ b/lib/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'combodo/itop', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'dddcb213d11aa68097d1ec9334401cea632ec944', + 'reference' => '0c3e839381fb70ad7856576de4fc1da17278dfa2', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -22,7 +22,7 @@ 'combodo/itop' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'dddcb213d11aa68097d1ec9334401cea632ec944', + 'reference' => '0c3e839381fb70ad7856576de4fc1da17278dfa2', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/sources/Composer/iTopComposer.php b/sources/Composer/iTopComposer.php deleted file mode 100644 index 81cc70541..000000000 --- a/sources/Composer/iTopComposer.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - */ - -namespace Combodo\iTop\Composer; - -use FilesystemIterator; -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; - -class iTopComposer -{ - /** - * Parenthesis around alternation as it is eager (see linked ref), and we really want to use start / end of string - * `^test|examples$i` would match Tester for example - * `^(test|examples)$i` is not ! - * - * @since 3.2.0 N°7175 update regexp to also remove `examples` dir - * @link https://www.regular-expressions.info/alternation.html RegExp alternation reference - */ - public const TEST_DIR_REGEXP = '/^(tests?|examples)$/i'; - - /** - * @return array List of all subdirs of /lib that are {@see IsTestDir}. - * Warning : each path contains slashes (meaning on Windows you'll get eg `C:/Dev/wamp64/www/itop-27/lib/goaop/framework/tests`) - */ - public function ListAllTestDir() - { - $aAllTestDirs = array(); - $sPath = realpath(APPROOT.'lib'); - - $oDirectoryIterator = new RecursiveDirectoryIterator($sPath, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO|FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS); - $iterator = new RecursiveIteratorIterator( - $oDirectoryIterator, - RecursiveIteratorIterator::CHILD_FIRST); - - /** @var DirectoryIterator $file */ - foreach($iterator as $file) { - if(!$file->isDir()) { - continue; - } - $sDirName = $file->getFilename(); - if (!$this->IsTestDir($sDirName)) - { - continue; - } - - $sTestPathDir = $file->getRealpath(); - $sTestPathDir = str_replace('\\', '/', $sTestPathDir); - $aAllTestDirs[] = $sTestPathDir; - } - - return $aAllTestDirs; - } - - /** - * @param $sDirName - * - * @return false|int as {@see \preg_match()} - * @uses self::TEST_DIR_REGEXP - * @uses \preg_match() - */ - public static function IsTestDir($sDirName) - { - return preg_match(static::TEST_DIR_REGEXP, $sDirName); - } - - /** - * @return string APPROOT constant but with slashes instead of DIRECTORY_SEPARATOR. - * This ease writing our paths, as we can use '/' for every platforms. - */ - private function GetApprootWithSlashes() - { - return str_replace(DIRECTORY_SEPARATOR, '/', APPROOT); - } - - public function ListAllowedTestDir() - { - $APPROOT_WITH_SLASHES = $this->GetApprootWithSlashes(); - return array( - $APPROOT_WITH_SLASHES.'lib/twig/twig/src/Node/Expression/Test', - $APPROOT_WITH_SLASHES.'lib/twig/twig/lib/Twig/Node/Expression/Test', - ); - } - - public function ListDeniedTestDir() - { - $APPROOT_WITH_SLASHES = $this->GetApprootWithSlashes(); - return array( - $APPROOT_WITH_SLASHES.'lib/doctrine/lexer/tests', - - $APPROOT_WITH_SLASHES.'lib/goaop/framework/tests', - - $APPROOT_WITH_SLASHES.'lib/laminas/laminas-servicemanager/src/Test', - - $APPROOT_WITH_SLASHES.'lib/nikic/php-parser/test', - - $APPROOT_WITH_SLASHES.'lib/pear/archive_tar/tests', - $APPROOT_WITH_SLASHES.'lib/pear/console_getopt/tests', - $APPROOT_WITH_SLASHES.'lib/pear/pear_exception/tests', - - $APPROOT_WITH_SLASHES.'lib/psr/log/Psr/Log/Test', - - $APPROOT_WITH_SLASHES.'lib/symfony/cache/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/cache/Tests/DoctrineProviderTest.php', - $APPROOT_WITH_SLASHES.'lib/symfony/class-loader/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/config/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/console/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/css-selector/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/debug/Resources/ext/tests', - $APPROOT_WITH_SLASHES.'lib/symfony/debug/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/dependency-injection/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/dotenv/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/event-dispatcher/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/filesystem/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/finder/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/http-client-contracts/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/http-foundation/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/http-kernel/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/service-contracts/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/framework-bundle/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/mime/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/routing/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/stopwatch/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/translation-contracts/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/twig-bridge/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/twig-bundle/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/var-dumper/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/var-dumper/Tests/Test', - $APPROOT_WITH_SLASHES.'lib/symfony/var-dumper/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/web-profiler-bundle/Tests', - $APPROOT_WITH_SLASHES.'lib/symfony/yaml/Tests', - - $APPROOT_WITH_SLASHES.'lib/tecnickcom/tcpdf/examples', - - $APPROOT_WITH_SLASHES.'lib/thenetworg/oauth2-azure/tests', - - $APPROOT_WITH_SLASHES.'lib/twig/twig/src/Test', - $APPROOT_WITH_SLASHES.'lib/twig/twig/lib/Twig/Test', - $APPROOT_WITH_SLASHES.'lib/twig/twig/doc/tests', - - $APPROOT_WITH_SLASHES.'lib/laminas/laminas-servicemanager/src/Test', - ); - } - - public function ListDeniedButStillPresent() - { - $aDeniedTestDir = $this->ListDeniedTestDir(); - $aAllTestDir = $this->ListAllTestDir(); - return array_intersect($aDeniedTestDir, $aAllTestDir); - } -} \ No newline at end of file diff --git a/sources/Dependencies/AbstractHook.php b/sources/Dependencies/AbstractHook.php new file mode 100644 index 000000000..c8450d62f --- /dev/null +++ b/sources/Dependencies/AbstractHook.php @@ -0,0 +1,114 @@ + + * @package Combodo\iTop\Dependencies + */ +abstract class AbstractHook +{ + /** + * Questionnable folder is a folder name that seems like it doesn't need to be package as it only contain + * unnecessary files (e.g. lib test or example files) + * + * Parenthesis around alternation as it is eager (see linked ref), and we really want to use start / end of string + * `^test|examples$i` would match Tester for example + * `^(test|examples)$i` is not ! + * + * @since 3.2.0 N°7175 update regexp to also remove `examples` folder + * @link https://www.regular-expressions.info/alternation.html RegExp alternation reference + */ + public const QUESTIONNABLE_FOLDER_REGEXP = '/^(tests?|examples|htdocs?|demos?|external)$/i'; + + /** + * @return string Absolute path to the root folder of the dependencies (composer, npm, ...) + */ + abstract protected function GetDependenciesRootFolderAbsPath(): string; + + /** + * @return array List of all subdirs of the dependencies folder that are {@see IsQuestionnableFolder}. + * Warning : each path contains slashes (meaning on Windows you'll get eg `C:/Dev/wamp64/www/itop-27/lib/goaop/framework/tests`) + */ + public function ListAllQuestionnableFoldersAbsPaths(): array + { + $aAllTestDirs = array(); + $sPath = realpath($this->GetDependenciesRootFolderAbsPath()); + + $oDirectoryIterator = new RecursiveDirectoryIterator($sPath, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO|FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS); + $iterator = new RecursiveIteratorIterator( + $oDirectoryIterator, + RecursiveIteratorIterator::CHILD_FIRST); + + /** @var DirectoryIterator $file */ + foreach($iterator as $file) { + if(!$file->isDir()) { + continue; + } + $sDirName = $file->getFilename(); + if (!$this->IsQuestionnableFolder($sDirName)) + { + continue; + } + + $sTestPathDir = $file->getRealpath(); + $sTestPathDir = str_replace('\\', '/', $sTestPathDir); + $aAllTestDirs[] = $sTestPathDir; + } + + return $aAllTestDirs; + } + + /** + * @param string $sFolderName + * + * @return false|int as {@see \preg_match()} + * @uses static::QUESTIONNABLE_FOLDER_REGEXP + * @uses \preg_match() + */ + public static function IsQuestionnableFolder(string $sFolderName): false|int + { + return preg_match(static::QUESTIONNABLE_FOLDER_REGEXP, $sFolderName); + } + + /** + * @return string APPROOT constant but with slashes instead of DIRECTORY_SEPARATOR. + * This ease writing our paths, as we can use '/' for every platform. + */ + final protected function GetApprootPathWithSlashes(): string + { + return str_replace(DIRECTORY_SEPARATOR, '/', APPROOT); + } + + /** + * @return array Array of absolute paths to allowed questionnable folders + */ + abstract public function ListAllowedQuestionnableFoldersAbsPaths(): array; + + /** + * @return array Array of absolute paths to denied questionnable folders + */ + abstract public function ListDeniedQuestionnableFolderAbsPaths(): array; + + /** + * @return array Array of absolute paths to questionnable denied test folders that need to be marked as allowed or denied + */ + public function ListDeniedButStillPresent(): array + { + $aDeniedTestDir = $this->ListDeniedQuestionnableFolderAbsPaths(); + $aAllTestDir = $this->ListAllQuestionnableFoldersAbsPaths(); + return array_intersect($aDeniedTestDir, $aAllTestDir); + } +} \ No newline at end of file diff --git a/sources/Dependencies/Composer/iTopComposer.php b/sources/Dependencies/Composer/iTopComposer.php new file mode 100644 index 000000000..51bdae5f0 --- /dev/null +++ b/sources/Dependencies/Composer/iTopComposer.php @@ -0,0 +1,109 @@ + + * + */ + +namespace Combodo\iTop\Dependencies\Composer; + +use Combodo\iTop\Dependencies\AbstractHook; + +class iTopComposer extends AbstractHook +{ + /** + * @inheritDoc + */ + protected function GetDependenciesRootFolderAbsPath(): string + { + return $this->GetApprootPathWithSlashes() . "lib"; + } + + /** + * @inheritDoc + */ + public function ListAllowedQuestionnableFoldersAbsPaths(): array + { + $APPROOT_WITH_SLASHES = $this->GetDependenciesRootFolderAbsPath(); + return [ + $APPROOT_WITH_SLASHES . '/twig/twig/src/Node/Expression/Test', + ]; + } + + /** + * @inheritDoc + */ + public function ListDeniedQuestionnableFolderAbsPaths(): array + { + $APPROOT_WITH_SLASHES = $this->GetDependenciesRootFolderAbsPath(); + return [ + $APPROOT_WITH_SLASHES . '/doctrine/lexer/tests', + + $APPROOT_WITH_SLASHES . '/goaop/framework/tests', + + $APPROOT_WITH_SLASHES . '/laminas/laminas-servicemanager/src/Test', + + $APPROOT_WITH_SLASHES . '/nikic/php-parser/test', + + $APPROOT_WITH_SLASHES . '/pear/archive_tar/tests', + $APPROOT_WITH_SLASHES . '/pear/console_getopt/tests', + $APPROOT_WITH_SLASHES . '/pear/pear_exception/tests', + + $APPROOT_WITH_SLASHES . '/psr/log/Psr/Log/Test', + + $APPROOT_WITH_SLASHES . '/symfony/cache/Tests', + $APPROOT_WITH_SLASHES . '/symfony/cache/Tests/DoctrineProviderTest.php', + $APPROOT_WITH_SLASHES . '/symfony/class-loader/Tests', + $APPROOT_WITH_SLASHES . '/symfony/config/Tests', + $APPROOT_WITH_SLASHES . '/symfony/console/Tests', + $APPROOT_WITH_SLASHES . '/symfony/css-selector/Tests', + $APPROOT_WITH_SLASHES . '/symfony/debug/Resources/ext/tests', + $APPROOT_WITH_SLASHES . '/symfony/debug/Tests', + $APPROOT_WITH_SLASHES . '/symfony/dependency-injection/Tests', + $APPROOT_WITH_SLASHES . '/symfony/dotenv/Tests', + $APPROOT_WITH_SLASHES . '/symfony/event-dispatcher/Tests', + $APPROOT_WITH_SLASHES . '/symfony/filesystem/Tests', + $APPROOT_WITH_SLASHES . '/symfony/finder/Tests', + $APPROOT_WITH_SLASHES . '/symfony/http-client-contracts/Test', + $APPROOT_WITH_SLASHES . '/symfony/http-foundation/Test', + $APPROOT_WITH_SLASHES . '/symfony/http-kernel/Tests', + $APPROOT_WITH_SLASHES . '/symfony/service-contracts/Test', + $APPROOT_WITH_SLASHES . '/symfony/framework-bundle/Test', + $APPROOT_WITH_SLASHES . '/symfony/mime/Test', + $APPROOT_WITH_SLASHES . '/symfony/routing/Tests', + $APPROOT_WITH_SLASHES . '/symfony/stopwatch/Tests', + $APPROOT_WITH_SLASHES . '/symfony/translation-contracts/Test', + $APPROOT_WITH_SLASHES . '/symfony/twig-bridge/Test', + $APPROOT_WITH_SLASHES . '/symfony/twig-bundle/Tests', + $APPROOT_WITH_SLASHES . '/symfony/var-dumper/Test', + $APPROOT_WITH_SLASHES . '/symfony/var-dumper/Tests/Test', + $APPROOT_WITH_SLASHES . '/symfony/var-dumper/Tests', + $APPROOT_WITH_SLASHES . '/symfony/web-profiler-bundle/Tests', + $APPROOT_WITH_SLASHES . '/symfony/yaml/Tests', + + $APPROOT_WITH_SLASHES . '/tecnickcom/tcpdf/examples', + + $APPROOT_WITH_SLASHES . '/thenetworg/oauth2-azure/tests', + + $APPROOT_WITH_SLASHES . '/twig/twig/src/Test', + $APPROOT_WITH_SLASHES . '/twig/twig/lib/Twig/Test', + $APPROOT_WITH_SLASHES . '/twig/twig/doc/tests', + + $APPROOT_WITH_SLASHES . '/laminas/laminas-servicemanager/src/Test', + ]; + } +} \ No newline at end of file diff --git a/tests/php-unit-tests/unitary-tests/sources/Composer/iTopComposerTest.php b/tests/php-unit-tests/unitary-tests/sources/Dependencies/Composer/iTopComposerTest.php similarity index 66% rename from tests/php-unit-tests/unitary-tests/sources/Composer/iTopComposerTest.php rename to tests/php-unit-tests/unitary-tests/sources/Dependencies/Composer/iTopComposerTest.php index e80aae839..e8dff26f2 100644 --- a/tests/php-unit-tests/unitary-tests/sources/Composer/iTopComposerTest.php +++ b/tests/php-unit-tests/unitary-tests/sources/Dependencies/Composer/iTopComposerTest.php @@ -1,8 +1,8 @@ assertIsInt($isTestDir); if (true === $bIsTest) { $this->assertTrue(($isTestDir > 0)); @@ -48,7 +48,7 @@ class iTopComposerTest extends ItopTestCase } } - public function IsTestDirProvider() + public function IsTestFolderProvider() { return [ 'test' => ['test', true], @@ -62,42 +62,42 @@ class iTopComposerTest extends ItopTestCase ]; } - public function testListAllTestDir() + public function testListAllTestFoldersAbsPaths() { $oiTopComposer = new iTopComposer(); - $aDirs = $oiTopComposer->ListAllTestDir(); + $aDirs = $oiTopComposer->ListAllQuestionnableFoldersAbsPaths(); $this->assertTrue(is_array($aDirs)); foreach ($aDirs as $sDir) { $sDirName = basename($sDir); - $this->assertMatchesRegularExpression(iTopComposer::TEST_DIR_REGEXP, $sDirName, "Directory not matching test dir : $sDir"); + $this->assertMatchesRegularExpression(iTopComposer::QUESTIONNABLE_FOLDER_REGEXP, $sDirName, "Directory not matching test dir : $sDir"); } } - public function testListDeniedTestDir() + public function testListDeniedTestFolderAbsPaths() { $oiTopComposer = new iTopComposer(); - $aDirs = $oiTopComposer->ListDeniedTestDir(); + $aDirs = $oiTopComposer->ListDeniedQuestionnableFolderAbsPaths(); $this->assertTrue(is_array($aDirs)); $aDeniedDirWrongFormat = []; foreach ($aDirs as $sDir) { - if (false === iTopComposer::IsTestDir($sDir)) { + if (false === iTopComposer::IsQuestionnableFolder($sDir)) { $aDeniedDirWrongFormat[] = $sDir; } } $this->assertEmpty($aDeniedDirWrongFormat, - 'There are elements in \Combodo\iTop\Composer\iTopComposer::ListDeniedTestDir that are not test dirs :'.var_export($aDeniedDirWrongFormat, true)); + 'There are elements in \Combodo\iTop\Dependencies\Composer\iTopComposer::ListDeniedQuestionnableFolderAbsPaths that are not test dirs :'.var_export($aDeniedDirWrongFormat, true)); } - public function testListAllowedTestDir() + public function testListAllowedTestFoldersAbsPaths() { $oiTopComposer = new iTopComposer(); - $aDirs = $oiTopComposer->ListAllowedTestDir(); + $aDirs = $oiTopComposer->ListAllowedQuestionnableFoldersAbsPaths(); $this->assertTrue(is_array($aDirs)); } @@ -105,7 +105,7 @@ class iTopComposerTest extends ItopTestCase /** * This is NOT a unit test, this test the iTop instance running the test ... */ - public function testNoDeniedDirIsPresentForNow() + public function testNoDeniedFolderIsPresentForNow() { $oiTopComposer = new iTopComposer(); @@ -121,15 +121,15 @@ class iTopComposerTest extends ItopTestCase /** * This is NOT a unit test, this test the iTop instance running the test ... */ - public function testAllDirCovered() + public function testAllFoldersCovered() { - $oiTopComposer = new iTopComposer(); + $oDependenciesHandler = new iTopComposer(); $aAllowedAndDeniedDirs = array_merge( - $oiTopComposer->ListAllowedTestDir(), - $oiTopComposer->ListDeniedTestDir() + $oDependenciesHandler->ListAllowedQuestionnableFoldersAbsPaths(), + $oDependenciesHandler->ListDeniedQuestionnableFolderAbsPaths() ); - $aExistingDirs = $oiTopComposer->ListAllTestDir(); + $aExistingDirs = $oDependenciesHandler->ListAllQuestionnableFoldersAbsPaths(); $aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs); $aExtra = array_diff($aAllowedAndDeniedDirs, $aExistingDirs);