You are here

public function BrowserTestBaseTest::testTearDownWithoutSetUp in Drupal 9

Same name and namespace in other branches
  1. 8 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 82

Class

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

Namespace

Drupal\Tests\Core\Test

Code

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