3 namespace Drupal\simpletest\Tests;
5 use Drupal\simpletest\WebTestBase;
8 * Tests a test case with missing requirements.
12 class MissingCheckedRequirementsTest extends WebTestBase {
19 public static $modules = ['simpletest'];
21 protected function setUp() {
23 $admin_user = $this->drupalCreateUser(['administer unit tests']);
24 $this->drupalLogin($admin_user);
28 * Overrides checkRequirements().
30 protected function checkRequirements() {
31 if ($this->isInChildSite()) {
33 'Test is not allowed to run.'
36 return parent::checkRequirements();
40 * Ensures test will not run when requirements are missing.
42 public function testCheckRequirements() {
43 // If this is the main request, run the web test script and then assert
44 // that the child tests did not run.
45 if (!$this->isInChildSite()) {
46 // Run this test from web interface.
47 $edit['tests[Drupal\simpletest\Tests\MissingCheckedRequirementsTest]'] = TRUE;
48 $this->drupalPostForm('admin/config/development/testing', $edit, t('Run tests'));
49 $this->assertRaw('Test is not allowed to run.', 'Test check for requirements came up.');
50 $this->assertNoText('Test ran when it failed requirements check.', 'Test requirements stopped test from running.');
53 $this->fail('Test ran when it failed requirements check.');