Skip to content

Commit aac93a9

Browse files
committed
Test on latest PHP versions
1 parent 9561796 commit aac93a9

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
operating-system: ['ubuntu-latest']
14-
php-version: ['7.4', '8.0', '8.1', '8.2']
14+
php-version: ['8.1', '8.2', '8.3', '8.4']
1515
composer-version: ['composer:v2']
1616

1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v5
2020

2121
- name: Install PHP
2222
uses: shivammathur/setup-php@v2

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
}
2424
},
2525
"require": {
26-
"php": ">=7.4",
27-
"phpspec/phpspec": "^6.0 || ^7.0"
26+
"php": ">=8.1",
27+
"phpspec/phpspec": "^6.0 || ^7.0 || ^8.0"
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": "^9.0 || ^10.0",
30+
"phpunit/phpunit": "^10.0 || ^11.0 || ^12.0",
3131
"squizlabs/php_codesniffer": "^3.5"
3232
},
3333
"scripts": {

src/Subject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Subject extends BaseSubject
88
{
9-
public function __call(string $method, array $arguments = [])
9+
public function __call(string $method, array $arguments = []): mixed
1010
{
1111
if (preg_match('/^(to|notTo)(.+)$/', $method, $matches)) {
1212
$method = 'should' . $matches[2];

tests/ExpectTest.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@ protected function setUp(): void
1515
$this->addInvalidMatcher = false;
1616
}
1717

18-
/**
19-
* @dataProvider correctExpectations
20-
*/
18+
#[\PHPUnit\Framework\Attributes\DataProvider('correctExpectations')]
2119
public function testItDoesNotThrowWhenExpectationIsMet($expectation): void
2220
{
2321
$expectation();
2422
$this->addToAssertionCount(1); // No exception thrown
2523
}
2624

27-
/**
28-
* @dataProvider incorrectExpectations
29-
*/
25+
public function testItDoesNotThrowWhenExpectationIsMetAndACustomMatcherIsUsed(): void
26+
{
27+
expect(1)->toHaveFoo(1);
28+
$this->addToAssertionCount(1); // No exception thrown
29+
}
30+
31+
#[\PHPUnit\Framework\Attributes\DataProvider('incorrectExpectations')]
3032
public function testItThrowsWhenExpectationIsNotMet($expectation): void
3133
{
3234
$this->expectException(PhpSpecException::class);
@@ -58,7 +60,7 @@ public function testItCanBeDeactivated(): void
5860
/**
5961
* Cases that should evaluate without an exception
6062
*/
61-
public function correctExpectations(): array
63+
public static function correctExpectations(): array
6264
{
6365
return [
6466
[ function () { expect(5)->toBe(5); } ],
@@ -80,16 +82,13 @@ public function correctExpectations(): array
8082
[ function () { expect((new Foo()))->toTrigger(E_USER_DEPRECATED)->duringTriggerError(); } ],
8183
[ function () { expect(1.444447777)->toBeApproximately(1.444447777, 1.0e-9); } ],
8284
[ function () { expect((new Foo())->getIterator())->toIterateAs(new \ArrayIterator(['Foo', 'Bar'])); } ],
83-
// Custom matchers
84-
[ function () { expect(['foo' => 'bar'])->toHaveKey('foo'); } ],
85-
[ function () { expect(1)->toHaveFoo(1); } ],
8685
];
8786
}
8887

8988
/**
9089
* Cases that should throw an exception when evaluated
9190
*/
92-
public function incorrectExpectations(): array
91+
public static function incorrectExpectations(): array
9392
{
9493
return [
9594
[ function () { expect(6)->toBe(5); } ],
@@ -121,7 +120,6 @@ public function incorrectExpectations(): array
121120
public function getMatchers(): array
122121
{
123122
return [
124-
'haveKey' => function ($subject, $key) { return array_key_exists($key, $subject); },
125123
'haveFoo' => new FooMatcher(),
126124
'haveBar' => $this->addInvalidMatcher ? new \stdClass() : new FooMatcher(),
127125
];

tests/Foo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function isFoo()
1111
{
1212
return true;
1313
}
14-
public function count()
14+
public function count(): int
1515
{
1616
return 1;
1717
}

0 commit comments

Comments
 (0)