function ResponseStatusTest::providerTestConditions

Same name in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Plugin/Condition/ResponseStatusTest.php \Drupal\KernelTests\Core\Plugin\Condition\ResponseStatusTest::providerTestConditions()

Provides test data for testConditions.

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Plugin\Condition

Code

public static function providerTestConditions() {
    // Default values with 200 response code.
    (yield [
        'status_codes' => [],
        'negate' => FALSE,
        'response_code' => Response::HTTP_OK,
        'expected_execute' => TRUE,
    ]);
    // Default values with 403 response code.
    (yield [
        'status_codes' => [],
        'negate' => FALSE,
        'response_code' => Response::HTTP_FORBIDDEN,
        'expected_execute' => TRUE,
    ]);
    // Default values with 404 response code.
    (yield [
        'status_codes' => [],
        'negate' => FALSE,
        'response_code' => Response::HTTP_NOT_FOUND,
        'expected_execute' => TRUE,
    ]);
    // 200 status code enabled with 200 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_OK,
        'expected_execute' => TRUE,
    ]);
    // 200 status code enabled with 403 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_FORBIDDEN,
        'expected_execute' => FALSE,
    ]);
    // 200 status code enabled with 404 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_NOT_FOUND,
        'expected_execute' => FALSE,
    ]);
    // 403 status code enabled with 200 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_OK,
        'expected_execute' => FALSE,
    ]);
    // 403 status code enabled with 403 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_FORBIDDEN,
        'expected_execute' => TRUE,
    ]);
    // 403 status code enabled with 404 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_NOT_FOUND,
        'expected_execute' => FALSE,
    ]);
    // 200,403 status code enabled with 200 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_OK,
        'expected_execute' => TRUE,
    ]);
    // 200,403 status code enabled with 403 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_FORBIDDEN,
        'expected_execute' => TRUE,
    ]);
    // 200,403 status code enabled with 404 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_NOT_FOUND,
        'expected_execute' => FALSE,
    ]);
    // 200,404 status code enabled with 200 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_OK,
        'expected_execute' => TRUE,
    ]);
    // 200,404 status code enabled with 403 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_FORBIDDEN,
        'expected_execute' => FALSE,
    ]);
    // 200,404 status code enabled with 404 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_NOT_FOUND,
        'expected_execute' => TRUE,
    ]);
    // 403,404 status code enabled with 200 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_OK,
        'expected_execute' => FALSE,
    ]);
    // 403,404 status code enabled with 403 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_FORBIDDEN,
        'expected_execute' => TRUE,
    ]);
    // 403,404 status code enabled with 404 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_NOT_FOUND,
        'expected_execute' => TRUE,
    ]);
    // 200,403,404 status code enabled with 200 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_OK,
        'expected_execute' => TRUE,
    ]);
    // 200,403 status code enabled with 403 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_FORBIDDEN,
        'expected_execute' => TRUE,
    ]);
    // 200,403 status code enabled with 404 response code.
    (yield [
        'status_codes' => [
            Response::HTTP_OK => Response::HTTP_OK,
            Response::HTTP_FORBIDDEN => Response::HTTP_FORBIDDEN,
            Response::HTTP_NOT_FOUND => Response::HTTP_NOT_FOUND,
        ],
        'negate' => FALSE,
        'response_code' => Response::HTTP_NOT_FOUND,
        'expected_execute' => TRUE,
    ]);
}

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