[new IsValidCsrfTokenRule(), null, $type, "Missing CSRF token."], "exception if input is not a string" => [new IsValidCsrfTokenRule(), 170, $type, "CSRF token should be string, but is integer."], ]; } protected function setUp(): void { $_SESSION = []; } public function test_exception_if_input_is_incorrect_token(): void { $_SESSION["token"] = "valid"; self::expectException(InvalidValueException::class); (new IsValidCsrfTokenRule())->check(["key" => "invalid"], "key"); } public function test_no_exception_if_input_is_correct_token(): void { $_SESSION["token"] = "valid"; (new IsValidCsrfTokenRule())->check(["key" => "valid"], "key"); self::assertTrue(true); } }