Skip to content

Commit

Permalink
ci: add PHP 8.3 to workflow matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
brotkrueml committed Jan 16, 2024
1 parent df4ceee commit e6085af
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
typo3-versions: ^11
- php-versions: 8.2
typo3-versions: ^12
- php-versions: 8.3
typo3-versions: ^11
- php-versions: 8.3
typo3-versions: ^12
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions Classes/Guards/IntervalGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function guard($interval): string
}

if (@\DateInterval::createFromDateString($interval) === false) {
// @todo Remove check and exception when compatibility of PHP >= 8.3
// @see https://www.php.net/manual/de/class.datemalformedintervalstringexception.php
throw new \InvalidArgumentException(
\sprintf(
'Interval is not valid, "%s" given!',
Expand Down
23 changes: 18 additions & 5 deletions Tests/Unit/Guards/IntervalGuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,25 @@ public function providerForInvalidIntervals(): iterable
'expectedMessage' => 'Interval must be a string!',
'expectedCode' => 1671448703,
];
}

yield 'interval is an invalid string' => [
'interval' => 'This is invalid',
'expectedMessage' => 'Interval is not valid, "This is invalid" given!',
'expectedCode' => 1671448704,
];
/**
* @test
*
* @todo Remove when compatibility of PHP >= 8.3
* @see https://www.php.net/manual/de/class.datemalformedintervalstringexception.php
*/
public function guardThrowsExceptionOnInvalidIntervalWhenCreating(): void
{
if (\version_compare(\PHP_VERSION, '8.3.0', '>=')) {
self::markTestSkipped();
}

$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Interval is not valid, "This is invalid" given!');
$this->expectExceptionCode(1671448704);

$this->subject->guard('This is invalid');
}

/**
Expand Down

0 comments on commit e6085af

Please sign in to comment.