Skip to content

Commit aa65259

Browse files
committed
Upgrade PHPUnit and apply attributes
1 parent 9caa4bd commit aa65259

14 files changed

Lines changed: 158 additions & 293 deletions

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
"phpmd/phpmd": "^2.6",
2626
"phpstan/extension-installer": "^1.4",
2727
"phpstan/phpstan": "^2.1",
28-
"phpunit/phpunit": "^9.5",
28+
"phpunit/phpunit": "^10.0.0",
2929
"psr/log": "~1.0",
3030
"rector/rector": "^2.2",
31-
"sebastian/exporter": "^4.0.5",
31+
"sebastian/exporter": "^5.0.0",
3232
"squizlabs/php_codesniffer": "^3.7.1",
3333
"symfony/phpunit-bridge": "^6.3"
3434
},

src/Tests/Component/Signing/AuthnRequestSigningTest.php

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ class AuthnRequestSigningTest extends TestCase
4646

4747
private ?string $publicKey = null;
4848

49-
/**
50-
* @test
51-
* @group Signing
52-
* @group Deprecated
53-
*/
49+
#[\PHPUnit\Framework\Attributes\Test]
50+
#[\PHPUnit\Framework\Attributes\Group('Signing')]
51+
#[\PHPUnit\Framework\Attributes\Group('Deprecated')]
5452
public function deprecated_authn_request_signatures_are_verified_if_the_sender_uses_rfc1738_encoding(): void
5553
{
5654
$authnRequestWithDefaultEncoding = $this->createSignedAuthnRequest(
@@ -72,11 +70,9 @@ public function deprecated_authn_request_signatures_are_verified_if_the_sender_u
7270
);
7371
}
7472

75-
/**
76-
* @test
77-
* @group Signing
78-
* @group Deprecated
79-
*/
73+
#[\PHPUnit\Framework\Attributes\Test]
74+
#[\PHPUnit\Framework\Attributes\Group('Signing')]
75+
#[\PHPUnit\Framework\Attributes\Group('Deprecated')]
8076
public function deprecated_authn_request_signatures_are_verified_if_the_sender_uses_something_other_than_rfc1738_encoding(): void
8177
{
8278
$authnRequestWithCustomEncoding = $this->createSignedAuthnRequest(
@@ -98,11 +94,9 @@ public function deprecated_authn_request_signatures_are_verified_if_the_sender_u
9894
);
9995
}
10096

101-
/**
102-
* @test
103-
* @group Signing
104-
* @group Deprecated
105-
*/
97+
#[\PHPUnit\Framework\Attributes\Test]
98+
#[\PHPUnit\Framework\Attributes\Group('Signing')]
99+
#[\PHPUnit\Framework\Attributes\Group('Deprecated')]
106100
public function deprecated_authn_request_signatures_are_not_verified_if_the_data_to_sign_does_not_correspond_with_the_signature_sent(): void
107101
{
108102
$authnRequestWithModifiedDataToSign = $this->createSignedAuthnRequest(
@@ -123,11 +117,9 @@ public function deprecated_authn_request_signatures_are_not_verified_if_the_data
123117
);
124118
}
125119

126-
/**
127-
* @test
128-
* @group Signing
129-
* @group Deprecated
130-
*/
120+
#[\PHPUnit\Framework\Attributes\Test]
121+
#[\PHPUnit\Framework\Attributes\Group('Signing')]
122+
#[\PHPUnit\Framework\Attributes\Group('Deprecated')]
131123
public function deprecated_authn_request_signatures_are_not_verified_if_the_parameter_order_of_the_sent_query_is_not_correct(): void
132124
{
133125
$authnRequestWithModifiedDataToSign = $this->createSignedAuthnRequest(
@@ -147,10 +139,8 @@ public function deprecated_authn_request_signatures_are_not_verified_if_the_para
147139
);
148140
}
149141

150-
/**
151-
* @test
152-
* @group Signing
153-
*/
142+
#[\PHPUnit\Framework\Attributes\Test]
143+
#[\PHPUnit\Framework\Attributes\Group('Signing')]
154144
public function a_received_authn_requests_signature_is_verified_regardless_of_its_encoding(): void
155145
{
156146
$signatureVerifier = new SignatureVerifier(new KeyLoader, new NullLogger);
@@ -203,10 +193,8 @@ public function a_received_authn_requests_signature_is_verified_regardless_of_it
203193
);
204194
}
205195

206-
/**
207-
* @test
208-
* @group Signing
209-
*/
196+
#[\PHPUnit\Framework\Attributes\Test]
197+
#[\PHPUnit\Framework\Attributes\Group('Signing')]
210198
public function a_received_authn_requests_signature_is_not_verified_if_the_data_to_sign_does_not_correspond_with_the_signature_sent(): void
211199
{
212200
$signatureVerifier = new SignatureVerifier(new KeyLoader, new NullLogger);

src/Tests/Unit/Http/HttpBindingFactoryTest.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ public function setUp(): void
4141
$this->factory = new HttpBindingFactory($redirectBinding, $postBinding);
4242
}
4343

