function BrowserTestBaseTest::testTearDownWithoutSetUp

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::testTearDownWithoutSetUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::testTearDownWithoutSetUp()
  3. 11.x core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php \Drupal\Tests\Core\Test\BrowserTestBaseTest::testTearDownWithoutSetUp()

Tests that tearDown doesn't call cleanupEnvironment if setUp is not called.

@covers ::tearDown

File

core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php, line 83

Class

BrowserTestBaseTest
@coversDefaultClass \Drupal\Tests\BrowserTestBase @group Test

Namespace

Drupal\Tests\Core\Test

Code

public function testTearDownWithoutSetUp() : void {
    $method = 'cleanupEnvironment';
    $this->assertTrue(method_exists(BrowserTestBase::class, $method));
    $btb = $this->getMockBuilder(BrowserTestBaseMockableClass::class)
        ->disableOriginalConstructor()
        ->onlyMethods([
        $method,
    ])
        ->getMock();
    $btb->expects($this->never())
        ->method($method);
    $ref_tearDown = new \ReflectionMethod($btb, 'tearDown');
    $ref_tearDown->invoke($btb);
}

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