Chris@0: drupalCreateUser(['administer unit tests']); Chris@0: $this->drupalLogin($admin_user); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Overrides checkRequirements(). Chris@0: */ Chris@0: protected function checkRequirements() { Chris@0: if ($this->isInChildSite()) { Chris@0: return [ Chris@17: 'Test is not allowed to run.', Chris@0: ]; Chris@0: } Chris@0: return parent::checkRequirements(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Ensures test will not run when requirements are missing. Chris@0: */ Chris@0: public function testCheckRequirements() { Chris@0: // If this is the main request, run the web test script and then assert Chris@0: // that the child tests did not run. Chris@0: if (!$this->isInChildSite()) { Chris@0: // Run this test from web interface. Chris@0: $edit['tests[Drupal\simpletest\Tests\MissingCheckedRequirementsTest]'] = TRUE; Chris@0: $this->drupalPostForm('admin/config/development/testing', $edit, t('Run tests')); Chris@0: $this->assertRaw('Test is not allowed to run.', 'Test check for requirements came up.'); Chris@0: $this->assertNoText('Test ran when it failed requirements check.', 'Test requirements stopped test from running.'); Chris@0: } Chris@0: else { Chris@0: $this->fail('Test ran when it failed requirements check.'); Chris@0: } Chris@0: } Chris@0: Chris@0: }