InstallationProfileModuleTestsTest.php 2.08 KB
Newer Older
1 2 3 4 5 6 7 8
<?php

namespace Drupal\simpletest\Tests;

use Drupal\simpletest\WebTestBase;

/**
 * Verifies that tests bundled with installation profile modules are found.
9 10
 *
 * @group simpletest
11 12
 */
class InstallationProfileModuleTestsTest extends WebTestBase {
13 14 15 16 17 18

  /**
   * Modules to enable.
   *
   * @var array
   */
19
  public static $modules = ['simpletest'];
20

21 22 23 24 25 26 27
  /**
   * An administrative user with permission to adminsiter unit tests.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $adminUser;

28 29 30 31 32 33 34 35 36 37
  /**
   * Use the Testing profile.
   *
   * The Testing profile contains drupal_system_listing_compatible_test.test,
   * which attempts to:
   * - run tests using the Minimal profile (which does not contain the
   *   drupal_system_listing_compatible_test.module)
   * - but still install the drupal_system_listing_compatible_test.module
   *   contained in the Testing profile.
   *
38
   * @see \Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest
39 40
   *
   * @var string
41 42 43
   */
  protected $profile = 'testing';

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 53
  }

  /**
   * Tests existence of test case located in an installation profile module.
   */
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 63 64

    // Verifies that tests in installation profile modules are passed.
    $element = $this->xpath('//tr[contains(@class, :class)]/td[contains(text(), :value)]', [
      ':class' => 'simpletest-pass',
65
      ':value' => 'Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest',
66 67
    ]);
    $this->assertTrue(!empty($element));
68
  }
69

70
}