2017-06-22 12:50:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Dev;
|
|
|
|
|
|
|
|
use SilverStripe\Core\CoreKernel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Kernel for running unit tests
|
|
|
|
*/
|
|
|
|
class TestKernel extends CoreKernel
|
|
|
|
{
|
2021-11-17 00:37:16 +01:00
|
|
|
|
2021-11-18 11:16:03 +01:00
|
|
|
/** @var string[] $ciConfigs */
|
|
|
|
private $ciConfigs = [];
|
2021-11-17 00:37:16 +01:00
|
|
|
|
|
|
|
|
2017-06-22 12:50:45 +02:00
|
|
|
public function __construct($basePath)
|
|
|
|
{
|
|
|
|
$this->setEnvironment(self::DEV);
|
|
|
|
parent::__construct($basePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset kernel between tests.
|
|
|
|
* Note: this avoids resetting services (See TestState for service specific reset)
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function reset()
|
|
|
|
{
|
|
|
|
$this->setEnvironment(self::DEV);
|
|
|
|
$this->bootPHP();
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function bootPHP()
|
|
|
|
{
|
|
|
|
parent::bootPHP();
|
|
|
|
|
|
|
|
// Set default timezone consistently to avoid NZ-specific dependencies
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getIncludeTests()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-11-17 00:37:16 +01:00
|
|
|
|
|
|
|
/**
|
2021-11-18 11:16:03 +01:00
|
|
|
* Set a list of CI configurations that should cause a module's test not to be added to a manifest
|
|
|
|
* @param string[] $ciConfigs
|
2022-10-13 03:49:15 +02:00
|
|
|
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
2021-11-17 00:37:16 +01:00
|
|
|
*/
|
2021-11-21 23:02:27 +01:00
|
|
|
public function setIgnoredCIConfigs(array $ciConfigs): self
|
2021-11-17 00:37:16 +01:00
|
|
|
{
|
2022-10-13 03:49:15 +02:00
|
|
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality');
|
2022-08-10 06:21:05 +02:00
|
|
|
|
2021-11-21 23:02:27 +01:00
|
|
|
$this->ciConfigs = $ciConfigs;
|
2021-11-17 00:37:16 +01:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2022-10-13 03:49:15 +02:00
|
|
|
/**
|
|
|
|
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
|
|
|
*/
|
2021-11-21 23:02:27 +01:00
|
|
|
protected function getIgnoredCIConfigs(): array
|
2021-11-17 00:37:16 +01:00
|
|
|
{
|
2022-10-13 03:49:15 +02:00
|
|
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality');
|
2022-08-10 06:21:05 +02:00
|
|
|
|
2021-11-21 23:02:27 +01:00
|
|
|
return $this->ciConfigs;
|
2021-11-17 00:37:16 +01:00
|
|
|
}
|
|
|
|
|
2017-06-22 12:50:45 +02:00
|
|
|
protected function bootErrorHandling()
|
|
|
|
{
|
|
|
|
// Leave phpunit to capture errors
|
|
|
|
restore_error_handler();
|
|
|
|
}
|
|
|
|
}
|