class TestInfoParsingTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.php \Drupal\Tests\simpletest\Unit\TestInfoParsingTest
@coversDefaultClass \Drupal\simpletest\TestDiscovery @group simpletest
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\simpletest\Unit\TestInfoParsingTest
Expanded class hierarchy of TestInfoParsingTest
File
- core/
modules/ simpletest/ tests/ src/ Unit/ TestInfoParsingTest.php, line 16 - Contains \Drupal\Tests\simpletest\Unit\TestInfoParsingTest.
Namespace
Drupal\Tests\simpletest\UnitView source
class TestInfoParsingTest extends UnitTestCase {
/**
* @covers ::getTestInfo
* @dataProvider infoParserProvider
*/
public function testTestInfoParser($expected, $classname, $doc_comment = NULL) {
$info = \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment);
$this
->assertEquals($expected, $info);
}
public function infoParserProvider() {
// A module provided unit test.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\Tests\\simpletest\\Unit\\TestInfoParsingTest',
'group' => 'PHPUnit',
'description' => 'Tests \\Drupal\\simpletest\\TestDiscovery.',
],
// Classname.
'Drupal\\Tests\\simpletest\\Unit\\TestInfoParsingTest',
];
// A core unit test.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\Tests\\Core\\DrupalTest',
'group' => 'PHPUnit',
'description' => 'Tests \\Drupal.',
],
// Classname.
'Drupal\\Tests\\Core\\DrupalTest',
];
// Functional PHPUnit test.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\Tests\\simpletest\\Functional\\BrowserTestBaseTest',
'group' => 'simpletest',
'description' => 'Tests BrowserTestBase functionality.',
],
// Classname.
'Drupal\\Tests\\simpletest\\Functional\\BrowserTestBaseTest',
];
// Simpletest classes can not be autoloaded in a PHPUnit test, therefore
// provide a docblock.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
],
// Classname.
'Drupal\\field\\Tests\\BulkDeleteTest',
// Doc block.
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @group field\n */\n ",
];
// Test with a different amount of leading spaces.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
],
// Classname.
'Drupal\\field\\Tests\\BulkDeleteTest',
// Doc block.
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @group field\n */\n ",
];
// Make sure that a "* @" inside a string does not get parsed as an
// annotation.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards. * @',
],
// Classname.
'Drupal\\field\\Tests\\BulkDeleteTest',
// Doc block.
"/**\n * Bulk delete storages and fields, and clean up afterwards. * @\n *\n * @group field\n */\n ",
];
// Multiple @group annotations.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'Test',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
],
// Classname.
'Drupal\\field\\Tests\\BulkDeleteTest',
// Doc block.
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @group Test\n * @group field\n */\n ",
];
// @dependencies annotation.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
'requires' => [
'module' => [
'test',
],
],
],
// Classname.
'Drupal\\field\\Tests\\BulkDeleteTest',
// Doc block.
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @dependencies test\n * @group field\n */\n ",
];
// Multiple @dependencies annotation.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
'requires' => [
'module' => [
'test',
'test1',
'test2',
],
],
],
// Classname.
'Drupal\\field\\Tests\\BulkDeleteTest',
// Doc block.
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @dependencies test, test1,test2\n * @group field\n */\n ",
];
// Multi-line summary line.
$tests[] = [
// Expected result.
[
'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.',
],
// Classname.
'Drupal\\field\\Tests\\BulkDeleteTest',
// Doc block.
"/**\n * Bulk delete storages and fields, and clean up afterwards. And the summary\n * line continues and there is no gap to the annotation.\n * @group field\n */\n ",
];
return $tests;
}
/**
* @covers ::getTestInfo
* @expectedException \Drupal\simpletest\Exception\MissingGroupException
* @expectedExceptionMessage Missing @group annotation in Drupal\field\Tests\BulkDeleteTest
*/
public function testTestInfoParserMissingGroup() {
$classname = 'Drupal\\field\\Tests\\BulkDeleteTest';
$doc_comment = <<<EOT
/**
* Bulk delete storages and fields, and clean up afterwards.
*/
EOT;
\Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment);
}
/**
* @covers ::getTestInfo
*/
public function testTestInfoParserMissingSummary() {
$classname = 'Drupal\\field\\Tests\\BulkDeleteTest';
$doc_comment = <<<EOT
/**
* @group field
*/
EOT;
$info = \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment);
$this
->assertEmpty($info['description']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TestInfoParsingTest:: |
public | function | ||
TestInfoParsingTest:: |
public | function | @covers ::getTestInfo @dataProvider infoParserProvider | |
TestInfoParsingTest:: |
public | function | @covers ::getTestInfo @expectedException \Drupal\simpletest\Exception\MissingGroupException @expectedExceptionMessage Missing @group annotation in Drupal\field\Tests\BulkDeleteTest | |
TestInfoParsingTest:: |
public | function | @covers ::getTestInfo | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 259 |