113748f18d5ec2bb0c4fedb337c83cceebb2b29f
[yaffs-website] / web / core / modules / simpletest / src / Tests / InstallationProfileModuleTestsTest.php
1 <?php
2
3 namespace Drupal\simpletest\Tests;
4
5 use Drupal\simpletest\WebTestBase;
6
7 /**
8  * Verifies that tests bundled with installation profile modules are found.
9  *
10  * @group simpletest
11  */
12 class InstallationProfileModuleTestsTest extends WebTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['simpletest'];
20
21   /**
22    * An administrative user with permission to administer unit tests.
23    *
24    * @var \Drupal\user\UserInterface
25    */
26   protected $adminUser;
27
28   /**
29    * Use the Testing profile.
30    *
31    * The Testing profile contains drupal_system_listing_compatible_test.test,
32    * which attempts to:
33    * - run tests using the Minimal profile (which does not contain the
34    *   drupal_system_listing_compatible_test.module)
35    * - but still install the drupal_system_listing_compatible_test.module
36    *   contained in the Testing profile.
37    *
38    * @see \Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest
39    *
40    * @var string
41    */
42   protected $profile = 'testing';
43
44   protected function setUp() {
45     parent::setUp();
46
47     $this->adminUser = $this->drupalCreateUser(['administer unit tests']);
48     $this->drupalLogin($this->adminUser);
49   }
50
51   /**
52    * Tests existence of test case located in an installation profile module.
53    */
54   public function testInstallationProfileTests() {
55     $this->drupalGet('admin/config/development/testing');
56     $this->assertText('Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest');
57     $edit = [
58       'tests[Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest]' => TRUE,
59     ];
60     $this->drupalPostForm(NULL, $edit, t('Run tests'));
61
62     // Verifies that tests in installation profile modules are passed.
63     $element = $this->xpath('//tr[contains(@class, :class)]/td[contains(text(), :value)]', [
64       ':class' => 'simpletest-pass',
65       ':value' => 'Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest',
66     ]);
67     $this->assertTrue(!empty($element));
68   }
69
70 }