function DrupalKernelRequestStackTest::getRequestStackCount

Uses reflection to count the number of requests in the request stack.

Parameters

\Symfony\Component\HttpFoundation\RequestStack $request_stack: The request stack.

Return value

int The number of requests in the stack.

File

core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelRequestStackTest.php, line 195

Class

DrupalKernelRequestStackTest
Tests the usage of the request stack as part of request processing.

Namespace

Drupal\KernelTests\Core\DrupalKernel

Code

private function getRequestStackCount(RequestStack $request_stack) : int {
  // Create reflection object
  $reflection = new \ReflectionClass($request_stack);
  // Get the private property
  return count($reflection->getProperty('requests')
    ->getValue($request_stack));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.