Rename "Ignore CI Configs" to "Ignored CI Config"

This commit is contained in:
Maxime Rainville 2021-11-22 11:02:27 +13:00
parent 7c3fddfc8a
commit e0197191b8
8 changed files with 21 additions and 20 deletions

View File

@ -516,7 +516,7 @@ class CoreKernel implements Kernel
* *
* @return string[] List of CI types to ignore as defined by `Module`. * @return string[] List of CI types to ignore as defined by `Module`.
*/ */
protected function getIgnoreCIConfigs(): array protected function getIgnoredCIConfigs(): array
{ {
return []; return [];
} }
@ -532,14 +532,14 @@ class CoreKernel implements Kernel
$this->getClassLoader()->init( $this->getClassLoader()->init(
$this->getIncludeTests(), $this->getIncludeTests(),
$flush, $flush,
$this->getIgnoreCIConfigs() $this->getIgnoredCIConfigs()
); );
// Find modules // Find modules
$this->getModuleLoader()->init( $this->getModuleLoader()->init(
$this->getIncludeTests(), $this->getIncludeTests(),
$flush, $flush,
$this->getIgnoreCIConfigs() $this->getIgnoredCIConfigs()
); );
// Flush config // Flush config
@ -561,7 +561,7 @@ class CoreKernel implements Kernel
$defaultSet->init( $defaultSet->init(
$this->getIncludeTests(), $this->getIncludeTests(),
$flush, $flush,
$this->getIgnoreCIConfigs() $this->getIgnoredCIConfigs()
); );
} }
} }

View File

@ -515,7 +515,7 @@ class ClassManifest
'name_regex' => '/^[^_].*\\.php$/', 'name_regex' => '/^[^_].*\\.php$/',
'ignore_files' => ['index.php', 'cli-script.php'], 'ignore_files' => ['index.php', 'cli-script.php'],
'ignore_tests' => !$includeTests, 'ignore_tests' => !$includeTests,
'ignore_ci_configs' => $ignoredCIConfigs, 'ignored_ci_configs' => $ignoredCIConfigs,
'file_callback' => function ($basename, $pathname, $depth) use ($includeTests, $finder) { 'file_callback' => function ($basename, $pathname, $depth) use ($includeTests, $finder) {
$this->handleFile($basename, $pathname, $includeTests); $this->handleFile($basename, $pathname, $includeTests);
}, },

View File

@ -6,13 +6,14 @@ use RuntimeException;
use SilverStripe\Assets\FileFinder; use SilverStripe\Assets\FileFinder;
/** /**
* An extension to the default file finder with some extra filters to faciliate * An extension to the default file finder with some extra filters to facilitate
* autoload and template manifest generation: * autoload and template manifest generation:
* - Only modules with _config.php files are scanned. * - Only modules with _config.php files are scanned.
* - If a _manifest_exclude file is present inside a directory it is ignored. * - If a _manifest_exclude file is present inside a directory it is ignored.
* - Assets and module language directories are ignored. * - Assets and module language directories are ignored.
* - Module tests directories are skipped if the ignore_tests option is not * - Module tests directories are skipped if either of these conditions is meant:
* set to false. * - the `ignore_tests` option is not set to false.
* - the module PHP CI configuration matches one of the `ignored_ci_configs`
*/ */
class ManifestFileFinder extends FileFinder class ManifestFileFinder extends FileFinder
{ {
@ -34,7 +35,7 @@ class ManifestFileFinder extends FileFinder
'ignore_tests' => true, 'ignore_tests' => true,
'min_depth' => 1, 'min_depth' => 1,
'ignore_dirs' => ['node_modules'], 'ignore_dirs' => ['node_modules'],
'ignore_ci_configs' => [] 'ignored_ci_configs' => []
]; ];
public function acceptDir($basename, $pathname, $depth) public function acceptDir($basename, $pathname, $depth)
@ -76,9 +77,9 @@ class ManifestFileFinder extends FileFinder
} }
// Skip if test dir inside vendor module with unexpected CI Configuration // Skip if test dir inside vendor module with unexpected CI Configuration
if ($depth > 3 && $basename === self::TESTS_DIR && $ignoreCIConfig = $this->getOption('ignore_ci_configs')) { if ($depth > 3 && $basename === self::TESTS_DIR && $ignoredCIConfig = $this->getOption('ignored_ci_configs')) {
$ciLib = $this->findModuleCIPhpConfiguration($basename, $pathname, $depth); $ciLib = $this->findModuleCIPhpConfiguration($basename, $pathname, $depth);
if (in_array($ciLib, $ignoreCIConfig)) { if (in_array($ciLib, $ignoredCIConfig)) {
return false; return false;
} }
} }

