mglaman / drupal-test-helpers

Helpers for writing better Kernel and Unit tests for Drupal
GNU General Public License v2.0
10 stars 2 forks source link

TestHttpKernel needs to implement TerminableInterface #11

Closed mglaman closed 5 months ago

mglaman commented 1 year ago

It doesn't implement TerminableInterface so termination of results doesn't happen, even though the decorated http kernel does.

I discovered in \Drupal\Core\StackMiddleware\StackedHttpKernel::terminate with

      if (!$previous instanceof TerminableInterface && $kernel instanceof TerminableInterface) {
        $kernel->terminate($request, $response);
      }
mglaman commented 1 year ago

The change required:

Implement \Symfony\Component\HttpKernel\TerminableInterface and

  public function terminate(Request $request, Response $response): void {
    if ($this->httpKernel instanceof TerminableInterface) {
      $this->httpKernel->terminate($request, $response);
    }
  }