expectedShutdownCalled = ['shutdownFunction', 'shutdownFunction2']; drupal_register_shutdown_function([$this, 'shutdownFunction']); } /** * @covers ::assertPostConditions */ public function testNoShutdownFunction(): void { $this->expectedShutdownCalled = []; } /** * Registers that this shutdown function has been called. */ public function shutdownFunction(): void { self::$shutdownCalled[] = 'shutdownFunction'; drupal_register_shutdown_function([$this, 'shutdownFunction2']); } /** * Registers that this shutdown function has been called. */ public function shutdownFunction2(): void { self::$shutdownCalled[] = 'shutdownFunction2'; } /** * {@inheritdoc} */ protected function assertPostConditions(): void { parent::assertPostConditions(); $this->assertSame($this->expectedShutdownCalled, self::$shutdownCalled); } }