mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX illegalExtensions are optional, requiredExtensions are mandatory with useful error messages.
This commit is contained in:
parent
8c486da3df
commit
ede549a6ed
@ -352,22 +352,34 @@ class SapphireTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// Remove any illegal extensions that are present
|
||||
foreach ($this->illegalExtensions as $class => $extensions) {
|
||||
if (!class_exists($class)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($extensions as $extension) {
|
||||
if ($class::has_extension($extension)) {
|
||||
if (!isset($this->extensionsToReapply[$class])) {
|
||||
$this->extensionsToReapply[$class] = array();
|
||||
}
|
||||
$this->extensionsToReapply[$class][] = $extension;
|
||||
$class::remove_extension($extension);
|
||||
$isAltered = true;
|
||||
if (!class_exists($extension) || $class::has_extension($extension)) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($this->extensionsToReapply[$class])) {
|
||||
$this->extensionsToReapply[$class] = array();
|
||||
}
|
||||
$this->extensionsToReapply[$class][] = $extension;
|
||||
$class::remove_extension($extension);
|
||||
$isAltered = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Add any required extensions that aren't present
|
||||
foreach ($this->requiredExtensions as $class => $extensions) {
|
||||
if (!class_exists($class)) {
|
||||
$self = static::class;
|
||||
throw new LogicException("Test {$self} requires class {$class} which doesn't exist");
|
||||
}
|
||||
$this->extensionsToRemove[$class] = array();
|
||||
foreach ($extensions as $extension) {
|
||||
if (!class_exists($extension)) {
|
||||
$self = static::class;
|
||||
throw new LogicException("Test {$self} requires extension {$extension} which doesn't exist");
|
||||
}
|
||||
if (!$class::has_extension($extension)) {
|
||||
if (!isset($this->extensionsToRemove[$class])) {
|
||||
$this->extensionsToReapply[$class] = array();
|
||||
|
Loading…
Reference in New Issue
Block a user