Skip to content

Commit d503aab

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

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
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": "^9.0 || ^10.0 || ^11.0",
3131
"squizlabs/php_codesniffer": "^3.5"
3232
},
3333
"scripts": {

tests/ExpectTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public function testItDoesNotThrowWhenExpectationIsMet($expectation): void
2424
$this->addToAssertionCount(1); // No exception thrown
2525
}
2626

27+
public function testItDoesNotThrowWhenExpectationIsMetAndACustomMatcherIsUsed(): void
28+
{
29+
expect(1)->toHaveFoo(1);
30+
$this->addToAssertionCount(1); // No exception thrown
31+
}
32+
2733
/**
2834
* @dataProvider incorrectExpectations
2935
*/
@@ -58,7 +64,7 @@ public function testItCanBeDeactivated(): void
5864
/**
5965
* Cases that should evaluate without an exception
6066
*/
61-
public function correctExpectations(): array
67+
public static function correctExpectations(): array
6268
{
6369
return [
6470
[ function () { expect(5)->toBe(5); } ],
@@ -80,16 +86,13 @@ public function correctExpectations(): array
8086
[ function () { expect((new Foo()))->toTrigger(E_USER_DEPRECATED)->duringTriggerError(); } ],
8187
[ function () { expect(1.444447777)->toBeApproximately(1.444447777, 1.0e-9); } ],
8288
[ 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); } ],
8689
];
8790
}
8891

8992
/**
9093
* Cases that should throw an exception when evaluated
9194
*/
92-
public function incorrectExpectations(): array
95+
public static function incorrectExpectations(): array
9396
{
9497
return [
9598
[ function () { expect(6)->toBe(5); } ],
@@ -121,7 +124,6 @@ public function incorrectExpectations(): array
121124
public function getMatchers(): array
122125
{
123126
return [
124-
'haveKey' => function ($subject, $key) { return array_key_exists($key, $subject); },
125127
'haveFoo' => new FooMatcher(),
126128
'haveBar' => $this->addInvalidMatcher ? new \stdClass() : new FooMatcher(),
127129
];

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)