class TestSuiteBaseTest
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php \Drupal\Tests\Core\Test\TestSuiteBaseTest
- 8.9.x core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php \Drupal\Tests\Core\Test\TestSuiteBaseTest
- 11.x core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php \Drupal\Tests\Core\Test\TestSuiteBaseTest
@coversDefaultClass \Drupal\Tests\TestSuites\TestSuiteBase
@group TestSuite
Hierarchy
- class \Drupal\Tests\Core\Test\TestSuiteBaseTest extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait
Expanded class hierarchy of TestSuiteBaseTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Test/ TestSuiteBaseTest.php, line 21
Namespace
Drupal\Tests\Core\TestView source
class TestSuiteBaseTest extends TestCase {
use ExpectDeprecationTrait;
/**
* Helper method to set up the file system.
*
* @return array[]
* A Drupal filesystem suitable for use with vfsStream.
*/
protected function getFilesystem() {
return [
'core' => [
'modules' => [],
'profiles' => [],
'tests' => [
'Drupal' => [
'NotUnitTests' => [
'CoreNotUnitTest.php' => '<?php',
],
'Tests' => [
'CoreUnitTest.php' => '<?php',
// Ensure that the following files are not found as tests.
'Listeners' => [
'Listener.php' => '<?php',
'Legacy' => [
'Listener.php' => '<?php',
],
],
],
],
],
],
];
}
/**
* @return array[]
* Test data for testAddTestsBySuiteNamespaceCore(). An array of arrays:
* - A filesystem array for vfsStream.
* - The sub-namespace of the test suite.
* - The array of tests expected to be discovered.
*/
public function provideCoreTests() {
$filesystem = $this->getFilesystem();
return [
'unit-tests' => [
$filesystem,
'Unit',
[
'Drupal\\Tests\\CoreUnitTest' => 'vfs://root/core/tests/Drupal/Tests/CoreUnitTest.php',
],
],
'not-unit-tests' => [
$filesystem,
'NotUnit',
[
'Drupal\\NotUnitTests\\CoreNotUnitTest' => 'vfs://root/core/tests/Drupal/NotUnitTests/CoreNotUnitTest.php',
],
],
];
}
/**
* Tests for special case behavior of unit test suite namespaces in core.
*
* @group legacy
*
* @covers ::addTestsBySuiteNamespace
*
* @dataProvider provideCoreTests
*/
public function testAddTestsBySuiteNamespaceCore($filesystem, $suite_namespace, $expected_tests) : void {
$this->expectDeprecation('Drupal\\Tests\\Core\\Test\\StubTestSuiteBase is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement and test discovery will be handled differently in PHPUnit 10. See https://www.drupal.org/node/3405829');
// Set up the file system.
$vfs = vfsStream::setup('root');
vfsStream::create($filesystem, $vfs);
// Make a stub suite base to test.
$stub = new StubTestSuiteBase('test_me');
// Access addTestsBySuiteNamespace().
$ref_add_tests = new \ReflectionMethod($stub, 'addTestsBySuiteNamespace');
// Invoke addTestsBySuiteNamespace().
$ref_add_tests->invokeArgs($stub, [
vfsStream::url('root'),
$suite_namespace,
]);
// Determine if we loaded the expected test files.
$this->assertEquals($expected_tests, $stub->testFiles);
}
/**
* Tests the assumption that local time is in 'Australia/Sydney'.
*/
public function testLocalTimeZone() : void {
// The 'Australia/Sydney' time zone is set in core/tests/bootstrap.php
$this->assertEquals('Australia/Sydney', date_default_timezone_get());
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
TestSuiteBaseTest::getFilesystem | protected | function | Helper method to set up the file system. |
TestSuiteBaseTest::provideCoreTests | public | function | |
TestSuiteBaseTest::testAddTestsBySuiteNamespaceCore | public | function | Tests for special case behavior of unit test suite namespaces in core. |
TestSuiteBaseTest::testLocalTimeZone | public | function | Tests the assumption that local time is in 'Australia/Sydney'. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.