View File

@ -173,7 +173,7 @@ class ModuleManifest
$finder->setOptions([ $finder->setOptions([
'min_depth' => 0, 'min_depth' => 0,
'ignore_tests' => !$includeTests, 'ignore_tests' => !$includeTests,
'ignore_ci_configs' => $ignoredCIConfigs, 'ignored_ci_configs' => $ignoredCIConfigs,
'dir_callback' => function ($basename, $pathname, $depth) use ($finder) { 'dir_callback' => function ($basename, $pathname, $depth) use ($finder) {
if ($finder->isDirectoryModule($basename, $pathname, $depth)) { if ($finder->isDirectoryModule($basename, $pathname, $depth)) {
$this->addModule($pathname); $this->addModule($pathname);

View File

@ -1012,7 +1012,7 @@ if (class_exists(IsEqualCanonicalizing::class)) {
$kernel = new TestKernel(BASE_PATH); $kernel = new TestKernel(BASE_PATH);
// PHPUnit 9 only logic to exclude old test still targeting PHPUNit 5.7 // PHPUnit 9 only logic to exclude old test still targeting PHPUNit 5.7
$kernel->setIgnoreCIConfigs([Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]); $kernel->setIgnoredCIConfigs([Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]);
if (class_exists(HTTPApplication::class)) { if (class_exists(HTTPApplication::class)) {
// Mock request // Mock request

View File

@ -51,15 +51,15 @@ class TestKernel extends CoreKernel
* Set a list of CI configurations that should cause a module's test not to be added to a manifest * Set a list of CI configurations that should cause a module's test not to be added to a manifest
* @param string[] $ciConfigs * @param string[] $ciConfigs
*/ */
public function setIgnoreCIConfigs(array $ciLibs): self public function setIgnoredCIConfigs(array $ciConfigs): self
{ {
$this->ciLibs = $ciLibs; $this->ciConfigs = $ciConfigs;
return $this; return $this;
} }
protected function getIgnoreCIConfigs(): array protected function getIgnoredCIConfigs(): array
{ {
return $this->ciLibs; return $this->ciConfigs;
} }
protected function bootErrorHandling() protected function bootErrorHandling()

View File

@ -139,7 +139,7 @@ class ThemeManifest implements ThemeList
'include_themes' => false, 'include_themes' => false,
'ignore_dirs' => ['node_modules', THEMES_DIR], 'ignore_dirs' => ['node_modules', THEMES_DIR],
'ignore_tests' => !$includeTests, 'ignore_tests' => !$includeTests,
'ignore_ci_configs' => $ignoredCIConfigs, 'ignored_ci_configs' => $ignoredCIConfigs,
'dir_callback' => [$this, 'handleDirectory'] 'dir_callback' => [$this, 'handleDirectory']
]); ]);

View File

@ -91,7 +91,7 @@ class ManifestFileFinderTest extends SapphireTest
$finder = new ManifestFileFinder(); $finder = new ManifestFileFinder();
$finder->setOption('name_regex', '/\.txt$/'); $finder->setOption('name_regex', '/\.txt$/');
$finder->setOption('ignore_tests', false); $finder->setOption('ignore_tests', false);
$finder->setOption('ignore_ci_configs', [Module::CI_PHPUNIT_FIVE]); $finder->setOption('ignored_ci_configs', [Module::CI_PHPUNIT_FIVE]);
$this->assertFinderFinds( $this->assertFinderFinds(
$finder, $finder,
@ -115,7 +115,7 @@ class ManifestFileFinderTest extends SapphireTest
$finder = new ManifestFileFinder(); $finder = new ManifestFileFinder();
$finder->setOption('name_regex', '/\.txt$/'); $finder->setOption('name_regex', '/\.txt$/');
$finder->setOption('ignore_tests', false); $finder->setOption('ignore_tests', false);
$finder->setOption('ignore_ci_configs', [Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]); $finder->setOption('ignored_ci_configs', [Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]);
$this->assertFinderFinds( $this->assertFinderFinds(
$finder, $finder,