View source
<?php
namespace Drupal\Tests\simpletest\Unit;
use Drupal\Tests\UnitTestCase;
class TestInfoParsingTest extends UnitTestCase {
public function testTestInfoParser($expected, $classname, $doc_comment = NULL) {
$info = \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment);
$this
->assertEquals($expected, $info);
}
public function infoParserProvider() {
$tests[] = [
[
'name' => 'Drupal\\Tests\\simpletest\\Unit\\TestInfoParsingTest',
'group' => 'PHPUnit',
'description' => 'Tests \\Drupal\\simpletest\\TestDiscovery.',
],
'Drupal\\Tests\\simpletest\\Unit\\TestInfoParsingTest',
];
$tests[] = [
[
'name' => 'Drupal\\Tests\\Core\\DrupalTest',
'group' => 'PHPUnit',
'description' => 'Tests \\Drupal.',
],
'Drupal\\Tests\\Core\\DrupalTest',
];
$tests[] = [
[
'name' => 'Drupal\\Tests\\simpletest\\Functional\\BrowserTestBaseTest',
'group' => 'simpletest',
'description' => 'Tests BrowserTestBase functionality.',
],
'Drupal\\Tests\\simpletest\\Functional\\BrowserTestBaseTest',
];
$tests[] = [
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
],
'Drupal\\field\\Tests\\BulkDeleteTest',
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @group field\n */\n ",
];
$tests[] = [
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
],
'Drupal\\field\\Tests\\BulkDeleteTest',
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @group field\n */\n ",
];
$tests[] = [
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards. * @',
],
'Drupal\\field\\Tests\\BulkDeleteTest',
"/**\n * Bulk delete storages and fields, and clean up afterwards. * @\n *\n * @group field\n */\n ",
];
$tests[] = [
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'Test',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
],
'Drupal\\field\\Tests\\BulkDeleteTest',
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @group Test\n * @group field\n */\n ",
];
$tests[] = [
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
'requires' => [
'module' => [
'test',
],
],
],
'Drupal\\field\\Tests\\BulkDeleteTest',
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @dependencies test\n * @group field\n */\n ",
];
$tests[] = [
[
'name' => 'Drupal\\field\\Tests\\BulkDeleteTest',
'group' => 'field',
'description' => 'Bulk delete storages and fields, and clean up afterwards.',
'requires' => [
'module' => [
'test',
'test1',
'test2',
],
],
],
'Drupal\\field\\Tests\\BulkDeleteTest',
"/**\n * Bulk delete storages and fields, and clean up afterwards.\n *\n * @dependencies test, test1,test2\n * @group field\n */\n ",
];
$tests[] = [
[
'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.',
],
'Drupal\\field\\Tests\\BulkDeleteTest',
"/**\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;
}
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);
}
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']);
}
}