function BrokenSetUpTest::setUp

Overrides WebTestBase::setUp

File

core/modules/simpletest/src/Tests/BrokenSetUpTest.php, line 36

Class

BrokenSetUpTest
Tests a test case that does not call parent::setUp().

Namespace

Drupal\simpletest\Tests

Code

protected function setUp() {
    // If the test is being run from the main site, set up normally.
    if (!$this->isInChildSite()) {
        parent::setUp();
        $this->sharedTriggerFile = $this->publicFilesDirectory . '/trigger';
        // Create and log in user.
        $admin_user = $this->drupalCreateUser([
            'administer unit tests',
        ]);
        $this->drupalLogin($admin_user);
    }
    else {
        $this->sharedTriggerFile = $this->originalFileDirectory . '/trigger';
        if (file_get_contents($this->sharedTriggerFile) === 'setup') {
            throw new \Exception('Broken setup');
        }
        $this->pass('The setUp() method has run.');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.