Skip to content

Commit 3c1ddfd

Browse files
authored
Merge pull request #55 from williamdes/phpunit-12
Add support for PHPUnit 12
2 parents 59f1560 + 858e9bd commit 3c1ddfd

File tree

7 files changed

+55
-3
lines changed

7 files changed

+55
-3
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: CI
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
58
branches: ['*']
@@ -14,7 +17,7 @@ jobs:
1417
strategy:
1518
fail-fast: false
1619
matrix:
17-
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
20+
php: [ '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
1821
dependency-version: [ '' ]
1922
include:
2023
- php: '7.3'

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"psr/container": "^1.0|^2.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^9.0",
23+
"phpunit/phpunit": "^9.0 || ^10 || ^11 || ^12",
2424
"athletic/athletic": "~0.1.8",
2525
"mnapoli/hard-mode": "~0.3.0"
2626
},

tests/CallableResolverTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function setUp(): void
2727
/**
2828
* @test
2929
*/
30+
#[\PHPUnit\Framework\Attributes\Test]
3031
public function resolves_function()
3132
{
3233
$result = $this->resolver->resolve('strlen');
@@ -37,6 +38,7 @@ public function resolves_function()
3738
/**
3839
* @test
3940
*/
41+
#[\PHPUnit\Framework\Attributes\Test]
4042
public function resolves_namespaced_function()
4143
{
4244
$result = $this->resolver->resolve(__NAMESPACE__ . '\foo');
@@ -47,6 +49,7 @@ public function resolves_namespaced_function()
4749
/**
4850
* @test
4951
*/
52+
#[\PHPUnit\Framework\Attributes\Test]
5053
public function resolves_callable_from_container()
5154
{
5255
$callable = function () {
@@ -59,6 +62,7 @@ public function resolves_callable_from_container()
5962
/**
6063
* @test
6164
*/
65+
#[\PHPUnit\Framework\Attributes\Test]
6266
public function resolves_invokable_class()
6367
{
6468
$callable = new CallableSpy;
@@ -70,6 +74,7 @@ public function resolves_invokable_class()
7074
/**
7175
* @test
7276
*/
77+
#[\PHPUnit\Framework\Attributes\Test]
7378
public function resolve_array_method_call()
7479
{
7580
$fixture = new InvokerTestFixture;
@@ -84,6 +89,7 @@ public function resolve_array_method_call()
8489
/**
8590
* @test
8691
*/
92+
#[\PHPUnit\Framework\Attributes\Test]
8793
public function resolve_string_method_call()
8894
{
8995
$fixture = new InvokerTestFixture;
@@ -98,6 +104,7 @@ public function resolve_string_method_call()
98104
/**
99105
* @test
100106
*/
107+
#[\PHPUnit\Framework\Attributes\Test]
101108
public function resolves_array_method_call_with_service()
102109
{
103110
$fixture = new InvokerTestFixture;
@@ -112,6 +119,7 @@ public function resolves_array_method_call_with_service()
112119
/**
113120
* @test
114121
*/
122+
#[\PHPUnit\Framework\Attributes\Test]
115123
public function resolves_string_method_call_with_service()
116124
{
117125
$fixture = new InvokerTestFixture;
@@ -126,6 +134,7 @@ public function resolves_string_method_call_with_service()
126134
/**
127135
* @test
128136
*/
137+
#[\PHPUnit\Framework\Attributes\Test]
129138
public function throws_resolving_non_callable_from_container()
130139
{
131140
$this->expectExceptionMessage("'foo' is neither a callable nor a valid container entry");
@@ -137,6 +146,7 @@ public function throws_resolving_non_callable_from_container()
137146
/**
138147
* @test
139148
*/
149+
#[\PHPUnit\Framework\Attributes\Test]
140150
public function handles_objects_correctly_in_exception_message()
141151
{
142152
$this->expectExceptionMessage('Instance of stdClass is not a callable');
@@ -148,6 +158,7 @@ public function handles_objects_correctly_in_exception_message()
148158
/**
149159
* @test
150160
*/
161+
#[\PHPUnit\Framework\Attributes\Test]
151162
public function handles_method_calls_correctly_in_exception_message()
152163
{
153164
$this->expectExceptionMessage('stdClass::test() is not a callable');

tests/InvokerTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function setUp(): void
3232
/**
3333
* @test
3434
*/
35+
#[\PHPUnit\Framework\Attributes\Test]
3536
public function should_invoke_closure()
3637
{
3738
$callable = new CallableSpy;
@@ -44,6 +45,7 @@ public function should_invoke_closure()
4445
/**
4546
* @test
4647
*/
48+
#[\PHPUnit\Framework\Attributes\Test]
4749
public function should_invoke_method()
4850
{
4951
$fixture = new InvokerTestFixture;
@@ -56,6 +58,7 @@ public function should_invoke_method()
5658
/**
5759
* @test
5860
*/
61+
#[\PHPUnit\Framework\Attributes\Test]
5962
public function cannot_invoke_unknown_method()
6063
{
6164
$this->expectExceptionMessage('Invoker\Test\InvokerTestFixture::bar() is not a callable.');
@@ -66,6 +69,7 @@ public function cannot_invoke_unknown_method()
6669
/**
6770
* @test
6871
*/
72+
#[\PHPUnit\Framework\Attributes\Test]
6973
public function cannot_invoke_magic_method()
7074
{
7175
$this->expectExceptionMessage('Invoker\Test\InvokerTestMagicMethodFixture::foo() is not a callable. A __call() or __callStatic() method exists but magic methods are not supported.');
@@ -76,6 +80,7 @@ public function cannot_invoke_magic_method()
7680
/**
7781
* @test
7882
*/
83+
#[\PHPUnit\Framework\Attributes\Test]
7984
public function cannot_invoke_static_magic_method()
8085
{
8186
$this->expectExceptionMessage('Invoker\Test\InvokerTestStaticMagicMethodFixture::foo() is not a callable. A __call() or __callStatic() method exists but magic methods are not supported.');
@@ -86,6 +91,7 @@ public function cannot_invoke_static_magic_method()
8691
/**
8792
* @test
8893
*/
94+
#[\PHPUnit\Framework\Attributes\Test]
8995
public function should_invoke_static_method()
9096
{
9197
$result = $this->invoker->call([InvokerTestStaticFixture::class, 'foo']);
@@ -96,6 +102,7 @@ public function should_invoke_static_method()
96102
/**
97103
* @test
98104
*/
105+
#[\PHPUnit\Framework\Attributes\Test]
99106
public function should_invoke_static_method_with_scope_resolution_syntax()
100107
{
101108
$result = $this->invoker->call('Invoker\Test\InvokerTestStaticFixture::foo');
@@ -106,6 +113,7 @@ public function should_invoke_static_method_with_scope_resolution_syntax()
106113
/**
107114
* @test
108115
*/
116+
#[\PHPUnit\Framework\Attributes\Test]
109117
public function should_return_the_callable_return_value()
110118
{
111119
$result = $this->invoker->call(function () {
@@ -118,6 +126,7 @@ public function should_return_the_callable_return_value()
118126
/**
119127
* @test
120128
*/
129+
#[\PHPUnit\Framework\Attributes\Test]
121130
public function should_throw_if_no_value_for_parameter()
122131
{
123132
$this->expectExceptionMessage('Unable to invoke the callable because no value was given for parameter 2 ($bar)');
@@ -132,6 +141,7 @@ public function should_throw_if_no_value_for_parameter()
132141
/**
133142
* @test
134143
*/
144+
#[\PHPUnit\Framework\Attributes\Test]
135145
public function should_throw_if_no_value_for_parameter_even_with_trailing_optional_parameters()
136146
{
137147
$this->expectExceptionMessage('Unable to invoke the callable because no value was given for parameter 2 ($bar)');
@@ -146,6 +156,7 @@ public function should_throw_if_no_value_for_parameter_even_with_trailing_option
146156
/**
147157
* @test
148158
*/
159+
#[\PHPUnit\Framework\Attributes\Test]
149160
public function should_invoke_callable_with_parameters_indexed_by_position()
150161
{
151162
$callable = new CallableSpy;
@@ -158,6 +169,7 @@ public function should_invoke_callable_with_parameters_indexed_by_position()
158169
/**
159170
* @test
160171
*/
172+
#[\PHPUnit\Framework\Attributes\Test]
161173
public function should_invoke_callable_with_parameters_indexed_by_name()
162174
{
163175
$parameters = [
@@ -175,6 +187,7 @@ public function should_invoke_callable_with_parameters_indexed_by_name()
175187
/**
176188
* @test
177189
*/
190+
#[\PHPUnit\Framework\Attributes\Test]
178191
public function should_invoke_callable_with_default_value_for_undefined_parameters()
179192
{
180193
$parameters = [
@@ -192,6 +205,7 @@ public function should_invoke_callable_with_default_value_for_undefined_paramete
192205
/**
193206
* @test
194207
*/
208+
#[\PHPUnit\Framework\Attributes\Test]
195209
public function should_invoke_callable_with_null_for_nullable_parameters()
196210
{
197211
$result = $this->invoker->call(function (?string $baz = null) {
@@ -238,6 +252,7 @@ public function should_invoke_callable_with_optional_parameter_before_required_p
238252
/**
239253
* @test
240254
*/
255+
#[\PHPUnit\Framework\Attributes\Test]
241256
public function should_do_dependency_injection_with_typehint_container_resolver()
242257
{
243258
$resolver = new TypeHintContainerResolver($this->container);
@@ -256,6 +271,7 @@ public function should_do_dependency_injection_with_typehint_container_resolver(
256271
/**
257272
* @test
258273
*/
274+
#[\PHPUnit\Framework\Attributes\Test]
259275
public function should_do_dependency_injection_with_parameter_name_container_resolver()
260276
{
261277
$resolver = new ParameterNameContainerResolver($this->container);
@@ -274,6 +290,7 @@ public function should_do_dependency_injection_with_parameter_name_container_res
274290
/**
275291
* @test
276292
*/
293+
#[\PHPUnit\Framework\Attributes\Test]
277294
public function should_resolve_callable_from_container()
278295
{
279296
$callable = new CallableSpy;
@@ -287,6 +304,7 @@ public function should_resolve_callable_from_container()
287304
/**
288305
* @test
289306
*/
307+
#[\PHPUnit\Framework\Attributes\Test]
290308
public function should_resolve_array_callable_from_container()
291309
{
292310
$fixture = new InvokerTestFixture;
@@ -301,6 +319,7 @@ public function should_resolve_array_callable_from_container()
301319
/**
302320
* @test
303321
*/
322+
#[\PHPUnit\Framework\Attributes\Test]
304323
public function should_resolve_callable_from_container_with_scope_resolution_syntax()
305324
{
306325
$fixture = new InvokerTestFixture;
@@ -315,6 +334,7 @@ public function should_resolve_callable_from_container_with_scope_resolution_syn
315334
/**
316335
* @test
317336
*/
337+
#[\PHPUnit\Framework\Attributes\Test]
318338
public function should_resolve_array_callable_from_container_with_class_name()
319339
{
320340
$fixture = new InvokerTestFixture;
@@ -329,6 +349,7 @@ public function should_resolve_array_callable_from_container_with_class_name()
329349
/**
330350
* @test
331351
*/
352+
#[\PHPUnit\Framework\Attributes\Test]
332353
public function should_resolve_callable_from_container_with_class_name_in_scope_resolution_syntax()
333354
{
334355
$fixture = new InvokerTestFixture;
@@ -366,6 +387,7 @@ public function positioned_parameters_have_the_highest_priority()
366387
/**
367388
* @test
368389
*/
390+
#[\PHPUnit\Framework\Attributes\Test]
369391
public function should_not_invoke_statically_a_non_static_method()
370392
{
371393
$this->expectExceptionMessage('Cannot call foo() on Invoker\Test\InvokerTestFixture because it is not a class nor a valid container entry');
@@ -376,6 +398,7 @@ public function should_not_invoke_statically_a_non_static_method()
376398
/**
377399
* @test
378400
*/
401+
#[\PHPUnit\Framework\Attributes\Test]
379402
public function should_throw_if_calling_non_callable_without_container()
380403
{
381404
$this->expectExceptionMessage("'foo' is not a callable");
@@ -387,6 +410,7 @@ public function should_throw_if_calling_non_callable_without_container()
387410
/**
388411
* @test
389412
*/
413+
#[\PHPUnit\Framework\Attributes\Test]
390414
public function should_throw_if_calling_non_callable_without_container_2()
391415
{
392416
$this->expectExceptionMessage('NULL is not a callable');
@@ -398,6 +422,7 @@ public function should_throw_if_calling_non_callable_without_container_2()
398422
/**
399423
* @test
400424
*/
425+
#[\PHPUnit\Framework\Attributes\Test]
401426
public function should_throw_if_calling_non_callable_with_container()
402427
{
403428
$this->expectExceptionMessage("'foo' is neither a callable nor a valid container entry");
@@ -409,6 +434,7 @@ public function should_throw_if_calling_non_callable_with_container()
409434
/**
410435
* @test
411436
*/
437+
#[\PHPUnit\Framework\Attributes\Test]
412438
public function should_throw_if_calling_non_callable_object()
413439
{
414440
$this->expectExceptionMessage('Instance of stdClass is not a callable');
@@ -420,6 +446,7 @@ public function should_throw_if_calling_non_callable_object()
420446
/**
421447
* @test
422448
*/
449+
#[\PHPUnit\Framework\Attributes\Test]
423450
public function should_invoke_static_method_rather_than_resolving_entry_from_container()
424451
{
425452
// Register a non-callable so that test fails if we try to invoke that
@@ -434,6 +461,7 @@ public function should_invoke_static_method_rather_than_resolving_entry_from_con
434461
/**
435462
* @test
436463
*/
464+
#[\PHPUnit\Framework\Attributes\Test]
437465
public function should_throw_if_no_value_for_optional_parameter_1()
438466
{
439467
$this->expectExceptionMessage('Unable to invoke the callable because no value was given for parameter 2 ($bar)');
@@ -449,6 +477,7 @@ public function should_throw_if_no_value_for_optional_parameter_1()
449477
/**
450478
* @test
451479
*/
480+
#[\PHPUnit\Framework\Attributes\Test]
452481
public function should_throw_if_no_value_for_optional_parameter_2()
453482
{
454483
$this->expectExceptionMessage('Unable to invoke the callable because no value was given for parameter 2 ($bar)');
@@ -465,6 +494,7 @@ public function should_throw_if_no_value_for_optional_parameter_2()
465494
/**
466495
* @test
467496
*/
497+
#[\PHPUnit\Framework\Attributes\Test]
468498
public function should_invoke_callable_with_variadic_parameter()
469499
{
470500
$callable = function (...$param) {
@@ -533,4 +563,3 @@ public static function __callStatic(string $name, array $args): string
533563
throw new Exception('Unknown method');
534564
}
535565
}
536-

tests/ParameterResolver/Container/ParameterNameContainerResolverTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function setUp(): void
2323
/**
2424
* @test
2525
*/
26+
#[\PHPUnit\Framework\Attributes\Test]
2627
public function should_resolve_parameter_with_parameter_name_from_container()
2728
{
2829
$callable = function ($foo) {
@@ -40,6 +41,7 @@ public function should_resolve_parameter_with_parameter_name_from_container()
4041
/**
4142
* @test
4243
*/
44+
#[\PHPUnit\Framework\Attributes\Test]
4345
public function should_skip_parameter_if_container_cannot_provide_parameter()
4446
{
4547
$callable = function ($foo) {
@@ -54,6 +56,7 @@ public function should_skip_parameter_if_container_cannot_provide_parameter()
5456
/**
5557
* @test
5658
*/
59+
#[\PHPUnit\Framework\Attributes\Test]
5760
public function should_skip_parameter_if_already_resolved()
5861
{
5962
$callable = function ($foo) {

0 commit comments

Comments
 (0)