summaryrefslogtreecommitdiffstatshomepage
path: root/core/tests/Drupal/Tests/WaitTerminateTestTrait.php
blob: 0c273751b61e6eb4d562f7eeac9c2e8db58a4247 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php

declare(strict_types=1);

namespace Drupal\Tests;

/**
 * Provides a method to enforce that requests will wait for the terminate event.
 */
trait WaitTerminateTestTrait {

  /**
   * Specify that subsequent requests must wait for the terminate event.
   *
   * The terminate event is fired after a response is sent to the user agent.
   * Tests with assertions which operate on data computed during the terminate
   * event need to enable this.
   */
  protected function setWaitForTerminate(): void {
    $this->setContainerParameter('drupal.test_wait_terminate', TRUE);
    $this->rebuildContainer();
  }

}