function ResponseStatusTest::providerStatusCodesValidation

Same name and namespace in other branches
  1. main core/tests/Drupal/KernelTests/Core/Plugin/Condition/ResponseStatusTest.php \Drupal\KernelTests\Core\Plugin\Condition\ResponseStatusTest::providerStatusCodesValidation()

Provides test data for ::testStatusCodesValidation().

File

core/tests/Drupal/KernelTests/Core/Plugin/Condition/ResponseStatusTest.php, line 296

Class

ResponseStatusTest
Tests the Response Status Condition, provided by the system module.

Namespace

Drupal\KernelTests\Core\Plugin\Condition

Code

public static function providerStatusCodesValidation() : \Iterator {
  yield 'OK: empty status_codes' => [
    [],
    [],
  ];
  yield 'OK: 200' => [
    [
      Response::HTTP_OK,
    ],
    [],
  ];
  yield 'OK: all supported status codes' => [
    [
      Response::HTTP_OK,
      Response::HTTP_FORBIDDEN,
      Response::HTTP_NOT_FOUND,
    ],
    [],
  ];
  yield 'INVALID: 418' => [
    [
      Response::HTTP_I_AM_A_TEAPOT,
    ],
    [
      'status_codes.0' => 'The value you selected is not a valid choice.',
    ],
  ];
  yield 'INVALID: 200 and 418' => [
    [
      Response::HTTP_OK,
      Response::HTTP_I_AM_A_TEAPOT,
    ],
    [
      'status_codes.1' => 'The value you selected is not a valid choice.',
    ],
  ];
}

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