class KernelTestBaseShutdownTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/KernelTestBaseShutdownTest.php \Drupal\KernelTests\KernelTestBaseShutdownTest
- 10 core/tests/Drupal/KernelTests/KernelTestBaseShutdownTest.php \Drupal\KernelTests\KernelTestBaseShutdownTest
- 8.9.x core/tests/Drupal/KernelTests/KernelTestBaseShutdownTest.php \Drupal\KernelTests\KernelTestBaseShutdownTest
@coversDefaultClass \Drupal\KernelTests\KernelTestBase
@group PHPUnit @group Test @group KernelTests
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\KernelTestBaseShutdownTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of KernelTestBaseShutdownTest
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestBaseShutdownTest.php, line 12
Namespace
Drupal\KernelTestsView source
class KernelTestBaseShutdownTest extends KernelTestBase {
/**
* Indicates which shutdown functions are expected to be called.
*
* @var array
*/
protected $expectedShutdownCalled;
/**
* Indicates which shutdown functions have been called.
*
* @var array
*/
protected static $shutdownCalled;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
// Initialize static variable prior to testing.
self::$shutdownCalled = [];
parent::setUp();
}
/**
* @covers ::assertPostConditions
*/
public function testShutdownFunction() {
$this->expectedShutdownCalled = [
'shutdownFunction',
'shutdownFunction2',
];
drupal_register_shutdown_function([
$this,
'shutdownFunction',
]);
}
/**
* @covers ::assertPostConditions
*/
public function testNoShutdownFunction() {
$this->expectedShutdownCalled = [];
}
/**
* Registers that this shutdown function has been called.
*/
public function shutdownFunction() {
self::$shutdownCalled[] = 'shutdownFunction';
drupal_register_shutdown_function([
$this,
'shutdownFunction2',
]);
}
/**
* Registers that this shutdown function has been called.
*/
public function shutdownFunction2() {
self::$shutdownCalled[] = 'shutdownFunction2';
}
/**
* {@inheritdoc}
*/
protected function assertPostConditions() : void {
parent::assertPostConditions();
$this->assertSame($this->expectedShutdownCalled, self::$shutdownCalled);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.