mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Anwser Peer review feedback
This commit is contained in:
parent
cbc4593ab4
commit
7c3fddfc8a
@ -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 getIgnoreCILibraries(): array
|
protected function getIgnoreCIConfigs(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@ -532,14 +532,14 @@ class CoreKernel implements Kernel
|
|||||||
$this->getClassLoader()->init(
|
$this->getClassLoader()->init(
|
||||||
$this->getIncludeTests(),
|
$this->getIncludeTests(),
|
||||||
$flush,
|
$flush,
|
||||||
$this->getIgnoreCILibraries()
|
$this->getIgnoreCIConfigs()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Find modules
|
// Find modules
|
||||||
$this->getModuleLoader()->init(
|
$this->getModuleLoader()->init(
|
||||||
$this->getIncludeTests(),
|
$this->getIncludeTests(),
|
||||||
$flush,
|
$flush,
|
||||||
$this->getIgnoreCILibraries()
|
$this->getIgnoreCIConfigs()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Flush config
|
// Flush config
|
||||||
@ -561,7 +561,7 @@ class CoreKernel implements Kernel
|
|||||||
$defaultSet->init(
|
$defaultSet->init(
|
||||||
$this->getIncludeTests(),
|
$this->getIncludeTests(),
|
||||||
$flush,
|
$flush,
|
||||||
$this->getIgnoreCILibraries()
|
$this->getIgnoreCIConfigs()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,14 +120,14 @@ class ClassLoader
|
|||||||
*
|
*
|
||||||
* @param bool $includeTests
|
* @param bool $includeTests
|
||||||
* @param bool $forceRegen
|
* @param bool $forceRegen
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function init($includeTests = false, $forceRegen = false, array $ignoredCILibs = [])
|
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
foreach ($this->manifests as $manifest) {
|
foreach ($this->manifests as $manifest) {
|
||||||
/** @var ClassManifest $instance */
|
/** @var ClassManifest $instance */
|
||||||
$instance = $manifest['instance'];
|
$instance = $manifest['instance'];
|
||||||
$instance->init($includeTests, $forceRegen, $ignoredCILibs);
|
$instance->init($includeTests, $forceRegen, $ignoredCIConfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerAutoloader();
|
$this->registerAutoloader();
|
||||||
|
@ -260,9 +260,9 @@ class ClassManifest
|
|||||||
*
|
*
|
||||||
* @param bool $includeTests
|
* @param bool $includeTests
|
||||||
* @param bool $forceRegen
|
* @param bool $forceRegen
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function init($includeTests = false, $forceRegen = false, array $ignoredCILibs = [])
|
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
$this->cache = $this->buildCache($includeTests);
|
$this->cache = $this->buildCache($includeTests);
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ class ClassManifest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build
|
// Build
|
||||||
$this->regenerate($includeTests, $ignoredCILibs);
|
$this->regenerate($includeTests, $ignoredCIConfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -501,9 +501,9 @@ class ClassManifest
|
|||||||
* Completely regenerates the manifest file.
|
* Completely regenerates the manifest file.
|
||||||
*
|
*
|
||||||
* @param bool $includeTests
|
* @param bool $includeTests
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function regenerate($includeTests, array $ignoredCILibs = [])
|
public function regenerate($includeTests, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
// Reset the manifest so stale info doesn't cause errors.
|
// Reset the manifest so stale info doesn't cause errors.
|
||||||
$this->loadState([]);
|
$this->loadState([]);
|
||||||
@ -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_libraries' => $ignoredCILibs,
|
'ignore_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);
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Core\Manifest;
|
namespace SilverStripe\Core\Manifest;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
use SilverStripe\Assets\FileFinder;
|
use SilverStripe\Assets\FileFinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +34,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_libraries' => []
|
'ignore_ci_configs' => []
|
||||||
];
|
];
|
||||||
|
|
||||||
public function acceptDir($basename, $pathname, $depth)
|
public function acceptDir($basename, $pathname, $depth)
|
||||||
@ -74,10 +75,10 @@ class ManifestFileFinder extends FileFinder
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if test dir inside vendor module with unexpected CI library
|
// Skip if test dir inside vendor module with unexpected CI Configuration
|
||||||
if ($depth > 3 && $basename === self::TESTS_DIR && $ignoreCILib = $this->getOption('ignore_ci_libraries')) {
|
if ($depth > 3 && $basename === self::TESTS_DIR && $ignoreCIConfig = $this->getOption('ignore_ci_configs')) {
|
||||||
$ciLib = $this->findModuleCILib($basename, $pathname, $depth);
|
$ciLib = $this->findModuleCIPhpConfiguration($basename, $pathname, $depth);
|
||||||
if (in_array($ciLib, $ignoreCILib)) {
|
if (in_array($ciLib, $ignoreCIConfig)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,21 +262,39 @@ class ManifestFileFinder extends FileFinder
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findModuleCILib(string $basename, string $pathname, int $depth): string
|
/**
|
||||||
|
* Find out the root of the current module and read the PHP CI configuration from tho composer file
|
||||||
|
*
|
||||||
|
* @param string $basename Name of the current folder
|
||||||
|
* @param string $pathname Full path the parent folder
|
||||||
|
* @param string $depth Depth of the current folder
|
||||||
|
*/
|
||||||
|
private function findModuleCIPhpConfiguration(string $basename, string $pathname, int $depth): string
|
||||||
{
|
{
|
||||||
if ($depth < 1) {
|
if ($depth < 1) {
|
||||||
|
// We went all the way back to the root of the project
|
||||||
return Module::CI_UNKNOWN;
|
return Module::CI_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We pop the current folder and use the next entry the pathname
|
||||||
$newBasename = basename($pathname);
|
$newBasename = basename($pathname);
|
||||||
$newPathname = dirname($pathname);
|
$newPathname = dirname($pathname);
|
||||||
$newDepth = $depth - 1;
|
$newDepth = $depth - 1;
|
||||||
|
|
||||||
if ($this->isDirectoryModule($newBasename, $newPathname, $newDepth)) {
|
if ($this->isDirectoryModule($newBasename, $newPathname, $newDepth)) {
|
||||||
|
// We've reached the root of the module folder, we can read the PHP CI config now
|
||||||
$module = new Module($newPathname, $this->upLevels($newPathname, $newDepth));
|
$module = new Module($newPathname, $this->upLevels($newPathname, $newDepth));
|
||||||
return $module->getCILibrary();
|
$config = $module->getCIConfig();
|
||||||
|
|
||||||
|
if (empty($config['PHP'])) {
|
||||||
|
// This should never happen
|
||||||
|
throw new RuntimeException('Module::getCIConfig() did not return a PHP CI value');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->findModuleCILib($newBasename, $newPathname, $newDepth);
|
return $config['PHP'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// We haven't reach our module root yet ... let's look up one more level
|
||||||
|
return $this->findModuleCIPhpConfiguration($newBasename, $newPathname, $newDepth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\Core\Manifest;
|
|||||||
use Composer\Semver\Semver;
|
use Composer\Semver\Semver;
|
||||||
use Exception;
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
use Serializable;
|
use Serializable;
|
||||||
use SilverStripe\Core\Path;
|
use SilverStripe\Core\Path;
|
||||||
use SilverStripe\Dev\Deprecation;
|
use SilverStripe\Dev\Deprecation;
|
||||||
@ -21,19 +22,19 @@ class Module implements Serializable
|
|||||||
const TRIM_CHARS = ' /\\';
|
const TRIM_CHARS = ' /\\';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value of getCILibrary() when module uses PHPUNit 9
|
* Return value of getCIConfig() when module uses PHPUNit 9
|
||||||
*/
|
*/
|
||||||
const CI_PHPUNIT_NINE = 'PHPUnit9';
|
const CI_PHPUNIT_NINE = 'CI_PHPUNIT_NINE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value of getCILibrary() when module uses PHPUNit 5
|
* Return value of getCIConfig() when module uses PHPUNit 5
|
||||||
*/
|
*/
|
||||||
const CI_PHPUNIT_FIVE = 'PHPUnit5';
|
const CI_PHPUNIT_FIVE = 'CI_PHPUNIT_FIVE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value of getCILibrary() when module does not use any CI
|
* Return value of getCIConfig() when module does not use any CI
|
||||||
*/
|
*/
|
||||||
const CI_UNKNOWN = 'NoPHPUnit';
|
const CI_UNKNOWN = 'CI_UNKNOWN';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -295,10 +296,22 @@ class Module implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine what CI library the module is using.
|
* Determine what configurations the module is using to run various aspects of its CI. THe only aspect
|
||||||
|
* that is observed is `PHP`
|
||||||
|
* @return array List of configuration aspects e.g.: `['PHP' => 'CI_PHPUNIT_NINE']`
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function getCILibrary(): string
|
public function getCIConfig(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'PHP' => $this->getPhpCiConfig()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine what CI Configuration the module uses to test its PHP code.
|
||||||
|
*/
|
||||||
|
private function getPhpCiConfig(): string
|
||||||
{
|
{
|
||||||
// We don't have any composer data at all
|
// We don't have any composer data at all
|
||||||
if (empty($this->composerData)) {
|
if (empty($this->composerData)) {
|
||||||
@ -316,10 +329,18 @@ class Module implements Serializable
|
|||||||
// Try to pick which CI we are using based on phpunit constraint
|
// Try to pick which CI we are using based on phpunit constraint
|
||||||
$phpUnitConstraint = $this->requireDevConstraint(['sminnee/phpunit', 'phpunit/phpunit']);
|
$phpUnitConstraint = $this->requireDevConstraint(['sminnee/phpunit', 'phpunit/phpunit']);
|
||||||
if ($phpUnitConstraint) {
|
if ($phpUnitConstraint) {
|
||||||
if ($this->satisfiesAtLeastOne(['5.7.0', '5.0.0', '5.x-dev', '5.7.x-dev'], $phpUnitConstraint)) {
|
if ($this->constraintSatisfies(
|
||||||
|
$phpUnitConstraint,
|
||||||
|
['5.7.0', '5.0.0', '5.x-dev', '5.7.x-dev'],
|
||||||
|
5
|
||||||
|
)) {
|
||||||
return self::CI_PHPUNIT_FIVE;
|
return self::CI_PHPUNIT_FIVE;
|
||||||
}
|
}
|
||||||
if ($this->satisfiesAtLeastOne(['9.0.0', '9.5.0', '9.x-dev', '9.5.x-dev'], $phpUnitConstraint)) {
|
if ($this->constraintSatisfies(
|
||||||
|
$phpUnitConstraint,
|
||||||
|
['9.0.0', '9.5.0', '9.x-dev', '9.5.x-dev'],
|
||||||
|
9
|
||||||
|
)) {
|
||||||
return self::CI_PHPUNIT_NINE;
|
return self::CI_PHPUNIT_NINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,10 +348,18 @@ class Module implements Serializable
|
|||||||
// Try to pick which CI we are using based on recipe-testing constraint
|
// Try to pick which CI we are using based on recipe-testing constraint
|
||||||
$recipeTestingConstraint = $this->requireDevConstraint(['silverstripe/recipe-testing']);
|
$recipeTestingConstraint = $this->requireDevConstraint(['silverstripe/recipe-testing']);
|
||||||
if ($recipeTestingConstraint) {
|
if ($recipeTestingConstraint) {
|
||||||
if ($this->satisfiesAtLeastOne(['1.0.0', '1.1.0', '1.2.0', '1.1.x-dev', '1.2.x-dev', '1.x-dev'], $recipeTestingConstraint)) {
|
if ($this->constraintSatisfies(
|
||||||
|
$recipeTestingConstraint,
|
||||||
|
['1.0.0', '1.1.0', '1.2.0', '1.1.x-dev', '1.2.x-dev', '1.x-dev'],
|
||||||
|
1
|
||||||
|
)) {
|
||||||
return self::CI_PHPUNIT_FIVE;
|
return self::CI_PHPUNIT_FIVE;
|
||||||
}
|
}
|
||||||
if ($this->satisfiesAtLeastOne(['2.0.0', '2.0.x-dev', '2.x-dev'], $recipeTestingConstraint)) {
|
if ($this->constraintSatisfies(
|
||||||
|
$recipeTestingConstraint,
|
||||||
|
['2.0.0', '2.0.x-dev', '2.x-dev'],
|
||||||
|
2
|
||||||
|
)) {
|
||||||
return self::CI_PHPUNIT_NINE;
|
return self::CI_PHPUNIT_NINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,9 +391,22 @@ class Module implements Serializable
|
|||||||
/**
|
/**
|
||||||
* Determines if the provided constraint allows at least one of the version provided
|
* Determines if the provided constraint allows at least one of the version provided
|
||||||
*/
|
*/
|
||||||
private function satisfiesAtLeastOne(array $versions, string $constraint): bool
|
private function constraintSatisfies(
|
||||||
{
|
string $constraint,
|
||||||
return !empty(Semver::satisfiedBy($versions, $constraint));
|
array $possibleVersions,
|
||||||
|
int $majorVersionFallback
|
||||||
|
): bool {
|
||||||
|
// Let's see of any of our possible versions is allowed by the constraint
|
||||||
|
if (!empty(Semver::satisfiedBy($possibleVersions, $constraint))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Let's see if we are using an exact version constraint. e.g. ~1.2.3 or 1.2.3 or ~1.2 or 1.2.*
|
||||||
|
if (preg_match("/^~?$majorVersionFallback(\.(\d+)|\*){0,2}/", $constraint)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +91,12 @@ class ModuleLoader
|
|||||||
*
|
*
|
||||||
* @param bool $includeTests
|
* @param bool $includeTests
|
||||||
* @param bool $forceRegen
|
* @param bool $forceRegen
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function init($includeTests = false, $forceRegen = false, array $ignoredCILibs = [])
|
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
foreach ($this->manifests as $manifest) {
|
foreach ($this->manifests as $manifest) {
|
||||||
$manifest->init($includeTests, $forceRegen, $ignoredCILibs);
|
$manifest->init($includeTests, $forceRegen, $ignoredCIConfigs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,9 +121,9 @@ class ModuleManifest
|
|||||||
/**
|
/**
|
||||||
* @param bool $includeTests
|
* @param bool $includeTests
|
||||||
* @param bool $forceRegen Force the manifest to be regenerated.
|
* @param bool $forceRegen Force the manifest to be regenerated.
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function init($includeTests = false, $forceRegen = false, array $ignoredCILibs = [])
|
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
// build cache from factory
|
// build cache from factory
|
||||||
if ($this->cacheFactory) {
|
if ($this->cacheFactory) {
|
||||||
@ -138,7 +138,7 @@ class ModuleManifest
|
|||||||
$this->modules = $this->cache->get($this->cacheKey) ?: [];
|
$this->modules = $this->cache->get($this->cacheKey) ?: [];
|
||||||
}
|
}
|
||||||
if (empty($this->modules)) {
|
if (empty($this->modules)) {
|
||||||
$this->regenerate($includeTests, $ignoredCILibs);
|
$this->regenerate($includeTests, $ignoredCIConfigs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,9 +163,9 @@ class ModuleManifest
|
|||||||
* Does _not_ build the actual variant
|
* Does _not_ build the actual variant
|
||||||
*
|
*
|
||||||
* @param bool $includeTests
|
* @param bool $includeTests
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function regenerate($includeTests = false, array $ignoredCILibs = [])
|
public function regenerate($includeTests = false, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
$this->modules = [];
|
$this->modules = [];
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ class ModuleManifest
|
|||||||
$finder->setOptions([
|
$finder->setOptions([
|
||||||
'min_depth' => 0,
|
'min_depth' => 0,
|
||||||
'ignore_tests' => !$includeTests,
|
'ignore_tests' => !$includeTests,
|
||||||
'ignore_ci_libraries' => $ignoredCILibs,
|
'ignore_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);
|
||||||
|
@ -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->setIgnoreCILibraries([Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]);
|
$kernel->setIgnoreCIConfigs([Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]);
|
||||||
|
|
||||||
if (class_exists(HTTPApplication::class)) {
|
if (class_exists(HTTPApplication::class)) {
|
||||||
// Mock request
|
// Mock request
|
||||||
|
@ -10,8 +10,8 @@ use SilverStripe\Core\CoreKernel;
|
|||||||
class TestKernel extends CoreKernel
|
class TestKernel extends CoreKernel
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var string[] $ciLibs */
|
/** @var string[] $ciConfigs */
|
||||||
private $ciLibs = [];
|
private $ciConfigs = [];
|
||||||
|
|
||||||
|
|
||||||
public function __construct($basePath)
|
public function __construct($basePath)
|
||||||
@ -48,15 +48,16 @@ class TestKernel extends CoreKernel
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $ciLibs
|
* Set a list of CI configurations that should cause a module's test not to be added to a manifest
|
||||||
|
* @param string[] $ciConfigs
|
||||||
*/
|
*/
|
||||||
public function setIgnoreCILibraries(array $ciLibs): self
|
public function setIgnoreCIConfigs(array $ciLibs): self
|
||||||
{
|
{
|
||||||
$this->ciLibs = $ciLibs;
|
$this->ciLibs = $ciLibs;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getIgnoreCILibraries(): array
|
protected function getIgnoreCIConfigs(): array
|
||||||
{
|
{
|
||||||
return $this->ciLibs;
|
return $this->ciLibs;
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,9 @@ class ThemeManifest implements ThemeList
|
|||||||
/**
|
/**
|
||||||
* @param bool $includeTests Include tests in the manifest
|
* @param bool $includeTests Include tests in the manifest
|
||||||
* @param bool $forceRegen Force the manifest to be regenerated.
|
* @param bool $forceRegen Force the manifest to be regenerated.
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function init($includeTests = false, $forceRegen = false, array $ignoredCILibs = [])
|
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
// build cache from factory
|
// build cache from factory
|
||||||
if ($this->cacheFactory) {
|
if ($this->cacheFactory) {
|
||||||
@ -88,7 +88,7 @@ class ThemeManifest implements ThemeList
|
|||||||
if (!$forceRegen && $this->cache && ($data = $this->cache->get($this->cacheKey))) {
|
if (!$forceRegen && $this->cache && ($data = $this->cache->get($this->cacheKey))) {
|
||||||
$this->themes = $data;
|
$this->themes = $data;
|
||||||
} else {
|
} else {
|
||||||
$this->regenerate($includeTests, $ignoredCILibs);
|
$this->regenerate($includeTests, $ignoredCIConfigs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,16 +130,16 @@ class ThemeManifest implements ThemeList
|
|||||||
* Regenerates the manifest by scanning the base path.
|
* Regenerates the manifest by scanning the base path.
|
||||||
*
|
*
|
||||||
* @param bool $includeTests
|
* @param bool $includeTests
|
||||||
* @param string[] $ignoredCILibs
|
* @param string[] $ignoredCIConfigs
|
||||||
*/
|
*/
|
||||||
public function regenerate($includeTests = false, array $ignoredCILibs = [])
|
public function regenerate($includeTests = false, array $ignoredCIConfigs = [])
|
||||||
{
|
{
|
||||||
$finder = new ManifestFileFinder();
|
$finder = new ManifestFileFinder();
|
||||||
$finder->setOptions([
|
$finder->setOptions([
|
||||||
'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_libraries' => $ignoredCILibs,
|
'ignore_ci_configs' => $ignoredCIConfigs,
|
||||||
'dir_callback' => [$this, 'handleDirectory']
|
'dir_callback' => [$this, 'handleDirectory']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -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_libraries', [Module::CI_PHPUNIT_FIVE]);
|
$finder->setOption('ignore_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_libraries', [Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]);
|
$finder->setOption('ignore_ci_configs', [Module::CI_PHPUNIT_FIVE, Module::CI_UNKNOWN]);
|
||||||
|
|
||||||
$this->assertFinderFinds(
|
$this->assertFinderFinds(
|
||||||
$finder,
|
$finder,
|
||||||
|
@ -23,16 +23,22 @@ class ModuleTest extends SapphireTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider ciLibraryProvider
|
* @dataProvider ciConfigProvider
|
||||||
|
* @param string $fixture The folder containing our test composer file
|
||||||
|
* @param string $expectedPhpConfig
|
||||||
*/
|
*/
|
||||||
public function testGetCILibrary($fixture, $expected)
|
public function testGetCIConfig($fixture, $expectedPhpConfig)
|
||||||
{
|
{
|
||||||
$path = __DIR__ . '/fixtures/phpunit-detection/' . $fixture;
|
$path = __DIR__ . '/fixtures/phpunit-detection/' . $fixture;
|
||||||
$module = new Module($path, $path);
|
$module = new Module($path, $path);
|
||||||
$this->assertEquals($expected, $module->getCILibrary());
|
$this->assertEquals(
|
||||||
|
$expectedPhpConfig,
|
||||||
|
$module->getCIConfig()['PHP'],
|
||||||
|
'PHP config is set to ' . $expectedPhpConfig
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ciLibraryProvider()
|
public function ciConfigProvider()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'empty require-dev' => ['empty-require-dev', Module::CI_UNKNOWN],
|
'empty require-dev' => ['empty-require-dev', Module::CI_UNKNOWN],
|
||||||
@ -43,19 +49,25 @@ class ModuleTest extends SapphireTest
|
|||||||
|
|
||||||
'phpunit 5.0' => ['phpunit-five-zero', Module::CI_PHPUNIT_FIVE],
|
'phpunit 5.0' => ['phpunit-five-zero', Module::CI_PHPUNIT_FIVE],
|
||||||
'phpunit 5.7' => ['phpunit-five-seven', Module::CI_PHPUNIT_FIVE],
|
'phpunit 5.7' => ['phpunit-five-seven', Module::CI_PHPUNIT_FIVE],
|
||||||
|
'phpunit 5 exact version' => ['phpunit-five-exact-version', Module::CI_PHPUNIT_FIVE],
|
||||||
|
'phpunit 5 tilde' => ['phpunit-five-tilde', Module::CI_PHPUNIT_FIVE],
|
||||||
'sminnee 5.7' => ['sminnee-five-seven', Module::CI_PHPUNIT_FIVE],
|
'sminnee 5.7' => ['sminnee-five-seven', Module::CI_PHPUNIT_FIVE],
|
||||||
'sminnee 5' => ['sminnee-five-seven', Module::CI_PHPUNIT_FIVE],
|
'sminnee 5' => ['sminnee-five-seven', Module::CI_PHPUNIT_FIVE],
|
||||||
|
'sminnee 5 star' => ['sminnee-five-star', Module::CI_PHPUNIT_FIVE],
|
||||||
|
|
||||||
'phpunit 9' => ['phpunit-nine', Module::CI_PHPUNIT_NINE],
|
'phpunit 9' => ['phpunit-nine', Module::CI_PHPUNIT_NINE],
|
||||||
'phpunit 9.5' => ['phpunit-nine-five', Module::CI_PHPUNIT_NINE],
|
'phpunit 9.5' => ['phpunit-nine-five', Module::CI_PHPUNIT_NINE],
|
||||||
'future phpunit 9' => ['phpunit-nine-x', Module::CI_PHPUNIT_NINE],
|
'future phpunit 9' => ['phpunit-nine-x', Module::CI_PHPUNIT_NINE],
|
||||||
|
'phpunit 9 exact version' => ['phpunit-nine-exact', Module::CI_PHPUNIT_NINE],
|
||||||
|
|
||||||
'recipe-testing 1' => ['recipe-testing-one', Module::CI_PHPUNIT_FIVE],
|
'recipe-testing 1' => ['recipe-testing-one', Module::CI_PHPUNIT_FIVE],
|
||||||
'recipe-testing 1.x' => ['recipe-testing-one-x', Module::CI_PHPUNIT_FIVE],
|
'recipe-testing 1.x' => ['recipe-testing-one-x', Module::CI_PHPUNIT_FIVE],
|
||||||
'recipe-testing 1.2.x' => ['recipe-testing-one-two-x', Module::CI_PHPUNIT_FIVE],
|
'recipe-testing 1.2.x' => ['recipe-testing-one-two-x', Module::CI_PHPUNIT_FIVE],
|
||||||
|
'recipe-testing 1 with stability flag' => ['recipe-testing-one-flag', Module::CI_PHPUNIT_FIVE],
|
||||||
|
|
||||||
'recipe-testing 2' => ['recipe-testing-two', Module::CI_PHPUNIT_NINE],
|
'recipe-testing 2' => ['recipe-testing-two', Module::CI_PHPUNIT_NINE],
|
||||||
'recipe-testing 2.x' => ['recipe-testing-two-x', Module::CI_PHPUNIT_NINE],
|
'recipe-testing 2.x' => ['recipe-testing-two-x', Module::CI_PHPUNIT_NINE],
|
||||||
|
'recipe-testing 2 exact' => ['recipe-testing-two-x', Module::CI_PHPUNIT_NINE],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "silverstripe/empty-require-dev",
|
||||||
|
"type": "silverstripe-vendor-module",
|
||||||
|
"description": "This fake module uses an exact version of phpunit 5",
|
||||||
|
"homepage": "https://www.silverstripe.org",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"require": {
|
||||||
|
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "5.7.1234"
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "silverstripe/empty-require-dev",
|
"name": "silverstripe/empty-require-dev",
|
||||||
"type": "silverstripe-vendor-module",
|
"type": "silverstripe-vendor-module",
|
||||||
"description": "This fake module uses any version of sminnee/PHPUnit 5",
|
"description": "This fake module uses any version of PHPUnit 5",
|
||||||
"homepage": "https://www.silverstripe.org",
|
"homepage": "https://www.silverstripe.org",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"sminnee/phpunit": "^5"
|
"phpunit/phpunit": "^5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "silverstripe/empty-require-dev",
|
||||||
|
"type": "silverstripe-vendor-module",
|
||||||
|
"description": "This fake module uses a tilde constraint of phpunit 5",
|
||||||
|
"homepage": "https://www.silverstripe.org",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"require": {
|
||||||
|
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~5.9.1234"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "silverstripe/empty-require-dev",
|
||||||
|
"type": "silverstripe-vendor-module",
|
||||||
|
"description": "This fake module uses an exact version of phpunit 9",
|
||||||
|
"homepage": "https://www.silverstripe.org",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"require": {
|
||||||
|
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "9.9.9"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "silverstripe/empty-require-dev",
|
||||||
|
"type": "silverstripe-vendor-module",
|
||||||
|
"description": "This fake module uses a version of recipe testing 1 with a stability flag",
|
||||||
|
"homepage": "https://www.silverstripe.org",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"require": {
|
||||||
|
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"silverstripe/recipe-testing": "~1.8.0@stable"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "silverstripe/empty-require-dev",
|
||||||
|
"type": "silverstripe-vendor-module",
|
||||||
|
"description": "This fake module uses an exact version of recipe testing 2",
|
||||||
|
"homepage": "https://www.silverstripe.org",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"require": {
|
||||||
|
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"silverstripe/recipe-testing": "2.34.56"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "silverstripe/empty-require-dev",
|
||||||
|
"type": "silverstripe-vendor-module",
|
||||||
|
"description": "This fake module uses a star constraint of sminnee 5",
|
||||||
|
"homepage": "https://www.silverstripe.org",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"require": {
|
||||||
|
"silverstripe/recipe-cms": "4.4.x-dev as 4.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"sminnee/phpunit": "5.9.*"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user