44-
/**
45-
* @test
46-
* @group http
47-
*/
44+
#[\PHPUnit\Framework\Attributes\Test]
45+
#[\PHPUnit\Framework\Attributes\Group('http')]
4846
public function a_redirect_binding_can_be_built(): void
4947
{
5048
$request = new Request(
@@ -60,10 +58,8 @@ public function a_redirect_binding_can_be_built(): void
6058
$this->assertInstanceOf(RedirectBinding::class, $binding);
6159
}
6260

63-
/**
64-
* @test
65-
* @group http
66-
*/
61+
#[\PHPUnit\Framework\Attributes\Test]
62+
#[\PHPUnit\Framework\Attributes\Group('http')]
6763
public function a_post_binding_can_be_built(): void
6864
{
6965
$request = new Request(
@@ -79,10 +75,8 @@ public function a_post_binding_can_be_built(): void
7975
$this->assertInstanceOf(PostBinding::class, $binding);
8076
}
8177

82-
/**
83-
* @test
84-
* @group http
85-
*/
78+
#[\PHPUnit\Framework\Attributes\Test]
79+
#[\PHPUnit\Framework\Attributes\Group('http')]
8680
public function a_put_binding_can_not_be_built(): void
8781
{
8882
$this->expectExceptionMessage("Request type of \"PUT\" is not supported.");
@@ -99,10 +93,8 @@ public function a_put_binding_can_not_be_built(): void
9993
$this->factory->build($request);
10094
}
10195

102-
/**
103-
* @test
104-
* @group http
105-
*/
96+
#[\PHPUnit\Framework\Attributes\Test]
97+
#[\PHPUnit\Framework\Attributes\Group('http')]
10698
public function an_invalid_post_authn_request_is_rejected(): void
10799
{
108100
$this->expectExceptionMessage("POST-binding is supported for SAMLRequest.");
@@ -119,10 +111,8 @@ public function an_invalid_post_authn_request_is_rejected(): void
119111
$this->factory->build($request);
120112
}
121113

122-
/**
123-
* @test
124-
* @group http
125-
*/
114+
#[\PHPUnit\Framework\Attributes\Test]
115+
#[\PHPUnit\Framework\Attributes\Group('http')]
126116
public function an_invalid_get_authn_request_is_rejected(): void
127117
{
128118
$this->expectExceptionMessage("Redirect binding is supported for SAMLRequest and Response.");

src/Tests/Unit/Http/RedirectBindingTest.php

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,9 @@ public function setUp(): void
6565
ContainerSingleton::setContainer(new MockContainer());
6666
}
6767

68-
/**
69-
* @test
70-
* @group http
71-
*
72-
* @dataProvider nonGetMethodProvider
73-
*/
68+
#[\PHPUnit\Framework\Attributes\Test]
69+
#[\PHPUnit\Framework\Attributes\DataProvider('nonGetMethodProvider')]
70+
#[\PHPUnit\Framework\Attributes\Group('http')]
7471
public function a_signed_authn_request_cannot_be_received_from_a_request_that_is_not_a_get_request(string $nonGetMethod): void
7572
{
7673
$this->expectException(BadRequestHttpException::class);
@@ -87,10 +84,8 @@ public function a_signed_authn_request_cannot_be_received_from_a_request_that_is
8784
$redirectBinding->receiveSignedAuthnRequestFrom($request);
8885
}
8986

90-
/**
91-
* @test
92-
* @group http
93-
*/
87+
#[\PHPUnit\Framework\Attributes\Test]
88+
#[\PHPUnit\Framework\Attributes\Group('http')]
9489
public function a_signed_authn_request_cannot_be_received_from_a_request_that_has_no_signed_saml_request(): void
9590
{
9691
$this->expectException(UnsignedRequestException::class);
@@ -107,10 +102,8 @@ public function a_signed_authn_request_cannot_be_received_from_a_request_that_ha
107102
$redirectBinding->receiveSignedAuthnRequestFrom($request);
108103
}
109104

110-
/**
111-
* @test
112-
* @group http
113-
*/
105+
#[\PHPUnit\Framework\Attributes\Test]
106+
#[\PHPUnit\Framework\Attributes\Group('http')]
114107
public function a_signed_authn_request_cannot_be_received_if_the_service_provider_in_the_authn_request_is_unknown(): void
115108
{
116109
$this->expectException(UnknownServiceProviderException::class);
@@ -142,9 +135,9 @@ public function a_signed_authn_request_cannot_be_received_if_the_service_provide
142135

143136
/**
144137
* Signed AuthNRequests destination MUST match the request URI
145-
* @test
146-
* @group http
147138
*/
139+
#[\PHPUnit\Framework\Attributes\Test]
140+
#[\PHPUnit\Framework\Attributes\Group('http')]
148141
public function a_signed_authn_requests_destination_must_match_request_uri(): void
149142
{
150143
$this->expectException(BadRequestHttpException::class);
@@ -171,9 +164,9 @@ public function a_signed_authn_requests_destination_must_match_request_uri(): vo
171164

172165
/**
173166
* Signed AuthNRequests destination have a destination
174-
* @test
175-
* @group http
176167
*/
168+
#[\PHPUnit\Framework\Attributes\Test]
169+
#[\PHPUnit\Framework\Attributes\Group('http')]
177170
public function a_signed_authn_requests_must_carry_a_destination(): void
178171
{
179172
$this->expectException(BadRequestHttpException::class);
@@ -198,10 +191,8 @@ public function a_signed_authn_requests_must_carry_a_destination(): void
198191
$redirectBinding->receiveSignedAuthnRequestFrom($request);
199192
}
200193

201-
/**
202-
* @test
203-
* @group http
204-
*/
194+
#[\PHPUnit\Framework\Attributes\Test]
195+
#[\PHPUnit\Framework\Attributes\Group('http')]
205196
public function a_signed_authn_request_cannot_be_received_if_the_signature_is_invalid(): void
206197
{
207198
$this->expectException(SignatureValidationFailedException::class);
@@ -239,12 +230,9 @@ public function a_signed_authn_request_cannot_be_received_if_the_signature_is_in
239230
$redirectBinding = new RedirectBinding($mockSignatureVerifier, $mockEntityRepository);
240231
$redirectBinding->receiveSignedAuthnRequestFrom($request);
241232
}
242-
/**
243-
* @test
244-
* @group http
245-
*
246-
* @dataProvider nonGetMethodProvider
247-
*/
233+
#[\PHPUnit\Framework\Attributes\Test]
234+
#[\PHPUnit\Framework\Attributes\DataProvider('nonGetMethodProvider')]
235+
#[\PHPUnit\Framework\Attributes\Group('http')]
248236
public function a_unsigned_authn_request_cannot_be_received_from_a_request_that_is_not_a_get_request(string $nonGetMethod): void
249237
{
250238
$this->expectException(BadRequestHttpException::class);
@@ -260,10 +248,8 @@ public function a_unsigned_authn_request_cannot_be_received_from_a_request_that_
260248
$redirectBinding->receiveUnsignedAuthnRequestFrom($request);
261249
}
262250

263-
/**
264-
* @test
265-
* @group http
266-
*/
251+
#[\PHPUnit\Framework\Attributes\Test]
252+
#[\PHPUnit\Framework\Attributes\Group('http')]
267253
public function a_unsigned_authn_request_cannot_be_received_if_the_service_provider_in_the_authn_request_is_unknown(): void
268254
{
269255
$this->expectException(UnknownServiceProviderException::class);
@@ -290,10 +276,8 @@ public function a_unsigned_authn_request_cannot_be_received_if_the_service_provi
290276
$redirectBinding->receiveUnsignedAuthnRequestFrom($request);
291277
}
292278

293-
/**
294-
* @test
295-
* @group http
296-
*/
279+
#[\PHPUnit\Framework\Attributes\Test]
280+
#[\PHPUnit\Framework\Attributes\Group('http')]
297281
public function a_unsigned_authn_request_cannot_be_received_if_the_service_provider_in_the_authn_request_is_unknown_with_destination(): void
298282
{
299283
$this->expectException(UnknownServiceProviderException::class);
@@ -320,7 +304,7 @@ public function a_unsigned_authn_request_cannot_be_received_if_the_service_provi
320304
$redirectBinding->receiveUnsignedAuthnRequestFrom($request);
321305
}
322306

323-
public function nonGetMethodProvider(): array
307+
public static function nonGetMethodProvider(): array
324308
{
325309
return [
326310
[Request::METHOD_POST],

src/Tests/Unit/Monolog/SamlAuthenticationLoggerTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ final class SamlAuthenticationLoggerTest extends TestCase
2929
{
3030
use MockeryPHPUnitIntegration;
3131

32-
/**
33-
* @test
34-
*/
32+
#[\PHPUnit\Framework\Attributes\Test]
3533
public function it_returns_a_logger_for_an_authentication(): void
3634
{
3735
$requestId = md5('boesboes');
@@ -44,9 +42,7 @@ public function it_returns_a_logger_for_an_authentication(): void
4442
$logger->emergency('message2');
4543
}
4644

47-
/**
48-
* @test
49-
*/
45+
#[\PHPUnit\Framework\Attributes\Test]
5046
public function it_does_not_throw_when_no_authentication(): void
5147
{
5248
$innerLogger = m::mock(LoggerInterface::class);

0 commit comments

Comments
 (0)