updated core

This commit is contained in:
Bachir Soussi Chiadmi
2018-01-24 13:36:32 +01:00
parent cd7dea45a9
commit f9374cf96d
1997 changed files with 5175 additions and 127715 deletions
+3 -3
View File
@@ -6,8 +6,8 @@ package: Core
# core: 8.x
configure: simpletest.settings
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -10,7 +10,7 @@ use Drupal\Tests\block\Traits\BlockCreationTrait as BaseBlockCreationTrait;
* This trait is meant to be used only by test classes.
*
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
* Drupal\Tests\AssertHelperTrait instead.
* \Drupal\Tests\block\Traits\BlockCreationTrait instead.
*
* @see https://www.drupal.org/node/2884454
*/
@@ -10,7 +10,7 @@ use Drupal\Tests\node\Traits\ContentTypeCreationTrait as BaseContentTypeCreation
* This trait is meant to be used only by test classes.
*
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
* Drupal\Tests\ContentTypeCreationTrait instead.
* \Drupal\Tests\node\Traits\ContentTypeCreationTrait instead.
*
* @see https://www.drupal.org/node/2884454
*/
@@ -226,7 +226,6 @@ EOD;
$this->kernel->shutdown();
$this->kernel->boot();
// Save the original site directory path, so that extensions in the
// site-specific directory can still be discovered in the test site
// environment.
@@ -10,7 +10,7 @@ use Drupal\Tests\node\Traits\NodeCreationTrait as BaseNodeCreationTrait;
* This trait is meant to be used only by test classes.
*
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
* Drupal\Tests\NodeCreationTrait instead.
* \Drupal\Tests\node\Traits\NodeCreationTrait instead.
*
* @see https://www.drupal.org/node/2884454
*/
@@ -49,7 +49,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv
/**
* {@inheritdoc}
*/
public function preLoadRoutes($names){
public function preLoadRoutes($names) {
return $this->lazyLoadItself()->preLoadRoutes($names);
}
+2
View File
@@ -45,6 +45,8 @@ abstract class TestBase {
/**
* Time limit for the test.
*
* @var int
*/
protected $timeLimit = 500;
@@ -1,27 +0,0 @@
<?php
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\WebTestBase;
/**
* This test will check SimpleTest's treatment of hook_install during setUp.
* Image module is used for test.
*
* @group simpletest
*/
class FolderTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('image');
function testFolderSetup() {
$directory = file_default_scheme() . '://styles';
$this->assertTrue(file_prepare_directory($directory, FALSE), 'Directory created.');
}
}
@@ -36,6 +36,8 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
* contained in the Testing profile.
*
* @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
*
* @var string
*/
protected $profile = 'testing';
@@ -1,78 +0,0 @@
<?php
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests the SimpleTest email capturing logic, the assertMail assertion and the
* drupalGetMails function.
*
* @group simpletest
*/
class MailCaptureTest extends WebTestBase {
/**
* Test to see if the wrapper function is executed correctly.
*/
function testMailSend() {
// Create an email.
$subject = $this->randomString(64);
$body = $this->randomString(128);
$message = array(
'id' => 'drupal_mail_test',
'headers' => array('Content-type' => 'text/html'),
'subject' => $subject,
'to' => 'foobar@example.com',
'body' => $body,
);
// Before we send the email, drupalGetMails should return an empty array.
$captured_emails = $this->drupalGetMails();
$this->assertEqual(count($captured_emails), 0, 'The captured emails queue is empty.', 'Email');
// Send the email.
\Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'simpletest', 'key' => 'drupal_mail_test'))->mail($message);
// Ensure that there is one email in the captured emails array.
$captured_emails = $this->drupalGetMails();
$this->assertEqual(count($captured_emails), 1, 'One email was captured.', 'Email');
// Assert that the email was sent by iterating over the message properties
// and ensuring that they are captured intact.
foreach ($message as $field => $value) {
$this->assertMail($field, $value, format_string('The email was sent and the value for property @field is intact.', array('@field' => $field)), 'Email');
}
// Send additional emails so more than one email is captured.
for ($index = 0; $index < 5; $index++) {
$message = array(
'id' => 'drupal_mail_test_' . $index,
'headers' => array('Content-type' => 'text/html'),
'subject' => $this->randomString(64),
'to' => $this->randomMachineName(32) . '@example.com',
'body' => $this->randomString(512),
);
\Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'drupal_mail_test', 'key' => $index))->mail($message);
}
// There should now be 6 emails captured.
$captured_emails = $this->drupalGetMails();
$this->assertEqual(count($captured_emails), 6, 'All emails were captured.', 'Email');
// Test different ways of getting filtered emails via drupalGetMails().
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test'));
$this->assertEqual(count($captured_emails), 1, 'Only one email is returned when filtering by id.', 'Email');
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject));
$this->assertEqual(count($captured_emails), 1, 'Only one email is returned when filtering by id and subject.', 'Email');
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test', 'subject' => $subject, 'from' => 'this_was_not_used@example.com'));
$this->assertEqual(count($captured_emails), 0, 'No emails are returned when querying with an unused from address.', 'Email');
// Send the last email again, so we can confirm that the
// drupalGetMails-filter correctly returns all emails with a given
// property/value.
\Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'drupal_mail_test', 'key' => $index))->mail($message);
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test_4'));
$this->assertEqual(count($captured_emails), 2, 'All emails with the same id are returned when filtering by id.', 'Email');
}
}
@@ -1,22 +0,0 @@
<?php
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\WebTestBase;
/**
* This test should not load since it requires a module that is not found.
*
* @group simpletest
* @dependencies simpletest_missing_module
*/
class MissingDependentModuleUnitTest extends WebTestBase {
/**
* Ensure that this test will not be loaded despite its dependency.
*/
function testFail() {
$this->fail('Running test with missing required module.');
}
}
@@ -1,64 +0,0 @@
<?php
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Verifies that tests in other installation profiles are found.
*
* @group simpletest
* @see SimpleTestInstallationProfileModuleTestsTestCase
*/
class OtherInstallationProfileTestsTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('simpletest');
/**
* Use the Minimal profile.
*
* The Testing profile contains drupal_system_listing_compatible_test.test,
* which should be found.
*
* The Standard profile contains \Drupal\standard\Tests\StandardTest, which
* should be found.
*
* @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
* @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
*/
protected $profile = 'minimal';
/**
* An administrative user with permission to administer unit tests.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(array('administer unit tests'));
$this->drupalLogin($this->adminUser);
}
/**
* Tests that tests located in another installation profile appear.
*/
function testOtherInstallationProfile() {
// Assert the existence of a test in a different installation profile than
// the current.
$this->drupalGet('admin/config/development/testing');
$this->assertText('Tests Standard installation profile expectations.');
// Assert the existence of a test for a module in a different installation
// profile than the current.
$this->assertText('Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest');
}
}
@@ -1,52 +0,0 @@
<?php
namespace Drupal\simpletest\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests User related helper methods of WebTestBase.
*
* @group simpletest
*/
class UserHelpersTest extends WebTestBase {
/**
* Tests WebTestBase::drupalUserIsLoggedIn().
*/
function testDrupalUserIsLoggedIn() {
$first_user = $this->drupalCreateUser();
$second_user = $this->drupalCreateUser();
// After logging in, the first user should be logged in, the second not.
$this->drupalLogin($first_user);
$this->assertTrue($this->drupalUserIsLoggedIn($first_user));
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
// Verify that logged in state is retained across pages.
$this->drupalGet('');
$this->assertTrue($this->drupalUserIsLoggedIn($first_user));
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
// After logging out, both users should be logged out.
$this->drupalLogout();
$this->assertFalse($this->drupalUserIsLoggedIn($first_user));
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
// After logging back in, the second user should still be logged out.
$this->drupalLogin($first_user);
$this->assertTrue($this->drupalUserIsLoggedIn($first_user));
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
// After logging in the second user, the first one should be logged out.
$this->drupalLogin($second_user);
$this->assertTrue($this->drupalUserIsLoggedIn($second_user));
$this->assertFalse($this->drupalUserIsLoggedIn($first_user));
// After logging out, both should be logged out.
$this->drupalLogout();
$this->assertFalse($this->drupalUserIsLoggedIn($first_user));
$this->assertFalse($this->drupalUserIsLoggedIn($second_user));
}
}
@@ -12,7 +12,7 @@ use Drupal\Tests\user\Traits\UserCreationTrait as BaseUserCreationTrait;
* \Drupal\simpletest\TestBase.
*
* @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use
* Drupal\Tests\UserCreationTrait instead.
* \Drupal\Tests\user\Traits\UserCreationTrait instead.
*
* @see https://www.drupal.org/node/2884454
*/
+3 -1
View File
@@ -96,7 +96,7 @@ abstract class WebTestBase extends TestBase {
/**
* The headers of the page currently loaded in the internal browser.
*
* @var Array
* @var array
*/
protected $headers;
@@ -168,6 +168,8 @@ abstract class WebTestBase extends TestBase {
/**
* The maximum number of redirects to follow when handling responses.
*
* @var int
*/
protected $maximumRedirects = 5;
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- entity_test
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
core: '8.x'
project: 'drupal'
datestamp: 1509719929
datestamp: 1515021228
@@ -1,77 +0,0 @@
<?php
namespace Drupal\Tests\simpletest\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
* Tests BrowserTestBase functionality.
*
* @group simpletest
*/
class BrowserTestBaseTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('test_page_test', 'form_test');
/**
* Tests basic page test.
*/
public function testGoTo() {
$account = $this->drupalCreateUser();
$this->drupalLogin($account);
// Visit a Drupal page that requires login.
$this->drupalGet('test-page');
$this->assertSession()->statusCodeEquals(200);
// Test page contains some text.
$this->assertSession()->pageTextContains('Test page text.');
// Response includes cache tags that we can assert.
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Tags', 'rendered');
// Test that we can read the JS settings.
$js_settings = $this->getDrupalSettings();
$this->assertSame('azAZ09();.,\\\/-_{}', $js_settings['test-setting']);
// Test drupalGet with a url object.
$url = Url::fromRoute('test_page_test.render_title');
$this->drupalGet($url);
$this->assertSession()->statusCodeEquals(200);
// Test page contains some text.
$this->assertSession()->pageTextContains('Hello Drupal');
}
/**
* Tests basic form functionality.
*/
public function testForm() {
// Ensure the proper response code for a _form route.
$this->drupalGet('form-test/object-builder');
$this->assertSession()->statusCodeEquals(200);
// Ensure the form and text field exist.
$this->assertSession()->elementExists('css', 'form#form-test-form-test-object');
$this->assertSession()->fieldExists('bananas');
$edit = ['bananas' => 'green'];
$this->submitForm($edit, 'Save', 'form-test-form-test-object');
$config_factory = $this->container->get('config.factory');
$value = $config_factory->get('form_test.object')->get('bananas');
$this->assertSame('green', $value);
}
public function testError() {
$this->setExpectedException('\Exception', 'User notice: foo');
$this->drupalGet('test-error');
}
}
@@ -1,22 +0,0 @@
<?php
namespace Drupal\Tests\simpletest\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* This test should not load since it requires a module that is not found.
*
* @group simpletest
* @dependencies simpletest_missing_module
*/
class MissingDependentModuleUnitTest extends BrowserTestBase {
/**
* Ensure that this test will not be loaded despite its dependency.
*/
public function testFail() {
$this->fail('Running test with missing required module.');
}
}
@@ -28,6 +28,8 @@ class OtherInstallationProfileTestsTest extends BrowserTestBase {
* The Standard profile contains \Drupal\standard\Tests\StandardTest, which
* should be found.
*
* @var string
*
* @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
* @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
*/
@@ -1,49 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\simpletest\Unit\AssertHelperTraitTest.
*/
namespace Drupal\Tests\simpletest\Unit;
use Drupal\Core\Render\Markup;
use Drupal\simpletest\AssertHelperTrait;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\simpletest\AssertHelperTrait
* @group simpletest
*/
class AssertHelperTraitTest extends UnitTestCase {
/**
* @covers ::castSafeStrings
* @dataProvider providerCastSafeStrings
*/
public function testCastSafeStrings($expected, $value) {
$class = new AssertHelperTestClass();
$this->assertSame($expected, $class->testMethod($value));
}
public function providerCastSafeStrings() {
$safe_string = Markup::create('test safe string');
return [
['test simple string', 'test simple string'],
[['test simple array', 'test simple array'], ['test simple array', 'test simple array']],
['test safe string', $safe_string],
[['test safe string', 'test safe string'], [$safe_string, $safe_string]],
[['test safe string', 'mixed array', 'test safe string'], [$safe_string, 'mixed array', $safe_string]],
];
}
}
class AssertHelperTestClass {
use AssertHelperTrait;
public function testMethod($value) {
return $this->castSafeStrings($value);
}
}
@@ -1,430 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\simpletest\Unit\TestInfoParsingTest.
*/
namespace Drupal\Tests\simpletest\Unit {
use Composer\Autoload\ClassLoader;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\simpletest\TestDiscovery;
use Drupal\Tests\UnitTestCase;
use org\bovigo\vfs\vfsStream;
/**
* @coversDefaultClass \Drupal\simpletest\TestDiscovery
* @group simpletest
*/
class TestInfoParsingTest extends UnitTestCase {
/**
* @covers ::getTestInfo
* @dataProvider infoParserProvider
*/
public function testTestInfoParser($expected, $classname, $doc_comment = NULL) {
$info = 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' => 'simpletest',
'description' => 'Tests \Drupal\simpletest\TestDiscovery.',
'type' => 'PHPUnit-Unit',
],
// Classname.
'Drupal\Tests\simpletest\Unit\TestInfoParsingTest',
];
// A core unit test.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\Tests\Core\DrupalTest',
'group' => 'DrupalTest',
'description' => 'Tests \Drupal.',
'type' => 'PHPUnit-Unit',
],
// Classname.
'Drupal\Tests\Core\DrupalTest',
];
// Functional PHPUnit test.
$tests[] = [
// Expected result.
[
'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[] = [
// Expected result.
[
'name' => 'Drupal\simpletest\Tests\ExampleSimpleTest',
'group' => 'simpletest',
'description' => 'Tests the Simpletest UI internal browser.',
'type' => 'Simpletest',
],
// Classname.
'Drupal\simpletest\Tests\ExampleSimpleTest',
// Doc block.
"/**
* Tests the Simpletest UI internal browser.
*
* @group simpletest
*/
",
];
// Test with a different amount of leading spaces.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\simpletest\Tests\ExampleSimpleTest',
'group' => 'simpletest',
'description' => 'Tests the Simpletest UI internal browser.',
'type' => 'Simpletest',
],
// Classname.
'Drupal\simpletest\Tests\ExampleSimpleTest',
// Doc block.
"/**
* Tests the Simpletest UI internal browser.
*
* @group simpletest
*/
*/
",
];
// Make sure that a "* @" inside a string does not get parsed as an
// annotation.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\simpletest\Tests\ExampleSimpleTest',
'group' => 'simpletest',
'description' => 'Tests the Simpletest UI internal browser. * @',
'type' => 'Simpletest',
],
// Classname.
'Drupal\simpletest\Tests\ExampleSimpleTest',
// Doc block.
"/**
* Tests the Simpletest UI internal browser. * @
*
* @group simpletest
*/
",
];
// Multiple @group annotations.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\simpletest\Tests\ExampleSimpleTest',
'group' => 'Test',
'description' => 'Tests the Simpletest UI internal browser.',
'type' => 'Simpletest',
],
// Classname.
'Drupal\simpletest\Tests\ExampleSimpleTest',
// Doc block.
"/**
* Tests the Simpletest UI internal browser.
*
* @group Test
* @group simpletest
*/
",
];
// @dependencies annotation.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\simpletest\Tests\ExampleSimpleTest',
'description' => 'Tests the Simpletest UI internal browser.',
'type' => 'Simpletest',
'requires' => ['module' => ['test']],
'group' => 'simpletest',
],
// Classname.
'Drupal\simpletest\Tests\ExampleSimpleTest',
// Doc block.
"/**
* Tests the Simpletest UI internal browser.
*
* @dependencies test
* @group simpletest
*/
",
];
// Multiple @dependencies annotation.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\simpletest\Tests\ExampleSimpleTest',
'description' => 'Tests the Simpletest UI internal browser.',
'type' => 'Simpletest',
'requires' => ['module' => ['test', 'test1', 'test2']],
'group' => 'simpletest',
],
// Classname.
'Drupal\simpletest\Tests\ExampleSimpleTest',
// Doc block.
"/**
* Tests the Simpletest UI internal browser.
*
* @dependencies test, test1, test2
* @group simpletest
*/
",
];
// Multi-line summary line.
$tests[] = [
// Expected result.
[
'name' => 'Drupal\simpletest\Tests\ExampleSimpleTest',
'description' => 'Tests the Simpletest UI internal browser. And the summary line continues an there is no gap to the annotation.',
'type' => 'Simpletest',
'group' => 'simpletest',
],
// Classname.
'Drupal\simpletest\Tests\ExampleSimpleTest',
// Doc block.
"/**
* Tests the Simpletest UI internal browser. And the summary line continues an
* there is no gap to the annotation.
*
* @group simpletest
*/
",
];
return $tests;
}
/**
* @covers ::getTestInfo
* @expectedException \Drupal\simpletest\Exception\MissingGroupException
* @expectedExceptionMessage Missing @group annotation in Drupal\KernelTests\field\BulkDeleteTest
*/
public function testTestInfoParserMissingGroup() {
$classname = 'Drupal\KernelTests\field\BulkDeleteTest';
$doc_comment = <<<EOT
/**
* Bulk delete storages and fields, and clean up afterwards.
*/
EOT;
TestDiscovery::getTestInfo($classname, $doc_comment);
}
/**
* @covers ::getTestInfo
*/
public function testTestInfoParserMissingSummary() {
$classname = 'Drupal\KernelTests\field\BulkDeleteTest';
$doc_comment = <<<EOT
/**
* @group field
*/
EOT;
$info = TestDiscovery::getTestInfo($classname, $doc_comment);
$this->assertEmpty($info['description']);
}
protected function setupVfsWithTestClasses() {
vfsStream::setup('drupal');
$test_file = <<<EOF
<?php
/**
* Test description
* @group example
*/
class FunctionalExampleTest {}
EOF;
vfsStream::create([
'modules' => [
'test_module' => [
'tests' => [
'src' => [
'Functional' => [
'FunctionalExampleTest.php' => $test_file,
'FunctionalExampleTest2.php' => str_replace(['FunctionalExampleTest', '@group example'], ['FunctionalExampleTest2', '@group example2'], $test_file),
],
'Kernel' => [
'KernelExampleTest3.php' => str_replace(['FunctionalExampleTest', '@group example'], ['KernelExampleTest3', '@group example2'], $test_file),
],
],
],
],
],
]);
}
/**
* @covers ::getTestClasses
*/
public function testGetTestClasses() {
$this->setupVfsWithTestClasses();
$class_loader = $this->prophesize(ClassLoader::class);
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$test_discovery = new TestTestDiscovery('vfs://drupal', $class_loader->reveal(), $module_handler->reveal());
$extensions = [
'test_module' => new Extension('vfs://drupal', 'module', 'modules/test_module/test_module.info.yml'),
];
$test_discovery->setExtensions($extensions);
$result = $test_discovery->getTestClasses();
$this->assertCount(2, $result);
$this->assertEquals([
'example' => [
'Drupal\Tests\test_module\Functional\FunctionalExampleTest' => [
'name' => 'Drupal\Tests\test_module\Functional\FunctionalExampleTest',
'description' => 'Test description',
'group' => 'example',
'type' => 'PHPUnit-Functional',
],
],
'example2' => [
'Drupal\Tests\test_module\Functional\FunctionalExampleTest2' => [
'name' => 'Drupal\Tests\test_module\Functional\FunctionalExampleTest2',
'description' => 'Test description',
'group' => 'example2',
'type' => 'PHPUnit-Functional',
],
'Drupal\Tests\test_module\Kernel\KernelExampleTest3' => [
'name' => 'Drupal\Tests\test_module\Kernel\KernelExampleTest3',
'description' => 'Test description',
'group' => 'example2',
'type' => 'PHPUnit-Kernel',
],
],
], $result);
}
/**
* @covers ::getTestClasses
*/
public function testGetTestClassesWithSelectedTypes() {
$this->setupVfsWithTestClasses();
$class_loader = $this->prophesize(ClassLoader::class);
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$test_discovery = new TestTestDiscovery('vfs://drupal', $class_loader->reveal(), $module_handler->reveal());
$extensions = [
'test_module' => new Extension('vfs://drupal', 'module', 'modules/test_module/test_module.info.yml'),
];
$test_discovery->setExtensions($extensions);
$result = $test_discovery->getTestClasses(NULL, ['PHPUnit-Kernel']);
$this->assertCount(2, $result);
$this->assertEquals([
'example' => [
],
'example2' => [
'Drupal\Tests\test_module\Kernel\KernelExampleTest3' => [
'name' => 'Drupal\Tests\test_module\Kernel\KernelExampleTest3',
'description' => 'Test description',
'group' => 'example2',
'type' => 'PHPUnit-Kernel',
],
],
], $result);
}
}
class TestTestDiscovery extends TestDiscovery {
/**
* @var \Drupal\Core\Extension\Extension[]
*/
protected $extensions = [];
public function setExtensions(array $extensions) {
$this->extensions = $extensions;
}
/**
* {@inheritdoc}
*/
protected function getExtensions() {
return $this->extensions;
}
/**
* @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;
}
}
}
namespace Drupal\simpletest\Tests {
use Drupal\simpletest\WebTestBase;
/**
* Tests the Simpletest UI internal browser.
*
* @group simpletest
*/
class ExampleSimpleTest extends WebTestBase {
}
}