function ResponseStatusTest::testConditions
Tests the request path condition.
@dataProvider providerTestConditions
File
- 
              core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Condition/ ResponseStatusTest.php, line 58  
Class
- ResponseStatusTest
 - Tests the Response Status Condition, provided by the system module.
 
Namespace
Drupal\KernelTests\Core\Plugin\ConditionCode
public function testConditions(array $status_codes, bool $negate, int $response_code, bool $expected_execute) : void {
  if ($response_code === Response::HTTP_OK) {
    $request = Request::create('/my/valid/page');
  }
  else {
    $request = new Request();
    $request->attributes
      ->set('exception', new HttpException($response_code));
  }
  $request->setSession(new Session(new MockArraySessionStorage()));
  $this->requestStack
    ->push($request);
  /** @var \Drupal\system\Plugin\Condition\ResponseStatus $condition */
  $condition = $this->pluginManager
    ->createInstance('response_status');
  $condition->setConfig('status_codes', $status_codes);
  $condition->setConfig('negate', $negate);
  $this->assertSame($expected_execute, $condition->execute());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.