N°7331 - Refactor Composer cleanup scripts to be used by other dependencies managers as well

This commit is contained in:
Molkobain
2024-03-11 10:55:54 +01:00
parent b934cbe89e
commit d1a4d333eb
16 changed files with 286 additions and 211 deletions

View File

@@ -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',
];

View File

@@ -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;

View File

@@ -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__);

View File

@@ -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";
}

View File

@@ -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"
}
}

View File

@@ -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',

View File

@@ -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',

View File

@@ -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(),

View File

@@ -1,169 +0,0 @@
<?php
/**
* Copyright (C) 2010-2023 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http: *www.gnu.org/licenses/>
*
*/
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);
}
}

View File

@@ -0,0 +1,114 @@
<?php
/*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Dependencies;
use FilesystemIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
/**
* Class AbstractHook
*
* Extend this class to enable a dependency manager such as Composer or NPM to clean unnecessary files after an installation or update of a package.
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @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);
}
}

View File

@@ -0,0 +1,109 @@
<?php
/**
* Copyright (C) 2010-2023 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with iTop. If not, see <http: *www.gnu.org/licenses/>
*
*/
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',
];
}
}

View File

@@ -1,8 +1,8 @@
<?php
namespace Combodo\iTop\Test\UnitTest\Composer;
namespace Combodo\iTop\Test\UnitTest\Dependencies\Composer;
use Combodo\iTop\Composer\iTopComposer;
use Combodo\iTop\Dependencies\Composer\iTopComposer;
use Combodo\iTop\Test\UnitTest\ItopTestCase;
/**
@@ -34,12 +34,12 @@ class iTopComposerTest extends ItopTestCase
}
/**
* @dataProvider IsTestDirProvider
* @dataProvider IsTestFolderProvider
* @return void
*/
public function testIsTestDir($sDirName, $bIsTest)
public function testIsTestFolder($sDirName, $bIsTest)
{
$isTestDir = iTopComposer::IsTestDir($sDirName);
$isTestDir = iTopComposer::IsQuestionnableFolder($sDirName);
$this->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);