Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347
This commit is contained in:
parent
2a9f1f148d
commit
fd3b12cf27
251 changed files with 5439 additions and 957 deletions
|
@ -134,7 +134,6 @@ class TestDiscovery {
|
|||
*
|
||||
* @todo Remove singular grouping; retain list of groups in 'group' key.
|
||||
* @see https://www.drupal.org/node/2296615
|
||||
* @todo Add base class groups 'Kernel' + 'Web', complementing 'PHPUnit'.
|
||||
*/
|
||||
public function getTestClasses($extension = NULL) {
|
||||
$reader = new SimpleAnnotationReader();
|
||||
|
@ -328,12 +327,13 @@ class TestDiscovery {
|
|||
// Concrete tests must have a group.
|
||||
throw new MissingGroupException(sprintf('Missing @group annotation in %s', $classname));
|
||||
}
|
||||
// Force all PHPUnit tests into the same group.
|
||||
if (static::isUnitTest($classname)) {
|
||||
$info['group'] = 'PHPUnit';
|
||||
$info['group'] = $annotations['group'];
|
||||
// Put PHPUnit test suites into their own custom groups.
|
||||
if ($testsuite = static::getPhpunitTestSuite($classname)) {
|
||||
$info['type'] = 'PHPUnit-' . $testsuite;
|
||||
}
|
||||
else {
|
||||
$info['group'] = $annotations['group'];
|
||||
$info['type'] = 'Simpletest';
|
||||
}
|
||||
|
||||
if (!empty($annotations['coversDefaultClass'])) {
|
||||
|
@ -414,26 +414,31 @@ class TestDiscovery {
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines if the provided classname is a unit test.
|
||||
* Determines the phpunit testsuite for a given classname.
|
||||
*
|
||||
* @param $classname
|
||||
* @param string $classname
|
||||
* The test classname.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the class is a unit test. FALSE if not.
|
||||
* @return string|false
|
||||
* The testsuite name or FALSE if its not a phpunit test.
|
||||
*/
|
||||
public static function isUnitTest($classname) {
|
||||
if (strpos($classname, 'Drupal\\Tests\\') === 0) {
|
||||
$namespace = explode('\\', $classname);
|
||||
$first_letter = Unicode::substr($namespace[2], 0, 1);
|
||||
if (Unicode::strtoupper($first_letter) === $first_letter) {
|
||||
// A core unit test.
|
||||
return TRUE;
|
||||
}
|
||||
elseif ($namespace[3] == 'Unit') {
|
||||
// A module unit test.
|
||||
return TRUE;
|
||||
public static function getPhpunitTestSuite($classname) {
|
||||
if (preg_match('/Drupal\\\\Tests\\\\Core\\\\(\w+)/', $classname, $matches)) {
|
||||
return 'Unit';
|
||||
}
|
||||
if (preg_match('/Drupal\\\\Tests\\\\Component\\\\(\w+)/', $classname, $matches)) {
|
||||
return 'Unit';
|
||||
}
|
||||
// Module tests.
|
||||
if (preg_match('/Drupal\\\\Tests\\\\(\w+)\\\\(\w+)/', $classname, $matches)) {
|
||||
return $matches[2];
|
||||
}
|
||||
// Core tests.
|
||||
elseif (preg_match('/Drupal\\\\(\w*)Tests\\\\/', $classname, $matches)) {
|
||||
if ($matches[1] == '') {
|
||||
return 'Unit';
|
||||
}
|
||||
return $matches[1];
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\Tests\simpletest\Unit;
|
||||
|
||||
use Drupal\simpletest\TestDiscovery;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
@ -30,8 +31,9 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
// Expected result.
|
||||
[
|
||||
'name' => 'Drupal\Tests\simpletest\Unit\TestInfoParsingTest',
|
||||
'group' => 'PHPUnit',
|
||||
'group' => 'simpletest',
|
||||
'description' => 'Tests \Drupal\simpletest\TestDiscovery.',
|
||||
'type' => 'PHPUnit-Unit',
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\Tests\simpletest\Unit\TestInfoParsingTest',
|
||||
|
@ -42,8 +44,9 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
// Expected result.
|
||||
[
|
||||
'name' => 'Drupal\Tests\Core\DrupalTest',
|
||||
'group' => 'PHPUnit',
|
||||
'group' => 'DrupalTest',
|
||||
'description' => 'Tests \Drupal.',
|
||||
'type' => 'PHPUnit-Unit',
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\Tests\Core\DrupalTest',
|
||||
|
@ -56,11 +59,25 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'name' => 'Drupal\Tests\simpletest\Functional\BrowserTestBaseTest',
|
||||
'group' => 'simpletest',
|
||||
'description' => 'Tests BrowserTestBase functionality.',
|
||||
'type' => 'PHPUnit-Functional',
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\Tests\simpletest\Functional\BrowserTestBaseTest',
|
||||
];
|
||||
|
||||
// kernel PHPUnit test.
|
||||
$tests['phpunit-kernel'] = [
|
||||
// Expected result.
|
||||
[
|
||||
'name' => '\Drupal\Tests\file\Kernel\FileItemValidationTest',
|
||||
'group' => 'file',
|
||||
'description' => 'Tests that files referenced in file and image fields are always validated.',
|
||||
'type' => 'PHPUnit-Kernel',
|
||||
],
|
||||
// Classname.
|
||||
'\Drupal\Tests\file\Kernel\FileItemValidationTest',
|
||||
];
|
||||
|
||||
// Simpletest classes can not be autoloaded in a PHPUnit test, therefore
|
||||
// provide a docblock.
|
||||
$tests[] = [
|
||||
|
@ -69,6 +86,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'name' => 'Drupal\field\Tests\BulkDeleteTest',
|
||||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
|
||||
'type' => 'Simpletest',
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
|
@ -88,6 +106,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'name' => 'Drupal\field\Tests\BulkDeleteTest',
|
||||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
|
||||
'type' => 'Simpletest'
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
|
@ -108,6 +127,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'name' => 'Drupal\field\Tests\BulkDeleteTest',
|
||||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards. * @',
|
||||
'type' => 'Simpletest'
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
|
@ -127,6 +147,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'name' => 'Drupal\field\Tests\BulkDeleteTest',
|
||||
'group' => 'Test',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
|
||||
'type' => 'Simpletest'
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
|
@ -148,6 +169,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
|
||||
'requires' => ['module' => ['test']],
|
||||
'type' => 'Simpletest'
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
|
@ -169,6 +191,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
|
||||
'requires' => ['module' => ['test', 'test1', 'test2']],
|
||||
'type' => 'Simpletest'
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
|
@ -189,6 +212,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
'name' => 'Drupal\field\Tests\BulkDeleteTest',
|
||||
'group' => 'field',
|
||||
'description' => 'Bulk delete storages and fields, and clean up afterwards. And the summary line continues and there is no gap to the annotation.',
|
||||
'type' => 'Simpletest'
|
||||
],
|
||||
// Classname.
|
||||
'Drupal\field\Tests\BulkDeleteTest',
|
||||
|
@ -232,4 +256,29 @@ EOT;
|
|||
$this->assertEmpty($info['description']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getPhpunitTestSuite
|
||||
* @dataProvider providerTestGetPhpunitTestSuite
|
||||
*/
|
||||
public function testGetPhpunitTestSuite($classname, $expected) {
|
||||
$this->assertEquals($expected, TestDiscovery::getPhpunitTestSuite($classname));
|
||||
}
|
||||
|
||||
public function providerTestGetPhpunitTestSuite() {
|
||||
$data = [];
|
||||
$data['simpletest-webtest'] = ['\Drupal\rest\Tests\NodeTest', FALSE];
|
||||
$data['simpletest-kerneltest'] = ['\Drupal\hal\Tests\FileNormalizeTest', FALSE];
|
||||
$data['module-unittest'] = [static::class, 'Unit'];
|
||||
$data['module-kerneltest'] = ['\Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest', 'Kernel'];
|
||||
$data['module-functionaltest'] = ['\Drupal\Tests\simpletest\Functional\BrowserTestBaseTest', 'Functional'];
|
||||
$data['module-functionaljavascripttest'] = ['\Drupal\Tests\toolbar\FunctionalJavascript\ToolbarIntegrationTest', 'FunctionalJavascript'];
|
||||
$data['core-unittest'] = ['\Drupal\Tests\ComposerIntegrationTest', 'Unit'];
|
||||
$data['core-unittest2'] = ['Drupal\Tests\Core\DrupalTest', 'Unit'];
|
||||
$data['core-kerneltest'] = ['\Drupal\KernelTests\KernelTestBaseTest', 'Kernel'];
|
||||
$data['core-functionaltest'] = ['\Drupal\FunctionalTests\ExampleTest', 'Functional'];
|
||||
$data['core-functionaljavascripttest'] = ['\Drupal\FunctionalJavascriptTests\ExampleTest', 'FunctionalJavascript'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue