API Deprecate PHPUnit 5.7 compatability hacks

This commit is contained in:
Guy Sartorelli 2022-08-10 16:21:05 +12:00
parent 7b0957709d
commit a7461a8ffa
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A
13 changed files with 56 additions and 0 deletions

View File

@ -378,9 +378,11 @@ abstract class BaseKernel implements Kernel
* The purpose of this method is to avoid loading PHPUnit test files with incompatible definitions. * The purpose of this method is to avoid loading PHPUnit test files with incompatible definitions.
* *
* @return string[] List of CI types to ignore as defined by `Module`. * @return string[] List of CI types to ignore as defined by `Module`.
* @deprecated 5.0.0
*/ */
protected function getIgnoredCIConfigs(): array protected function getIgnoredCIConfigs(): array
{ {
Deprecation::notice('5.0.0', 'This method will be removed in CMS 5');
return []; return [];
} }

View File

@ -124,6 +124,10 @@ class ClassLoader
*/ */
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = []) public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
foreach ($this->manifests as $manifest) { foreach ($this->manifests as $manifest) {
/** @var ClassManifest $instance */ /** @var ClassManifest $instance */
$instance = $manifest['instance']; $instance = $manifest['instance'];

View File

@ -11,6 +11,7 @@ use PhpParser\ParserFactory;
use PhpParser\ErrorHandler\ErrorHandler; use PhpParser\ErrorHandler\ErrorHandler;
use Psr\SimpleCache\CacheInterface; use Psr\SimpleCache\CacheInterface;
use SilverStripe\Core\Cache\CacheFactory; use SilverStripe\Core\Cache\CacheFactory;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\TestOnly; use SilverStripe\Dev\TestOnly;
/** /**
@ -280,6 +281,10 @@ class ClassManifest
*/ */
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = []) public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
$this->cache = $this->buildCache($includeTests); $this->cache = $this->buildCache($includeTests);
// Check if cache is safe to use // Check if cache is safe to use
@ -543,6 +548,10 @@ class ClassManifest
*/ */
public function regenerate($includeTests, array $ignoredCIConfigs = []) public function regenerate($includeTests, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
// Reset the manifest so stale info doesn't cause errors. // Reset the manifest so stale info doesn't cause errors.
$this->loadState([]); $this->loadState([]);
$this->roots = []; $this->roots = [];

View File

@ -331,9 +331,11 @@ class Module implements Serializable
* that is observed is `PHP` * that is observed is `PHP`
* @return array List of configuration aspects e.g.: `['PHP' => 'CI_PHPUNIT_NINE']` * @return array List of configuration aspects e.g.: `['PHP' => 'CI_PHPUNIT_NINE']`
* @internal * @internal
* @deprecated 5.0.0
*/ */
public function getCIConfig(): array public function getCIConfig(): array
{ {
Deprecation::notice('5.0.0', 'This method will be removed in CMS 5');
return [ return [
'PHP' => $this->getPhpCiConfig() 'PHP' => $this->getPhpCiConfig()
]; ];

View File

@ -2,6 +2,8 @@
namespace SilverStripe\Core\Manifest; namespace SilverStripe\Core\Manifest;
use SilverStripe\Dev\Deprecation;
/** /**
* Module manifest holder * Module manifest holder
*/ */
@ -95,6 +97,10 @@ class ModuleLoader
*/ */
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = []) public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
foreach ($this->manifests as $manifest) { foreach ($this->manifests as $manifest) {
$manifest->init($includeTests, $forceRegen, $ignoredCIConfigs); $manifest->init($includeTests, $forceRegen, $ignoredCIConfigs);
} }

View File

@ -7,6 +7,7 @@ use Psr\SimpleCache\CacheInterface;
use SilverStripe\Core\Cache\CacheFactory; use SilverStripe\Core\Cache\CacheFactory;
use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
/** /**
* A utility class which builds a manifest of configuration items * A utility class which builds a manifest of configuration items
@ -125,6 +126,10 @@ class ModuleManifest
*/ */
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = []) public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
// build cache from factory // build cache from factory
if ($this->cacheFactory) { if ($this->cacheFactory) {
$this->cache = $this->cacheFactory->create( $this->cache = $this->cacheFactory->create(
@ -167,6 +172,10 @@ class ModuleManifest
*/ */
public function regenerate($includeTests = false, array $ignoredCIConfigs = []) public function regenerate($includeTests = false, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
$this->modules = []; $this->modules = [];
$finder = new ManifestFileFinder(); $finder = new ManifestFileFinder();

View File

@ -6,6 +6,7 @@ use PHPUnit_Framework_Constraint;
use PHPUnit_Framework_ExpectationFailedException; use PHPUnit_Framework_ExpectationFailedException;
use PHPUnit\Framework\Constraint\Constraint; use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\ExpectationFailedException;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SSListExporter; use SilverStripe\Dev\SSListExporter;
use SilverStripe\Dev\TestOnly; use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\SS_List; use SilverStripe\ORM\SS_List;
@ -190,6 +191,8 @@ class SSListContains extends PHPUnit_Framework_Constraint implements TestOnly
public function __construct($matches) public function __construct($matches)
{ {
Deprecation::notice('5.0.0', 'This class will be removed in CMS 5', Deprecation::SCOPE_CLASS);
$this->exporter = new SSListExporter(); $this->exporter = new SSListExporter();
$this->matches = $matches; $this->matches = $matches;

View File

@ -6,6 +6,7 @@ use PHPUnit_Framework_Constraint;
use PHPUnit_Framework_ExpectationFailedException; use PHPUnit_Framework_ExpectationFailedException;
use PHPUnit\Framework\Constraint\Constraint; use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\ExpectationFailedException;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SSListExporter; use SilverStripe\Dev\SSListExporter;
use SilverStripe\Dev\TestOnly; use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\SS_List; use SilverStripe\ORM\SS_List;
@ -135,6 +136,7 @@ class SSListContainsOnlyMatchingItems extends PHPUnit_Framework_Constraint imple
public function __construct($match) public function __construct($match)
{ {
Deprecation::notice('5.0.0', 'This class will be removed in CMS 5', Deprecation::SCOPE_CLASS);
$this->exporter = new SSListExporter(); $this->exporter = new SSListExporter();
$this->constraint = new ViewableDataContains($match); $this->constraint = new ViewableDataContains($match);

View File

@ -7,6 +7,7 @@ use PHPUnit_Framework_ExpectationFailedException;
use PHPUnit_Util_InvalidArgumentHelper; use PHPUnit_Util_InvalidArgumentHelper;
use PHPUnit\Framework\Constraint\Constraint; use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\ExpectationFailedException;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\TestOnly; use SilverStripe\Dev\TestOnly;
use SilverStripe\View\ViewableData; use SilverStripe\View\ViewableData;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
@ -141,6 +142,7 @@ class ViewableDataContains extends PHPUnit_Framework_Constraint implements TestO
*/ */
public function __construct($match) public function __construct($match)
{ {
Deprecation::notice('5.0.0', 'This class will be removed in CMS 5', Deprecation::SCOPE_CLASS);
parent::__construct(); parent::__construct();
if (!is_array($match)) { if (!is_array($match)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory( throw PHPUnit_Util_InvalidArgumentHelper::factory(

View File

@ -546,6 +546,8 @@ class FunctionalTest extends SapphireTest implements TestOnly
protected function setUp() protected function setUp()
{ {
Deprecation::notice('5.0.0', 'This class will be removed in CMS 5', Deprecation::SCOPE_CLASS);
parent::setUp(); parent::setUp();
// Skip calling FunctionalTest directly. // Skip calling FunctionalTest directly.

View File

@ -1619,6 +1619,8 @@ class SapphireTest extends PHPUnit_Framework_TestCase implements TestOnly
*/ */
protected function setUp() protected function setUp()
{ {
Deprecation::notice('5.0.0', 'This class will be removed in CMS 5', Deprecation::SCOPE_CLASS);
if (!defined('FRAMEWORK_PATH')) { if (!defined('FRAMEWORK_PATH')) {
trigger_error( trigger_error(
'Missing constants, did you remember to include the test bootstrap in your phpunit.xml file?', 'Missing constants, did you remember to include the test bootstrap in your phpunit.xml file?',

View File

@ -53,12 +53,16 @@ class TestKernel extends CoreKernel
*/ */
public function setIgnoredCIConfigs(array $ciConfigs): self public function setIgnoredCIConfigs(array $ciConfigs): self
{ {
Deprecation::notice('5.0.0', 'This method will be removed in CMS 5');
$this->ciConfigs = $ciConfigs; $this->ciConfigs = $ciConfigs;
return $this; return $this;
} }
protected function getIgnoredCIConfigs(): array protected function getIgnoredCIConfigs(): array
{ {
Deprecation::notice('5.0.0', 'This method will be removed in CMS 5');
return $this->ciConfigs; return $this->ciConfigs;
} }

View File

@ -6,6 +6,7 @@ use Psr\SimpleCache\CacheInterface;
use SilverStripe\Core\Cache\CacheFactory; use SilverStripe\Core\Cache\CacheFactory;
use SilverStripe\Core\Manifest\ManifestFileFinder; use SilverStripe\Core\Manifest\ManifestFileFinder;
use SilverStripe\Core\Manifest\ModuleLoader; use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Dev\Deprecation;
/** /**
* A class which builds a manifest of all themes (which is really just a directory called "templates") * A class which builds a manifest of all themes (which is really just a directory called "templates")
@ -77,6 +78,10 @@ class ThemeManifest implements ThemeList
*/ */
public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = []) public function init($includeTests = false, $forceRegen = false, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
// build cache from factory // build cache from factory
if ($this->cacheFactory) { if ($this->cacheFactory) {
$this->cache = $this->cacheFactory->create( $this->cache = $this->cacheFactory->create(
@ -134,6 +139,10 @@ class ThemeManifest implements ThemeList
*/ */
public function regenerate($includeTests = false, array $ignoredCIConfigs = []) public function regenerate($includeTests = false, array $ignoredCIConfigs = [])
{ {
if (!empty($ignoredCIConfigs)) {
Deprecation::notice('5.0.0', 'The $ignoredCIConfigs parameter will be removed in CMS 5');
}
$finder = new ManifestFileFinder(); $finder = new ManifestFileFinder();
$finder->setOptions([ $finder->setOptions([
'include_themes' => false, 'include_themes' => false,