KernelTestBaseShutdownTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/KernelTestBaseShutdownTest.php
View source
<?php
namespace Drupal\KernelTests;
class KernelTestBaseShutdownTest extends KernelTestBase {
protected $expectedShutdownCalled;
protected static $shutdownCalled;
protected function setUp() : void {
self::$shutdownCalled = [];
parent::setUp();
}
public function testShutdownFunction() {
$this->expectedShutdownCalled = [
'shutdownFunction',
'shutdownFunction2',
];
drupal_register_shutdown_function([
$this,
'shutdownFunction',
]);
}
public function testNoShutdownFunction() {
$this->expectedShutdownCalled = [];
}
public function shutdownFunction() {
self::$shutdownCalled[] = 'shutdownFunction';
drupal_register_shutdown_function([
$this,
'shutdownFunction2',
]);
}
public function shutdownFunction2() {
self::$shutdownCalled[] = 'shutdownFunction2';
}
protected function assertPostConditions() : void {
parent::assertPostConditions();
$this
->assertSame($this->expectedShutdownCalled, self::$shutdownCalled);
}
}