Remove TestListener and rely on PHPUnits APIs

This commit is contained in:
Daniel Hensby 2017-03-25 00:17:26 +13:00 committed by Sam Minnée
parent fbddd84cea
commit ac075eaf0b
75 changed files with 198 additions and 363 deletions

View File

@ -143,8 +143,9 @@ end of each test.
} }
} }
`tearDownOnce` and `setUpOnce` can be used to run code just once for the file rather than before and after each `tearDownAfterClass` and `setUpBeforeClass` can be used to run code just once for the file rather than before and after
individual test case. each individual test case. Remember to class the parent method in each method to ensure the core boot-strapping of tests
takes place.
:::php :::php
<?php <?php
@ -153,16 +154,16 @@ individual test case.
class PageTest extends SapphireTest class PageTest extends SapphireTest
{ {
function setUpOnce() public static function setUpBeforeClass()
{ {
parent::setUpOnce(); parent::setUpBeforeClass();
// .. // ..
} }
public function tearDownOnce() public static function tearDownAfterClass()
{ {
parent::tearDownOnce(); parent::tearDownAfterClass();
// .. // ..
} }
@ -179,9 +180,9 @@ If you need to make changes to `Config` (or `Injector`) for each test (or the wh
It's important to remember that the `parent::setUp();` functions will need to be called first to ensure the nesting feature works as expected. It's important to remember that the `parent::setUp();` functions will need to be called first to ensure the nesting feature works as expected.
:::php :::php
public function setUpOnce() public static function setUpBeforeClass()
{ {
parent::setUpOnce(); parent::setUpBeforeClass();
//this will remain for the whole suite and be removed for any other tests //this will remain for the whole suite and be removed for any other tests
Config::inst()->update('ClassName', 'var_name', 'var_value'); Config::inst()->update('ClassName', 'var_name', 'var_value');
} }

View File

@ -18,6 +18,7 @@ guide developers in preparing existing 3.x code for compatibility with 4.0
* [i18n](#overview-i18n) * [i18n](#overview-i18n)
* [Cache](#overview-cache) * [Cache](#overview-cache)
* [Email and Mailer](#overview-mailer) * [Email and Mailer](#overview-mailer)
* [SapphireTest](#overview-testing)
* [Commit History](#commit-history) * [Commit History](#commit-history)
## <a name="overview"></a>Highlights of major changes ## <a name="overview"></a>Highlights of major changes
@ -1703,3 +1704,12 @@ After (`mysite/_config/config.yml`):
* `$email->setTemplate()` renamed to `$email->setHTMLTemplate()` * `$email->setTemplate()` renamed to `$email->setHTMLTemplate()`
* Added `$email->setPlainTemplate` for rendering plain versions of email * Added `$email->setPlainTemplate` for rendering plain versions of email
* `$email->populateTemplate()` has been replaced with `$email->setData()` * `$email->populateTemplate()` has been replaced with `$email->setData()`
### <a name="overview-testing"></a>SapphireTest
* `setUpOnce` removed. Please use `setUpBeforeClass`
* `tearDownOnce` removed. Please use `tearDownAfterClass`
* `TestListener` class removed
* `SapphireTest::$requiredExtensions` renamed to `SapphireTest::$required_extensions` and made static
* `SapphireTest::$extraDataObjects` renamed to `SapphireTest::$extra_dataobjects` and made static
* `SapphireTest::$extraControllers` renamed to `SapphireTest::$extra_controllers` and made static

View File

@ -25,10 +25,6 @@
<directory>versioned/tests/php</directory> <directory>versioned/tests/php</directory>
</testsuite> </testsuite>
<listeners>
<listener class="SilverStripe\Dev\TestListener" />
</listeners>
<groups> <groups>
<exclude> <exclude>
<group>sanitychecks</group> <group>sanitychecks</group>

View File

@ -117,8 +117,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
* The keys of the are the classes that the extensions can't be applied the extensions to, and * The keys of the are the classes that the extensions can't be applied the extensions to, and
* the values are an array of illegal extensions on that class. * the values are an array of illegal extensions on that class.
*/ */
protected $illegalExtensions = array( protected static $illegal_extensions = [];
);
/** /**
* A list of extensions that must be applied during the execution of this run. If they are * A list of extensions that must be applied during the execution of this run. If they are
@ -132,15 +131,14 @@ class SapphireTest extends PHPUnit_Framework_TestCase
* array("MyTreeDataObject" => array("Versioned", "Hierarchy")) * array("MyTreeDataObject" => array("Versioned", "Hierarchy"))
* </code> * </code>
*/ */
protected $requiredExtensions = array( protected static $required_extensions = [];
);
/** /**
* By default, the test database won't contain any DataObjects that have the interface TestOnly. * By default, the test database won't contain any DataObjects that have the interface TestOnly.
* This variable lets you define additional TestOnly DataObjects to set up for this test. * This variable lets you define additional TestOnly DataObjects to set up for this test.
* Set it to an array of DataObject subclass names. * Set it to an array of DataObject subclass names.
*/ */
protected $extraDataObjects = array(); protected static $extra_dataobjects = [];
/** /**
* List of class names of {@see Controller} objects to register routes for * List of class names of {@see Controller} objects to register routes for
@ -148,7 +146,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
* *
* @var array * @var array
*/ */
protected $extraControllers = []; protected static $extra_controllers = [];
/** /**
* We need to disabling backing up of globals to avoid overriding * We need to disabling backing up of globals to avoid overriding
@ -159,12 +157,14 @@ class SapphireTest extends PHPUnit_Framework_TestCase
protected $backupGlobals = false; protected $backupGlobals = false;
/** /**
* Helper arrays for illegalExtensions/requiredExtensions code * Helper arrays for illegal_extensions/required_extensions code
*/ */
private $extensionsToReapply = array(), $extensionsToRemove = array(); private static $extensions_to_reapply = [];
private static $extensions_to_remove = [];
/** /**
* Check flushables on setupOnce() * Check flushables on setupBeforeClass()
* *
* @var bool * @var bool
*/ */
@ -334,10 +334,10 @@ class SapphireTest extends PHPUnit_Framework_TestCase
* This is different to {@link setUp()}, which gets called once * This is different to {@link setUp()}, which gets called once
* per method. Useful to initialize expensive operations which * per method. Useful to initialize expensive operations which
* don't change state for any called method inside the test, * don't change state for any called method inside the test,
* e.g. dynamically adding an extension. See {@link tearDownOnce()} * e.g. dynamically adding an extension. See {@link teardownAfterClass()}
* for tearing down the state again. * for tearing down the state again.
*/ */
public function setUpOnce() public static function setUpBeforeClass()
{ {
static::start(); static::start();
@ -351,40 +351,40 @@ class SapphireTest extends PHPUnit_Framework_TestCase
} }
// Remove any illegal extensions that are present // Remove any illegal extensions that are present
foreach ($this->illegalExtensions as $class => $extensions) { foreach (static::$illegal_extensions as $class => $extensions) {
if (!class_exists($class)) { if (!class_exists($class)) {
continue; continue;
} }
foreach ($extensions as $extension) { foreach ($extensions as $extension) {
if (!class_exists($extension) || $class::has_extension($extension)) { if (!class_exists($extension) ||$class::has_extension($extension)) {
continue; continue;
}if (!isset(static::$extensions_to_reapply[$class])) {
static::$extensions_to_reapply[$class] = array();
} }
if (!isset($this->extensionsToReapply[$class])) { static::$extensions_to_reapply[$class][] = $extension;
$this->extensionsToReapply[$class] = array();
}
$this->extensionsToReapply[$class][] = $extension;
$class::remove_extension($extension); $class::remove_extension($extension);
$isAltered = true; $isAltered = true;
} }
} }
// Add any required extensions that aren't present // Add any required extensions that aren't present
foreach ($this->requiredExtensions as $class => $extensions) { foreach (static::$required_extensions as $class => $extensions) {
if (!class_exists($class)) { if (!class_exists($class)) {
$self = static::class; $self = static::class;
throw new LogicException("Test {$self} requires class {$class} which doesn't exist"); throw new LogicException("Test {$self} requires class {$class} which doesn't exist");
} }
$this->extensionsToRemove[$class] = array(); static::$extensions_to_remove[$class] = array();
foreach ($extensions as $extension) { foreach ($extensions as $extension) {
if (!class_exists($extension)) { if (!class_exists($extension)) {
$self = static::class; $self = static::class;
throw new LogicException("Test {$self} requires extension {$extension} which doesn't exist"); throw new LogicException("Test {$self} requires extension {$extension} which doesn't exist");
} }
if (!$class::has_extension($extension)) { if (!$class::has_extension($extension)) {
if (!isset($this->extensionsToRemove[$class])) { if (!isset(static::$extensions_to_remove[$class])) {
$this->extensionsToReapply[$class] = array(); static::$extensions_to_reapply[$class] = array();
} }
$this->extensionsToRemove[$class][] = $extension; static::$extensions_to_remove[$class][] = $extension;
$class::add_extension($extension); $class::add_extension($extension);
$isAltered = true; $isAltered = true;
} }
@ -392,12 +392,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase
} }
// If we have made changes to the extensions present, then migrate the database schema. // If we have made changes to the extensions present, then migrate the database schema.
if ($isAltered || $this->extensionsToReapply || $this->extensionsToRemove || $this->getExtraDataObjects()) { if ($isAltered || static::$extensions_to_reapply || static::$extensions_to_remove || static::getExtraDataObjects()) {
DataObject::reset(); DataObject::reset();
if (!self::using_temp_db()) { if (!self::using_temp_db()) {
self::create_temp_db(); self::create_temp_db();
} }
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
// clear singletons, they're caching old extension info // clear singletons, they're caching old extension info
// which is used in DatabaseAdmin->doBuild() // which is used in DatabaseAdmin->doBuild()
@ -419,23 +419,23 @@ class SapphireTest extends PHPUnit_Framework_TestCase
/** /**
* tearDown method that's called once per test class rather once per test method. * tearDown method that's called once per test class rather once per test method.
*/ */
public function tearDownOnce() public static function tearDownAfterClass()
{ {
// If we have made changes to the extensions present, then migrate the database schema. // If we have made changes to the extensions present, then migrate the database schema.
if ($this->extensionsToReapply || $this->extensionsToRemove) { if (static::$extensions_to_reapply || static::$extensions_to_remove) {
// @todo: This isn't strictly necessary to restore extensions, but only to ensure that // @todo: This isn't strictly necessary to restore extensions, but only to ensure that
// Object::$extra_methods is properly flushed. This should be replaced with a simple // Object::$extra_methods is properly flushed. This should be replaced with a simple
// flush mechanism for each $class. // flush mechanism for each $class.
// //
// Remove extensions added for testing // Remove extensions added for testing
foreach ($this->extensionsToRemove as $class => $extensions) { foreach (static::$extensions_to_remove as $class => $extensions) {
foreach ($extensions as $extension) { foreach ($extensions as $extension) {
$class::remove_extension($extension); $class::remove_extension($extension);
} }
} }
// Reapply ones removed // Reapply ones removed
foreach ($this->extensionsToReapply as $class => $extensions) { foreach (static::$extensions_to_reapply as $class => $extensions) {
foreach ($extensions as $extension) { foreach ($extensions as $extension) {
$class::add_extension($extension); $class::add_extension($extension);
} }
@ -443,13 +443,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase
} }
//unnest injector / config now that the test suite is over //unnest injector / config now that the test suite is over
// this will reset all the extensions on the object too (see setUpOnce) // this will reset all the extensions on the object too (see setUpBeforeClass)
Injector::unnest(); Injector::unnest();
Config::unnest(); Config::unnest();
$extraDataObjects = $this->getExtraDataObjects(); $extraDataObjects = static::getExtraDataObjects();
if (!empty($this->extensionsToReapply) || !empty($this->extensionsToRemove) || !empty($extraDataObjects)) { if (!empty(static::$extensions_to_reapply) || !empty(static::$extensions_to_remove) || !empty($extraDataObjects)) {
$this->resetDBSchema(); static::resetDBSchema();
} }
} }
@ -1034,7 +1034,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
); );
ClassLoader::instance()->pushManifest($classManifest, false); ClassLoader::instance()->pushManifest($classManifest, false);
SapphireTest::set_test_class_manifest($classManifest); static::set_test_class_manifest($classManifest);
ThemeResourceLoader::instance()->addSet('$default', new ThemeManifest( ThemeResourceLoader::instance()->addSet('$default', new ThemeManifest(
BASE_PATH, BASE_PATH,
@ -1123,9 +1123,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
$dbConn->selectDatabase($dbname, true); $dbConn->selectDatabase($dbname, true);
/** @var static $st */ static::resetDBSchema();
$st = Injector::inst()->create(__CLASS__);
$st->resetDBSchema();
// Reinstate PHPUnit error handling // Reinstate PHPUnit error handling
set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError')); set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'));
@ -1153,7 +1151,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase
* Reset the testing database's schema. * Reset the testing database's schema.
* @param bool $includeExtraDataObjects If true, the extraDataObjects tables will also be included * @param bool $includeExtraDataObjects If true, the extraDataObjects tables will also be included
*/ */
public function resetDBSchema($includeExtraDataObjects = false) public static function resetDBSchema($includeExtraDataObjects = false)
{ {
if (self::using_temp_db()) { if (self::using_temp_db()) {
DataObject::reset(); DataObject::reset();
@ -1161,12 +1159,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild() // clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
Injector::inst()->unregisterAllObjects(); Injector::inst()->unregisterAllObjects();
$dataClasses = ClassInfo::subclassesFor('SilverStripe\\ORM\\DataObject'); $dataClasses = ClassInfo::subclassesFor(DataObject::class);
array_shift($dataClasses); array_shift($dataClasses);
DB::quiet(); DB::quiet();
$schema = DB::get_schema(); $schema = DB::get_schema();
$extraDataObjects = $includeExtraDataObjects ? $this->getExtraDataObjects() : null; $extraDataObjects = $includeExtraDataObjects ? static::getExtraDataObjects() : null;
$schema->schemaUpdate(function () use ($dataClasses, $extraDataObjects) { $schema->schemaUpdate(function () use ($dataClasses, $extraDataObjects) {
foreach ($dataClasses as $dataClass) { foreach ($dataClasses as $dataClass) {
// Check if class exists before trying to instantiate - this sidesteps any manifest weirdness // Check if class exists before trying to instantiate - this sidesteps any manifest weirdness
@ -1306,12 +1304,11 @@ class SapphireTest extends PHPUnit_Framework_TestCase
/** /**
* Return all extra objects to scaffold for this test * Return all extra objects to scaffold for this test
*
* @return array * @return array
*/ */
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return $this->extraDataObjects; return static::$extra_dataobjects;
} }
/** /**
@ -1319,9 +1316,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase
* *
* @return array * @return array
*/ */
protected function getExtraControllers() protected static function getExtraControllers()
{ {
return $this->extraControllers; return static::$extra_controllers;
} }
/** /**

View File

@ -1,84 +0,0 @@
<?php
namespace SilverStripe\Dev;
use PHPUnit_Framework_TestListener;
use PHPUnit_Framework_TestSuite;
use PHPUnit_Framework_Test;
use Exception;
use PHPUnit_Framework_AssertionFailedError;
/**
* Inject SilverStripe 'setUpOnce' and 'tearDownOnce' unittest extension methods into PHPUnit.
*
* This is already in later SilverStripe 2.4 versions, but having it here extends compatibility to older versions.
*/
class SilverStripeListener implements PHPUnit_Framework_TestListener
{
protected function isValidClass($name)
{
return (class_exists($name) && is_subclass_of($name, 'SilverStripe\\Dev\\SapphireTest'));
}
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$name = $suite->getName();
if (!$this->isValidClass($name)) {
return;
}
/** @var SapphireTest $class */
$class = new $name();
$class->setUpOnce();
}
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$name = $suite->getName();
if (!$this->isValidClass($name)) {
return;
}
/** @var SapphireTest $class */
$class = new $name();
$class->tearDownOnce();
}
public function startTest(PHPUnit_Framework_Test $test)
{
}
public function endTest(PHPUnit_Framework_Test $test, $time)
{
}
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
{
}
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
}
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
}
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
// Stub out to support PHPUnit 3.8
}
}

View File

@ -1,92 +0,0 @@
<?php
namespace SilverStripe\Dev;
use PHPUnit_Framework_TestListener;
use PHPUnit_Framework_Test;
use PHPUnit_Framework_AssertionFailedError;
use PHPUnit_Framework_TestSuite;
use Exception;
/**
* Necessary to call setUpOnce() and tearDownOnce() on {@link SapphireTest}
* classes. This feature doesn't exist in PHPUnit in the same way
* (setUpBeforeClass() and tearDownAfterClass() are just called statically).
*
* @see http://www.phpunit.de/manual/3.5/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
*/
class TestListener implements PHPUnit_Framework_TestListener
{
/**
* @var SapphireTest
*/
protected $class;
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
{
}
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
}
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
}
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
}
public function startTest(PHPUnit_Framework_Test $test)
{
}
public function endTest(PHPUnit_Framework_Test $test, $time)
{
}
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$name = $suite->getName();
if (!$this->isValidClass($name)) {
return;
}
$this->class = new $name();
$this->class->setUpOnce();
}
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$name = $suite->getName();
if (!$this->isValidClass($name)) {
return;
}
$this->class->tearDownOnce();
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 3.8.0
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
// Stub out to support PHPUnit 3.8
}
/**
* @param string $name Class Name
* @return boolean
*/
protected function isValidClass($name)
{
return (class_exists($name) && is_subclass_of($name, 'SilverStripe\\Dev\\SapphireTest'));
}
}

View File

@ -34,7 +34,7 @@ class ControllerTest extends FunctionalTest
protected $depSettings = null; protected $depSettings = null;
protected $extraControllers = [ protected static $extra_controllers = [
AccessBaseController::class, AccessBaseController::class,
AccessSecuredController::class, AccessSecuredController::class,
AccessWildcardSecuredController::class, AccessWildcardSecuredController::class,

View File

@ -7,12 +7,12 @@ use SilverStripe\Dev\TestOnly;
class AccessBaseController extends Controller implements TestOnly class AccessBaseController extends Controller implements TestOnly
{ {
private static $allowed_actions = array(); private static $allowed_actions = [];
private static $url_segment = 'AccessBaseController'; private static $url_segment = 'AccessBaseController';
private static $extensions = [ private static $extensions = [
AccessBaseControllerExtension::class AccessBaseControllerExtension::class,
]; ];
// Denied for all // Denied for all

View File

@ -28,8 +28,8 @@ class DirectorTest extends SapphireTest
protected $originalSession = array(); protected $originalSession = array();
protected $extraControllers = [ protected static $extra_controllers = [
TestController::class TestController::class,
]; ];
protected function setUp() protected function setUp()
@ -306,12 +306,14 @@ class DirectorTest extends SapphireTest
*/ */
public function testQueryIsEnvironment() public function testQueryIsEnvironment()
{ {
if (!isset($_SESSION)) {
$_SESSION = [];
}
// Reset // Reset
unset($_SESSION['isDev']); unset($_SESSION['isDev']);
unset($_SESSION['isLive']); unset($_SESSION['isLive']);
unset($_GET['isTest']); unset($_GET['isTest']);
unset($_GET['isDev']); unset($_GET['isDev']);
$_SESSION = $_SESSION ?: array();
// Test isDev=1 // Test isDev=1
$_GET['isDev'] = '1'; $_GET['isDev'] = '1';

View File

@ -24,7 +24,7 @@ class RequestHandlingTest extends FunctionalTest
{ {
protected static $fixture_file = null; protected static $fixture_file = null;
protected $illegalExtensions = array( protected static $illegal_extensions = array(
// Suppress CMS error page handling // Suppress CMS error page handling
Controller::class => array( Controller::class => array(
ErrorPageControllerExtension::class, ErrorPageControllerExtension::class,
@ -37,7 +37,7 @@ class RequestHandlingTest extends FunctionalTest
), ),
); );
protected $extraControllers = [ protected static $extra_controllers = [
TestController::class, TestController::class,
AllowedController::class, AllowedController::class,
ControllerFormWithAllowedActions::class, ControllerFormWithAllowedActions::class,

View File

@ -20,7 +20,7 @@ use SilverStripe\View\ViewableData;
class ClassInfoTest extends SapphireTest class ClassInfoTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
BaseClass::class, BaseClass::class,
BaseDataClass::class, BaseDataClass::class,
ChildClass::class, ChildClass::class,

View File

@ -8,7 +8,10 @@ use SilverStripe\Dev\Tests\BulkLoaderResultTest\Player;
class BulkLoaderResultTest extends SapphireTest class BulkLoaderResultTest extends SapphireTest
{ {
protected $extraDataObjects = array(Player::class);
protected static $extra_dataobjects = [
Player::class,
];
protected function setUp() protected function setUp()
{ {

View File

@ -17,7 +17,7 @@ class CsvBulkLoaderTest extends SapphireTest
protected static $fixture_file = 'CsvBulkLoaderTest.yml'; protected static $fixture_file = 'CsvBulkLoaderTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Team::class, Team::class,
Player::class, Player::class,
PlayerContract::class, PlayerContract::class,

View File

@ -17,7 +17,7 @@ class FixtureBlueprintTest extends SapphireTest
protected $usesDatabase = true; protected $usesDatabase = true;
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestDataObject::class, TestDataObject::class,
DataObjectRelation::class, DataObjectRelation::class,
TestSiteTree::class, TestSiteTree::class,

View File

@ -13,7 +13,7 @@ class FixtureFactoryTest extends SapphireTest
protected $usesDatabase = true; protected $usesDatabase = true;
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestDataObject::class, TestDataObject::class,
DataObjectRelation::class DataObjectRelation::class
); );

View File

@ -15,7 +15,7 @@ use SilverStripe\Control\Director;
class YamlFixtureTest extends SapphireTest class YamlFixtureTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestDataObject::class, TestDataObject::class,
DataObjectRelation::class, DataObjectRelation::class,
); );

View File

@ -13,7 +13,7 @@ class CheckboxFieldTest extends SapphireTest
protected $usesDatabase = true; protected $usesDatabase = true;
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Article::class, Article::class,
); );

View File

@ -23,7 +23,7 @@ class CheckboxSetFieldTest extends SapphireTest
protected static $fixture_file = 'CheckboxSetFieldTest.yml'; protected static $fixture_file = 'CheckboxSetFieldTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Article::class, Article::class,
Tag::class, Tag::class,
); );

View File

@ -14,7 +14,7 @@ use SilverStripe\Forms\Tests\EmailFieldTest\TestValidator;
class EmailFieldTest extends FunctionalTest class EmailFieldTest extends FunctionalTest
{ {
protected $extraControllers = [ protected static $extra_controllers = [
EmailFieldTest\TestController::class, EmailFieldTest\TestController::class,
]; ];

View File

@ -13,13 +13,13 @@ use SilverStripe\Versioned\Versioned;
class FormFactoryTest extends SapphireTest class FormFactoryTest extends SapphireTest
{ {
protected $extraDataObjects = [ protected static $extra_dataobjects = [
TestObject::class, TestObject::class,
]; ];
protected static $fixture_file = 'FormFactoryTest.yml'; protected static $fixture_file = 'FormFactoryTest.yml';
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
// Prevent setup breaking if versioned module absent // Prevent setup breaking if versioned module absent
if (class_exists(Versioned::class)) { if (class_exists(Versioned::class)) {

View File

@ -17,7 +17,7 @@ use ReflectionClass;
class FormFieldTest extends SapphireTest class FormFieldTest extends SapphireTest
{ {
protected $requiredExtensions = array( protected static $required_extensions = array(
FormField::class => array( FormField::class => array(
TestExtension::class TestExtension::class
) )

View File

@ -20,13 +20,13 @@ class FormScaffolderTest extends SapphireTest
protected static $fixture_file = 'FormScaffolderTest.yml'; protected static $fixture_file = 'FormScaffolderTest.yml';
protected $requiredExtensions = [ protected static $required_extensions = [
Article::class => [ Article::class => [
ArticleExtension::class ArticleExtension::class
] ]
]; ];
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Article::class, Article::class,
Tag::class, Tag::class,
Author::class, Author::class,

View File

@ -35,12 +35,12 @@ class FormTest extends FunctionalTest
protected static $fixture_file = 'FormTest.yml'; protected static $fixture_file = 'FormTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Player::class, Player::class,
Team::class, Team::class,
); );
protected $extraControllers = [ protected static $extra_controllers = [
TestController::class, TestController::class,
ControllerWithSecurityToken::class, ControllerWithSecurityToken::class,
ControllerWithStrictPostCheck::class, ControllerWithStrictPostCheck::class,

View File

@ -19,15 +19,15 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest
protected static $fixture_file = 'GridFieldTest.yml'; protected static $fixture_file = 'GridFieldTest.yml';
protected $extraDataObjects = [ protected static $extra_dataobjects = [
Team::class, Team::class,
Cheerleader::class, Cheerleader::class,
Player::class, Player::class,
Permissions::class Permissions::class
]; ];
protected $extraControllers = [ protected static $extra_controllers = [
TestController::class TestController::class,
]; ];
public function testScaffoldSearchFields() public function testScaffoldSearchFields()

View File

@ -28,32 +28,32 @@ class GridFieldDeleteActionTest extends SapphireTest
/** /**
* @var ArrayList * @var ArrayList
*/ */
protected $list; protected $list;
/** /**
* @var GridField * @var GridField
*/ */
protected $gridField; protected $gridField;
/** /**
* @var Form * @var Form
*/ */
protected $form; protected $form;
/** /**
* @var string * @var string
*/ */
protected static $fixture_file = 'GridFieldActionTest.yml'; protected static $fixture_file = 'GridFieldActionTest.yml';
/** /**
* @var array * @var array
*/ */
protected $extraDataObjects = [ protected static $extra_dataobjects = [
Team::class, Team::class,
Cheerleader::class, Cheerleader::class,
Player::class, Player::class,
Permissions::class Permissions::class,
]; ];
protected function setUp() protected function setUp()

View File

@ -21,13 +21,13 @@ class GridFieldDetailFormTest extends FunctionalTest
protected static $fixture_file = 'GridFieldDetailFormTest.yml'; protected static $fixture_file = 'GridFieldDetailFormTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Person::class, Person::class,
PeopleGroup::class, PeopleGroup::class,
Category::class, Category::class,
); );
protected $extraControllers = [ protected static $extra_controllers = [
CategoryController::class, CategoryController::class,
TestController::class, TestController::class,
GroupController::class, GroupController::class,

View File

@ -23,32 +23,32 @@ class GridFieldEditButtonTest extends SapphireTest
/** /**
* @var ArrayList * @var ArrayList
*/ */
protected $list; protected $list;
/** /**
* @var GridField * @var GridField
*/ */
protected $gridField; protected $gridField;
/** /**
* @var Form * @var Form
*/ */
protected $form; protected $form;
/** /**
* @var string * @var string
*/ */
protected static $fixture_file = 'GridFieldActionTest.yml'; protected static $fixture_file = 'GridFieldActionTest.yml';
/** /**
* @var array * @var array
*/ */
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Team::class, Team::class,
Cheerleader::class, Cheerleader::class,
Player::class, Player::class,
Permissions::class Permissions::class,
); );
protected function setUp() protected function setUp()

View File

@ -24,9 +24,9 @@ class GridFieldExportButtonTest extends SapphireTest
protected static $fixture_file = 'GridFieldExportButtonTest.yml'; protected static $fixture_file = 'GridFieldExportButtonTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Team::class, Team::class,
NoView::class NoView::class,
); );
protected function setUp() protected function setUp()

View File

@ -43,7 +43,7 @@ class GridFieldPaginatorTest extends FunctionalTest
/** /**
* @var array * @var array
*/ */
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Team::class, Team::class,
Player::class, Player::class,
Cheerleader::class, Cheerleader::class,

View File

@ -15,8 +15,8 @@ use SilverStripe\Forms\Tests\GridField\GridFieldPrintButtonTest\TestObject;
class GridFieldPrintButtonTest extends SapphireTest class GridFieldPrintButtonTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestObject::class TestObject::class,
); );
protected function setUp() protected function setUp()

View File

@ -21,12 +21,12 @@ class GridFieldSortableHeaderTest extends SapphireTest
protected static $fixture_file = 'GridFieldSortableHeaderTest.yml'; protected static $fixture_file = 'GridFieldSortableHeaderTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
Team::class, Team::class,
TeamGroup::class, TeamGroup::class,
Cheerleader::class, Cheerleader::class,
CheerleaderHat::class, CheerleaderHat::class,
Mom::class Mom::class,
); );
/** /**

View File

@ -29,7 +29,7 @@ use SilverStripe\Security\Member;
class GridFieldTest extends SapphireTest class GridFieldTest extends SapphireTest
{ {
protected $extraDataObjects = [ protected static $extra_dataobjects = [
Permissions::class, Permissions::class,
Cheerleader::class, Cheerleader::class,
Player::class, Player::class,

View File

@ -11,8 +11,8 @@ use SilverStripe\Forms\Tests\GridField\GridField_URLHandlerTest\TestController;
class GridField_URLHandlerTest extends FunctionalTest class GridField_URLHandlerTest extends FunctionalTest
{ {
protected $extraControllers = [ protected static $extra_controllers = [
TestController::class TestController::class,
]; ];
public function testFormSubmission() public function testFormSubmission()

View File

@ -29,13 +29,15 @@ class HTMLEditorFieldTest extends FunctionalTest
protected static $use_draft_site = true; protected static $use_draft_site = true;
protected $requiredExtensions = array( protected static $required_extensions= array(
HTMLEditorField_Toolbar::class => array( HTMLEditorField_Toolbar::class => array(
DummyMediaFormFieldExtension::class DummyMediaFormFieldExtension::class,
) ),
); );
protected $extraDataObjects = array(TestObject::class); protected static $extra_dataobjects = [
TestObject::class,
];
protected function setUp() protected function setUp()
{ {

View File

@ -17,10 +17,10 @@ class ListboxFieldTest extends SapphireTest
protected static $fixture_file = 'ListboxFieldTest.yml'; protected static $fixture_file = 'ListboxFieldTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestObject::class, TestObject::class,
Article::class, Article::class,
Tag::class Tag::class,
); );
public function testFieldWithManyManyRelationship() public function testFieldWithManyManyRelationship()

View File

@ -12,7 +12,7 @@ use SilverStripe\Forms\MoneyField;
class MoneyFieldTest extends SapphireTest class MoneyFieldTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestObject::class, TestObject::class,
CustomSetter_Object::class, CustomSetter_Object::class,
); );

View File

@ -9,7 +9,7 @@ class ComponentSetTest extends SapphireTest
protected static $fixture_file = 'ComponentSetTest.yml'; protected static $fixture_file = 'ComponentSetTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
ComponentSetTest\Player::class, ComponentSetTest\Player::class,
ComponentSetTest\Team::class, ComponentSetTest\Team::class,
); );

View File

@ -9,7 +9,7 @@ use SilverStripe\Dev\SapphireTest;
class DBClassNameTest extends SapphireTest class DBClassNameTest extends SapphireTest
{ {
protected $extraDataObjects = [ protected static $extra_dataobjects = [
DBClassNameTest\TestObject::class, DBClassNameTest\TestObject::class,
DBClassNameTest\ObjectSubClass::class, DBClassNameTest\ObjectSubClass::class,
DBClassNameTest\ObjectSubSubClass::class, DBClassNameTest\ObjectSubSubClass::class,

View File

@ -9,7 +9,7 @@ use SilverStripe\Dev\SapphireTest;
class DBCompositeTest extends SapphireTest class DBCompositeTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
DBCompositeTest\TestObject::class, DBCompositeTest\TestObject::class,
DBCompositeTest\SubclassedDBFieldObject::class, DBCompositeTest\SubclassedDBFieldObject::class,
); );

View File

@ -13,7 +13,7 @@ class DBMoneyTest extends SapphireTest
protected static $fixture_file = 'DBMoneyTest.yml'; protected static $fixture_file = 'DBMoneyTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
DBMoneyTest\TestObject::class, DBMoneyTest\TestObject::class,
DBMoneyTest\TestObjectSubclass::class, DBMoneyTest\TestObjectSubclass::class,
); );

View File

@ -15,7 +15,7 @@ class DataExtensionTest extends SapphireTest
{ {
protected static $fixture_file = 'DataExtensionTest.yml'; protected static $fixture_file = 'DataExtensionTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
DataExtensionTest\TestMember::class, DataExtensionTest\TestMember::class,
DataExtensionTest\Player::class, DataExtensionTest\Player::class,
DataExtensionTest\RelatedObject::class, DataExtensionTest\RelatedObject::class,
@ -25,7 +25,7 @@ class DataExtensionTest extends SapphireTest
DataExtensionTest\CMSFieldsGrandChild::class DataExtensionTest\CMSFieldsGrandChild::class
); );
protected $requiredExtensions = [ protected static $required_extensions = [
DataObject::class => [ DataObject::class => [
DataExtensionTest\AppliedToDO::class, DataExtensionTest\AppliedToDO::class,
] ]
@ -116,7 +116,7 @@ class DataExtensionTest extends SapphireTest
); );
// Now that we've just added the extension, we need to rebuild the database // Now that we've just added the extension, we need to rebuild the database
$this->resetDBSchema(true); static::resetDBSchema(true);
// Create a test record with extended fields, writing to the DB // Create a test record with extended fields, writing to the DB
$player = new DataExtensionTest\Player(); $player = new DataExtensionTest\Player();

View File

@ -24,7 +24,7 @@ class DataListTest extends SapphireTest
// Borrow the model from DataObjectTest // Borrow the model from DataObjectTest
protected static $fixture_file = 'DataObjectTest.yml'; protected static $fixture_file = 'DataObjectTest.yml';
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -11,7 +11,7 @@ class DataObjectDuplicationTest extends SapphireTest
protected $usesDatabase = true; protected $usesDatabase = true;
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
DataObjectDuplicationTest\Class1::class, DataObjectDuplicationTest\Class1::class,
DataObjectDuplicationTest\Class2::class, DataObjectDuplicationTest\Class2::class,
DataObjectDuplicationTest\Class3::class DataObjectDuplicationTest\Class3::class

View File

@ -15,7 +15,7 @@ class DataObjectLazyLoadingTest extends SapphireTest
'DataObjectTest.yml', 'DataObjectTest.yml',
); );
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -13,12 +13,12 @@ use SilverStripe\ORM\Tests\DataObjectSchemaGenerationTest\TestObject;
class DataObjectSchemaGenerationTest extends SapphireTest class DataObjectSchemaGenerationTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestObject::class, TestObject::class,
TestIndexObject::class TestIndexObject::class
); );
public function setUpOnce() public static function setUpBeforeClass()
{ {
// enable fulltext option on this table // enable fulltext option on this table
@ -27,7 +27,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest
array(MySQLSchemaManager::ID => 'ENGINE=MyISAM') array(MySQLSchemaManager::ID => 'ENGINE=MyISAM')
); );
parent::setUpOnce(); parent::setUpBeforeClass();
} }
/** /**

View File

@ -23,7 +23,7 @@ use SilverStripe\ORM\Tests\DataObjectSchemaTest\WithRelation;
*/ */
class DataObjectSchemaTest extends SapphireTest class DataObjectSchemaTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
// Classes in base namespace // Classes in base namespace
BaseClass::class, BaseClass::class,
BaseDataClass::class, BaseDataClass::class,

View File

@ -53,7 +53,7 @@ class DataObjectTest extends SapphireTest
DataObjectTest\Sortable::class, DataObjectTest\Sortable::class,
); );
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -16,7 +16,7 @@ class DataQueryTest extends SapphireTest
protected static $fixture_file = 'DataQueryTest.yml'; protected static $fixture_file = 'DataQueryTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
DataQueryTest\ObjectA::class, DataQueryTest\ObjectA::class,
DataQueryTest\ObjectB::class, DataQueryTest\ObjectB::class,
DataQueryTest\ObjectC::class, DataQueryTest\ObjectC::class,
@ -284,7 +284,7 @@ class DataQueryTest extends SapphireTest
$query = new DataQuery(DataQueryTest\ObjectF::class); $query = new DataQuery(DataQueryTest\ObjectF::class);
$query->where(DB::get_conn()->comparisonClause('"SortOrder"', '2')); $query->where(DB::get_conn()->comparisonClause('"SortOrder"', '2'));
$this->assertGreaterThan(0, $query->count(), "Couldn't find SortOrder"); $this->assertGreaterThan(0, $query->count(), "Couldn't find SortOrder");
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
public function testComparisonClauseDateFull() public function testComparisonClauseDateFull()
@ -293,7 +293,7 @@ class DataQueryTest extends SapphireTest
$query = new DataQuery(DataQueryTest\ObjectF::class); $query = new DataQuery(DataQueryTest\ObjectF::class);
$query->where(DB::get_conn()->comparisonClause('"MyDate"', '1988-03-04%')); $query->where(DB::get_conn()->comparisonClause('"MyDate"', '1988-03-04%'));
$this->assertGreaterThan(0, $query->count(), "Couldn't find MyDate"); $this->assertGreaterThan(0, $query->count(), "Couldn't find MyDate");
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
public function testComparisonClauseDateStartsWith() public function testComparisonClauseDateStartsWith()
@ -302,7 +302,7 @@ class DataQueryTest extends SapphireTest
$query = new DataQuery(DataQueryTest\ObjectF::class); $query = new DataQuery(DataQueryTest\ObjectF::class);
$query->where(DB::get_conn()->comparisonClause('"MyDate"', '1988%')); $query->where(DB::get_conn()->comparisonClause('"MyDate"', '1988%'));
$this->assertGreaterThan(0, $query->count(), "Couldn't find MyDate"); $this->assertGreaterThan(0, $query->count(), "Couldn't find MyDate");
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
public function testComparisonClauseDateStartsPartial() public function testComparisonClauseDateStartsPartial()
@ -311,7 +311,7 @@ class DataQueryTest extends SapphireTest
$query = new DataQuery(DataQueryTest\ObjectF::class); $query = new DataQuery(DataQueryTest\ObjectF::class);
$query->where(DB::get_conn()->comparisonClause('"MyDate"', '%03-04%')); $query->where(DB::get_conn()->comparisonClause('"MyDate"', '%03-04%'));
$this->assertGreaterThan(0, $query->count(), "Couldn't find MyDate"); $this->assertGreaterThan(0, $query->count(), "Couldn't find MyDate");
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
public function testComparisonClauseTextCaseInsensitive() public function testComparisonClauseTextCaseInsensitive()
@ -320,7 +320,7 @@ class DataQueryTest extends SapphireTest
$query = new DataQuery(DataQueryTest\ObjectF::class); $query = new DataQuery(DataQueryTest\ObjectF::class);
$query->where(DB::get_conn()->comparisonClause('"MyString"', 'helloworld')); $query->where(DB::get_conn()->comparisonClause('"MyString"', 'helloworld'));
$this->assertGreaterThan(0, $query->count(), "Couldn't find MyString"); $this->assertGreaterThan(0, $query->count(), "Couldn't find MyString");
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
public function testComparisonClauseTextCaseSensitive() public function testComparisonClauseTextCaseSensitive()
@ -333,7 +333,7 @@ class DataQueryTest extends SapphireTest
$query2 = new DataQuery(DataQueryTest\ObjectF::class); $query2 = new DataQuery(DataQueryTest\ObjectF::class);
$query2->where(DB::get_conn()->comparisonClause('"MyString"', 'helloworld', false, false, true)); $query2->where(DB::get_conn()->comparisonClause('"MyString"', 'helloworld', false, false, true));
$this->assertEquals(0, $query2->count(), "Found mystring. Shouldn't be able too."); $this->assertEquals(0, $query2->count(), "Found mystring. Shouldn't be able too.");
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
/** /**

View File

@ -15,7 +15,7 @@ use SilverStripe\ORM\Tests\DatabaseTest\MyObject;
class DatabaseTest extends SapphireTest class DatabaseTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
MyObject::class, MyObject::class,
); );
@ -37,7 +37,7 @@ class DatabaseTest extends SapphireTest
'Field is renamed to _obsolete_<fieldname> through dontRequireField()' 'Field is renamed to _obsolete_<fieldname> through dontRequireField()'
); );
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
public function testRenameField() public function testRenameField()
@ -59,7 +59,7 @@ class DatabaseTest extends SapphireTest
'Old fieldname isnt preserved through renameField()' 'Old fieldname isnt preserved through renameField()'
); );
$this->resetDBSchema(true); static::resetDBSchema(true);
} }
public function testMySQLCreateTableOptions() public function testMySQLCreateTableOptions()

View File

@ -11,7 +11,7 @@ class DecimalTest extends SapphireTest
protected $testDataObject; protected $testDataObject;
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
DecimalTest\TestObject::class DecimalTest\TestObject::class
); );

View File

@ -11,7 +11,7 @@ use SilverStripe\ORM\Tests\Filters\FulltextFilterTest\TestObject;
class FulltextFilterTest extends SapphireTest class FulltextFilterTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TestObject::class TestObject::class
); );

View File

@ -17,7 +17,7 @@ class SearchFilterApplyRelationTest extends SapphireTest
protected static $fixture_file = 'SearchFilterApplyRelationTest.yml'; protected static $fixture_file = 'SearchFilterApplyRelationTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
SearchFilterApplyRelationTest\TestObject::class, SearchFilterApplyRelationTest\TestObject::class,
SearchFilterApplyRelationTest\HasOneParent::class, SearchFilterApplyRelationTest\HasOneParent::class,
SearchFilterApplyRelationTest\HasOneChild::class, SearchFilterApplyRelationTest\HasOneChild::class,

View File

@ -11,7 +11,7 @@ class HasManyListTest extends SapphireTest
// Borrow the model from DataObjectTest // Borrow the model from DataObjectTest
protected static $fixture_file = 'DataObjectTest.yml'; protected static $fixture_file = 'DataObjectTest.yml';
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -12,13 +12,13 @@ class HierarchyTest extends SapphireTest
{ {
protected static $fixture_file = 'HierarchyTest.yml'; protected static $fixture_file = 'HierarchyTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
HierarchyTest\TestObject::class, HierarchyTest\TestObject::class,
HierarchyTest\HideTestObject::class, HierarchyTest\HideTestObject::class,
HierarchyTest\HideTestSubObject::class, HierarchyTest\HideTestSubObject::class,
); );
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
// Prevent setup breaking if versioned module absent // Prevent setup breaking if versioned module absent
if (class_exists(Versioned::class)) { if (class_exists(Versioned::class)) {

View File

@ -13,7 +13,7 @@ class ManyManyListExtensionTest extends SapphireTest
protected static $fixture_file = 'ManyManyListExtensionTest.yml'; protected static $fixture_file = 'ManyManyListExtensionTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
ManyManyListTest\IndirectPrimary::class, ManyManyListTest\IndirectPrimary::class,
ManyManyListTest\Secondary::class, ManyManyListTest\Secondary::class,
ManyManyListTest\SecondarySub::class ManyManyListTest\SecondarySub::class

View File

@ -20,7 +20,7 @@ class ManyManyListTest extends SapphireTest
ManyManyListTest\Product::class, ManyManyListTest\Product::class,
]; ];
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -11,7 +11,7 @@ class ManyManyThroughListTest extends SapphireTest
{ {
protected static $fixture_file = 'ManyManyThroughListTest.yml'; protected static $fixture_file = 'ManyManyThroughListTest.yml';
protected $extraDataObjects = [ protected static $extra_dataobjects = [
ManyManyThroughListTest\Item::class, ManyManyThroughListTest\Item::class,
ManyManyThroughListTest\JoinObject::class, ManyManyThroughListTest\JoinObject::class,
ManyManyThroughListTest\TestObject::class ManyManyThroughListTest\TestObject::class

View File

@ -14,7 +14,7 @@ class MapTest extends SapphireTest
// Borrow the model from DataObjectTest // Borrow the model from DataObjectTest
protected static $fixture_file = 'DataObjectTest.yml'; protected static $fixture_file = 'DataObjectTest.yml';
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -14,7 +14,7 @@ class MySQLDatabaseTest extends SapphireTest
protected static $fixture_file = 'MySQLDatabaseTest.yml'; protected static $fixture_file = 'MySQLDatabaseTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
MySQLDatabaseTest\Data::class MySQLDatabaseTest\Data::class
); );

View File

@ -13,7 +13,7 @@ class PDODatabaseTest extends SapphireTest
protected static $fixture_file = 'MySQLDatabaseTest.yml'; protected static $fixture_file = 'MySQLDatabaseTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
MySQLDatabaseTest\Data::class MySQLDatabaseTest\Data::class
); );

View File

@ -18,7 +18,7 @@ class PaginatedListTest extends SapphireTest
protected static $fixture_file = 'DataObjectTest.yml'; protected static $fixture_file = 'DataObjectTest.yml';
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -19,7 +19,7 @@ class PolymorphicHasManyListTest extends SapphireTest
// Borrow the model from DataObjectTest // Borrow the model from DataObjectTest
protected static $fixture_file = 'DataObjectTest.yml'; protected static $fixture_file = 'DataObjectTest.yml';
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return array_merge( return array_merge(
DataObjectTest::$extra_data_objects, DataObjectTest::$extra_data_objects,

View File

@ -15,7 +15,7 @@ use SilverStripe\ORM\Tests\SQLInsertTest\SQLInsertTestBase;
class SQLInsertTest extends SapphireTest class SQLInsertTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
SQLInsertTestBase::class SQLInsertTestBase::class
); );

View File

@ -15,7 +15,7 @@ class SQLSelectTest extends SapphireTest
protected static $fixture_file = 'SQLSelectTest.yml'; protected static $fixture_file = 'SQLSelectTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
SQLSelectTest\TestObject::class, SQLSelectTest\TestObject::class,
SQLSelectTest\TestBase::class, SQLSelectTest\TestBase::class,
SQLSelectTest\TestChild::class SQLSelectTest\TestChild::class

View File

@ -15,7 +15,7 @@ class SQLUpdateTest extends SapphireTest
public static $fixture_file = 'SQLUpdateTest.yml'; public static $fixture_file = 'SQLUpdateTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
SQLUpdateTest\TestBase::class, SQLUpdateTest\TestBase::class,
SQLUpdateTest\TestChild::class SQLUpdateTest\TestChild::class
); );

View File

@ -14,7 +14,7 @@ class SearchContextTest extends SapphireTest
protected static $fixture_file = 'SearchContextTest.yml'; protected static $fixture_file = 'SearchContextTest.yml';
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
SearchContextTest\Person::class, SearchContextTest\Person::class,
SearchContextTest\Book::class, SearchContextTest\Book::class,
SearchContextTest\Company::class, SearchContextTest\Company::class,

View File

@ -9,7 +9,7 @@ use SilverStripe\Dev\SapphireTest;
class TransactionTest extends SapphireTest class TransactionTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
TransactionTest\TestObject::class TransactionTest\TestObject::class
); );

View File

@ -9,7 +9,7 @@ class UnsavedRelationListTest extends SapphireTest
{ {
protected static $fixture_file = 'UnsavedRelationListTest.yml'; protected static $fixture_file = 'UnsavedRelationListTest.yml';
protected $extraDataObjects = [ protected static $extra_dataobjects = [
UnsavedRelationListTest\TestObject::class UnsavedRelationListTest\TestObject::class
]; ];

View File

@ -19,7 +19,7 @@ class BasicAuthTest extends FunctionalTest
protected static $fixture_file = 'BasicAuthTest.yml'; protected static $fixture_file = 'BasicAuthTest.yml';
protected $extraControllers = [ protected static $extra_controllers = [
ControllerSecuredWithPermission::class, ControllerSecuredWithPermission::class,
ControllerSecuredWithoutPermission::class, ControllerSecuredWithoutPermission::class,
]; ];

View File

@ -16,7 +16,7 @@ class GroupTest extends FunctionalTest
protected static $fixture_file = 'GroupTest.yml'; protected static $fixture_file = 'GroupTest.yml';
protected $extraDataObjects = [ protected static $extra_dataobjects = [
TestMember::class TestMember::class
]; ];

View File

@ -27,7 +27,7 @@ class MemberTest extends FunctionalTest
protected $orig = array(); protected $orig = array();
protected $illegalExtensions = array( protected static $illegal_extensions = array(
Member::class => array( Member::class => array(
// TODO Coupling with modules, this should be resolved by automatically // TODO Coupling with modules, this should be resolved by automatically
// removing all applied extensions before a unit test // removing all applied extensions before a unit test

View File

@ -40,7 +40,7 @@ class SecurityTest extends FunctionalTest
protected $priorRememberUsername = null; protected $priorRememberUsername = null;
protected $extraControllers = [ protected static $extra_controllers = [
SecurityTest\NullController::class, SecurityTest\NullController::class,
SecurityTest\SecuredController::class, SecurityTest\SecuredController::class,
]; ];
@ -663,14 +663,14 @@ class SecurityTest extends FunctionalTest
// and has all columns present in the ORM // and has all columns present in the ORM
/** /**
* @skipUpgrade * @skipUpgrade
*/ */
DB::get_schema()->renameField('Member', 'Email', 'Email_renamed'); DB::get_schema()->renameField('Member', 'Email', 'Email_renamed');
// Email column is now missing, which means we're not ready to do permission checks // Email column is now missing, which means we're not ready to do permission checks
$this->assertFalse(Security::database_is_ready()); $this->assertFalse(Security::database_is_ready());
// Rebuild the database (which re-adds the Email column), and try again // Rebuild the database (which re-adds the Email column), and try again
$this->resetDBSchema(true); static::resetDBSchema(true);
$this->assertTrue(Security::database_is_ready()); $this->assertTrue(Security::database_is_ready());
Security::$force_database_is_ready = $old; Security::$force_database_is_ready = $old;

View File

@ -15,11 +15,11 @@ use Symfony\Component\Cache\Simple\NullCache;
class SSViewerCacheBlockTest extends SapphireTest class SSViewerCacheBlockTest extends SapphireTest
{ {
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
SSViewerCacheBlockTest\TestModel::class SSViewerCacheBlockTest\TestModel::class
); );
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
$classes = parent::getExtraDataObjects(); $classes = parent::getExtraDataObjects();

View File

@ -41,7 +41,7 @@ class SSViewerTest extends SapphireTest
*/ */
protected $oldServer = array(); protected $oldServer = array();
protected $extraDataObjects = array( protected static $extra_dataobjects = array(
SSViewerTest\TestObject::class, SSViewerTest\TestObject::class,
); );

View File

@ -50,7 +50,7 @@ trait i18nTestManifest
*/ */
protected $moduleManifests = 0; protected $moduleManifests = 0;
protected function getExtraDataObjects() protected static function getExtraDataObjects()
{ {
return [ return [
TestDataObject::class, TestDataObject::class,