Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miladrahimi committed Jul 10, 2021
1 parent 5a6aa00 commit e45159d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^7|^8"
"phpunit/phpunit": "^7|^8|^9"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 9 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,13 @@ public function setUp(): void
'eyJzdWIiOjY2NiwiZXhwIjoxNTczMjUyODYzLCJuYmYiOjE1NzMxNjY0NjMsImlhdCI6MTU3MzE2NjQ2MywiaXNzIjoiVGVzdCEifQ.' .
'CpOJ34DnOpG1lnSgmUpoCby8jQW7LiYeNMSLNEEMiuY';
}

protected function expectExceptionMessageFormat(string $format)
{
if (method_exists($this, 'expectExceptionMessageMatches')) {
$this->expectExceptionMessageMatches($format);
} else {
$this->expectExceptionMessageRegExp($format);
}
}
}
6 changes: 3 additions & 3 deletions tests/Validator/DefaultValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function test_with_exp_it_should_fail_with_expired_exp()
$validator = new DefaultValidator();

$this->expectException(ValidationException::class);
$this->expectExceptionMessageRegExp('/^The `exp` must be newer than `.+`.$/');
$this->expectExceptionMessageFormat('/^The `exp` must be newer than `.+`.$/');
$validator->validate([
'exp' => time() - 60 * 60 * 24,
]);
Expand All @@ -68,7 +68,7 @@ public function test_with_nbf_it_should_fail_with_later_time()
$validator = new DefaultValidator();

$this->expectException(ValidationException::class);
$this->expectExceptionMessageRegExp('/^The `nbf` must be older than or same `.+`.$/');
$this->expectExceptionMessageFormat('/^The `nbf` must be older than or same `.+`.$/');
$validator->validate([
'nbf' => time() + 60 * 60 * 24,
]);
Expand All @@ -95,7 +95,7 @@ public function test_with_iat_it_should_fail_with_later_time()
$validator = new DefaultValidator();

$this->expectException(ValidationException::class);
$this->expectExceptionMessageRegExp('/^The `iat` must be older than or same `.+`.$/');
$this->expectExceptionMessageFormat('/^The `iat` must be older than or same `.+`.$/');
$validator->validate([
'iat' => time() + 60 * 60 * 24,
]);
Expand Down

0 comments on commit e45159d

Please sign in to comment.