Skip to content

Commit b7bdf8a

Browse files
authored
refactor: improve test method names and update PHPUnit configuration (#765)
refactor: improve test method names and update PHPUnit configuration
1 parent 1959079 commit b7bdf8a

File tree

48 files changed

+671
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+671
-439
lines changed

.ci-tools/phpstan-baseline.neon

Lines changed: 3 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,6 @@ parameters:
777777
count: 3
778778
path: ../src/symfony/src/DependencyInjection/WebauthnExtension.php
779779

780-
-
781-
rawMessage: 'Method Webauthn\Bundle\DependencyInjection\WebauthnExtension::getAlias() has Symfony\Component\DependencyInjection\Exception\BadMethodCallException in PHPDoc @throws tag but it''s not thrown.'
782-
identifier: throws.unusedType
783-
count: 1
784-
path: ../src/symfony/src/DependencyInjection/WebauthnExtension.php
785-
786780
-
787781
rawMessage: 'Method Webauthn\Bundle\DependencyInjection\WebauthnExtension::getConfiguration() has a parameter $container with a type declaration of Symfony\Component\DependencyInjection\ContainerBuilder, but containers should not be injected.'
788782
identifier: ergebnis.noParameterWithContainerTypeDeclaration
@@ -1644,12 +1638,6 @@ parameters:
16441638
count: 1
16451639
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
16461640

1647-
-
1648-
rawMessage: 'Method Webauthn\Bundle\Security\Authentication\WebauthnBadge::getUser() has Symfony\Component\Security\Core\Exception\AuthenticationException in PHPDoc @throws tag but it''s not thrown.'
1649-
identifier: throws.unusedType
1650-
count: 1
1651-
path: ../src/symfony/src/Security/Authentication/WebauthnBadge.php
1652-
16531641
-
16541642
rawMessage: 'Method Webauthn\Bundle\Security\Authentication\WebauthnBadge::getUserLoader() has a nullable return type declaration.'
16551643
identifier: ergebnis.noNullableReturnTypeDeclaration
@@ -4101,7 +4089,7 @@ parameters:
41014089
-
41024090
rawMessage: 'Parameter #2 $array of function array_key_exists expects array, mixed given.'
41034091
identifier: argument.type
4104-
count: 2
4092+
count: 1
41054093
path: ../src/webauthn/src/Denormalizer/AuthenticatorResponseDenormalizer.php
41064094

41074095
-
@@ -4188,12 +4176,6 @@ parameters:
41884176
count: 1
41894177
path: ../src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php
41904178

4191-
-
4192-
rawMessage: 'Only iterables can be unpacked, mixed given in argument #1.'
4193-
identifier: argument.unpackNonIterable
4194-
count: 1
4195-
path: ../src/webauthn/src/Denormalizer/ExtensionDescriptorDenormalizer.php
4196-
41974179
-
41984180
rawMessage: 'Parameter #1 $id of static method Webauthn\MetadataService\Statement\ExtensionDescriptor::create() expects string, mixed given.'
41994181
identifier: argument.type
@@ -4296,90 +4278,12 @@ parameters:
42964278
count: 1
42974279
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
42984280

4299-
-
4300-
rawMessage: Cannot access offset 'allowCredentials' on mixed.
4301-
identifier: offsetAccess.nonOffsetAccessible
4302-
count: 1
4303-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4304-
4305-
-
4306-
rawMessage: Cannot access offset 'attestation' on mixed.
4307-
identifier: offsetAccess.nonOffsetAccessible
4308-
count: 1
4309-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4310-
4311-
-
4312-
rawMessage: Cannot access offset 'authenticatorSelection' on mixed.
4313-
identifier: offsetAccess.nonOffsetAccessible
4314-
count: 1
4315-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4316-
4317-
-
4318-
rawMessage: Cannot access offset 'challenge' on mixed.
4319-
identifier: offsetAccess.nonOffsetAccessible
4320-
count: 2
4321-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4322-
4323-
-
4324-
rawMessage: Cannot access offset 'excludeCredentials' on mixed.
4325-
identifier: offsetAccess.nonOffsetAccessible
4326-
count: 1
4327-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4328-
4329-
-
4330-
rawMessage: Cannot access offset 'extensions' on mixed.
4331-
identifier: offsetAccess.nonOffsetAccessible
4332-
count: 2
4333-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4334-
4335-
-
4336-
rawMessage: Cannot access offset 'hints' on mixed.
4337-
identifier: offsetAccess.nonOffsetAccessible
4338-
count: 2
4339-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4340-
43414281
-
43424282
rawMessage: Cannot access offset 'id' on mixed.
43434283
identifier: offsetAccess.nonOffsetAccessible
43444284
count: 2
43454285
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
43464286

4347-
-
4348-
rawMessage: Cannot access offset 'pubKeyCredParams' on mixed.
4349-
identifier: offsetAccess.nonOffsetAccessible
4350-
count: 1
4351-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4352-
4353-
-
4354-
rawMessage: Cannot access offset 'rp' on mixed.
4355-
identifier: offsetAccess.nonOffsetAccessible
4356-
count: 1
4357-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4358-
4359-
-
4360-
rawMessage: Cannot access offset 'rpId' on mixed.
4361-
identifier: offsetAccess.nonOffsetAccessible
4362-
count: 1
4363-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4364-
4365-
-
4366-
rawMessage: Cannot access offset 'timeout' on mixed.
4367-
identifier: offsetAccess.nonOffsetAccessible
4368-
count: 2
4369-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4370-
4371-
-
4372-
rawMessage: Cannot access offset 'user' on mixed.
4373-
identifier: offsetAccess.nonOffsetAccessible
4374-
count: 1
4375-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4376-
4377-
-
4378-
rawMessage: Cannot access offset 'userVerification' on mixed.
4379-
identifier: offsetAccess.nonOffsetAccessible
4380-
count: 1
4381-
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
4382-
43834287
-
43844288
rawMessage: Cannot access offset mixed on mixed.
43854289
identifier: offsetAccess.nonOffsetAccessible
@@ -4389,7 +4293,7 @@ parameters:
43894293
-
43904294
rawMessage: 'Language construct isset() should not be used.'
43914295
identifier: ergebnis.noIsset
4392-
count: 6
4296+
count: 7
43934297
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
43944298

43954299
-
@@ -4467,7 +4371,7 @@ parameters:
44674371
-
44684372
rawMessage: 'Parameter #2 $array of function array_key_exists expects array, mixed given.'
44694373
identifier: argument.type
4470-
count: 2
4374+
count: 1
44714375
path: ../src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
44724376

44734377
-
@@ -5097,12 +5001,6 @@ parameters:
50975001
count: 1
50985002
path: ../src/webauthn/src/Denormalizer/TrustPathDenormalizer.php
50995003

5100-
-
5101-
rawMessage: 'Method Webauthn\Denormalizer\TrustPathDenormalizer::normalize() has Symfony\Component\Serializer\Exception\ExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5102-
identifier: throws.unusedType
5103-
count: 1
5104-
path: ../src/webauthn/src/Denormalizer/TrustPathDenormalizer.php
5105-
51065004
-
51075005
rawMessage: 'Method Webauthn\Denormalizer\TrustPathDenormalizer::normalize() has parameter $format with a nullable type declaration.'
51085006
identifier: ergebnis.noParameterWithNullableTypeDeclaration
@@ -5895,60 +5793,6 @@ parameters:
58955793
count: 1
58965794
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
58975795

5898-
-
5899-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getContent() has Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5900-
identifier: throws.unusedType
5901-
count: 1
5902-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5903-
5904-
-
5905-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getContent() has Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5906-
identifier: throws.unusedType
5907-
count: 1
5908-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5909-
5910-
-
5911-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getContent() has Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5912-
identifier: throws.unusedType
5913-
count: 1
5914-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5915-
5916-
-
5917-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getContent() has Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5918-
identifier: throws.unusedType
5919-
count: 1
5920-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5921-
5922-
-
5923-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getHeaders() has Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5924-
identifier: throws.unusedType
5925-
count: 1
5926-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5927-
5928-
-
5929-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getHeaders() has Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5930-
identifier: throws.unusedType
5931-
count: 1
5932-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5933-
5934-
-
5935-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getHeaders() has Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5936-
identifier: throws.unusedType
5937-
count: 1
5938-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5939-
5940-
-
5941-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getHeaders() has Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5942-
identifier: throws.unusedType
5943-
count: 1
5944-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5945-
5946-
-
5947-
rawMessage: 'Method Symfony\Contracts\HttpClient\ResponseInterface@anonymous/webauthn/src/MetadataService/Psr18HttpClient.php:75::getStatusCode() has Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface in PHPDoc @throws tag but it''s not thrown.'
5948-
identifier: throws.unusedType
5949-
count: 1
5950-
path: ../src/webauthn/src/MetadataService/Psr18HttpClient.php
5951-
59525796
-
59535797
rawMessage: 'Method Webauthn\MetadataService\Psr18HttpClient::request() has parameter $options with no value type specified in iterable type array.'
59545798
identifier: missingType.iterableValue

.ci-tools/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<server name="SHELL_VERBOSITY" value="-1" />
2020
<server name="KERNEL_CLASS" value="Webauthn\Tests\Bundle\Functional\AppKernel"/>
2121
</php>
22-
<source>
22+
<source ignoreIndirectDeprecations="true">
2323
<include>
2424
<directory>./../src</directory>
2525
</include>

castor.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,18 @@ function phpqa_update(): void
133133
run(['docker', 'pull', 'ghcr.io/spomky-labs/phpqa:' . $phpVersion]);
134134
}
135135

136-
#[AsTask(description: 'Run PHPUnit tests with coverage')]
137-
function phpunit(): void
136+
#[AsTask(description: 'Run PHPUnit tests with coverage', ignoreValidationErrors: true)]
137+
function phpunit(#[AsRawTokens] array $args = []): void
138138
{
139139
phpqa(
140140
[
141141
'composer', 'exec', '--', 'phpunit-11',
142142
'--coverage-xml', '.ci-tools/coverage',
143143
'--log-junit=.ci-tools/coverage/junit.xml',
144144
'--configuration', '.ci-tools/phpunit.xml.dist',
145+
'--display-warnings',
146+
'--display-deprecations',
147+
...$args,
145148
],
146149
['-e', 'XDEBUG_MODE=coverage']
147150
);

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@
8888
"web-token/jwt-library": "Mandatory for fetching Metadata Statement from distant sources",
8989
"symfony/security-bundle": "Symfony firewall using a JSON API (perfect for script applications)"
9090
},
91-
"minimum-stability": "beta",
9291
"require-dev": {
9392
"doctrine/dbal": "^3.8|^4.0",
94-
"symfony/doctrine-bridge": "^6.4|^7.0|^8.0",
9593
"doctrine/doctrine-bundle": "^2.12",
9694
"doctrine/orm": "^2.14|^3.0",
9795
"doctrine/persistence": "^3.1|^4.0",
@@ -103,11 +101,13 @@
103101
"symfony/asset": "^6.4|^7.0|^8.0",
104102
"symfony/asset-mapper": "^6.4|^7.0|^8.0",
105103
"symfony/browser-kit": "^6.4|^7.0|^8.0",
104+
"symfony/doctrine-bridge": "^6.4|^7.0|^8.0",
106105
"symfony/filesystem": "^6.4|^7.0|^8.0",
107106
"symfony/finder": "^6.4|^7.0|^8.0",
108107
"symfony/monolog-bundle": "^3.8",
109108
"symfony/twig-bundle": "^6.4|^7.0|^8.0",
110109
"symfony/var-dumper": "^6.4|^7.0|^8.0",
110+
"symfony/var-exporter": "^6.4|^7.0|^8.0",
111111
"symfony/yaml": "^6.4|^7.0|^8.0",
112112
"web-token/jwt-library": "^3.4|^4.0"
113113
},

src/webauthn/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
4545
}
4646
if ($type === PublicKeyCredentialCreationOptions::class) {
4747
return PublicKeyCredentialCreationOptions::create(
48-
$this->denormalizer->denormalize($data['rp'], PublicKeyCredentialRpEntity::class, $format, $context),
48+
! isset($data['rp']) ? PublicKeyCredentialRpEntity::create() : $this->denormalizer->denormalize(
49+
$data['rp'],
50+
PublicKeyCredentialRpEntity::class,
51+
$format,
52+
$context
53+
),
4954
$this->denormalizer->denormalize(
5055
$data['user'],
5156
PublicKeyCredentialUserEntity::class,

tests/MDS/Unit/BiometricAccuracyDescriptorObjectTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class BiometricAccuracyDescriptorObjectTest extends MdsTestCase
1717
{
1818
#[Test]
1919
#[DataProvider('validObjectData')]
20-
public function validObject(
20+
public function validBiometricAccuracyDescriptorSerializesCorrectly(
2121
BiometricAccuracyDescriptor $object,
2222
?float $selfAttestedFAR,
2323
?float $selfAttestedFRR,
@@ -26,14 +26,22 @@ public function validObject(
2626
?int $blockSlowdown,
2727
string $expectedJson
2828
): void {
29+
// Given
30+
// Object provided by data provider
31+
32+
// When
33+
$serialized = $this->getSerializer()
34+
->serialize($object, JsonEncoder::FORMAT, [
35+
AbstractObjectNormalizer::SKIP_NULL_VALUES => true,
36+
]);
37+
38+
// Then
2939
static::assertSame($selfAttestedFAR, $object->selfAttestedFRR);
3040
static::assertSame($selfAttestedFRR, $object->selfAttestedFAR);
3141
static::assertSame($maxTemplates, $object->maxTemplates);
3242
static::assertSame($maxRetries, $object->maxRetries);
3343
static::assertSame($blockSlowdown, $object->blockSlowdown);
34-
static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [
35-
AbstractObjectNormalizer::SKIP_NULL_VALUES => true,
36-
]));
44+
static::assertSame($expectedJson, $serialized);
3745
}
3846

3947
public static function validObjectData(): iterable

tests/MDS/Unit/CodeAccuracyDescriptorObjectTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,29 @@ final class CodeAccuracyDescriptorObjectTest extends MdsTestCase
1818
{
1919
#[Test]
2020
#[DataProvider('validObjectData')]
21-
public function validObject(
21+
public function validCodeAccuracyDescriptorSerializesCorrectly(
2222
CodeAccuracyDescriptor $object,
2323
int $base,
2424
int $minLength,
2525
?int $maxRetries,
2626
?int $blockSlowdown,
2727
string $expectedJson
2828
): void {
29+
// Given
30+
// Object provided by data provider
31+
32+
// When
33+
$serialized = $this->getSerializer()
34+
->serialize($object, JsonEncoder::FORMAT, [
35+
AbstractObjectNormalizer::SKIP_NULL_VALUES => true,
36+
]);
37+
38+
// Then
2939
static::assertSame($base, $object->base);
3040
static::assertSame($minLength, $object->minLength);
3141
static::assertSame($maxRetries, $object->maxRetries);
3242
static::assertSame($blockSlowdown, $object->blockSlowdown);
33-
static::assertSame($expectedJson, $this->getSerializer()->serialize($object, JsonEncoder::FORMAT, [
34-
AbstractObjectNormalizer::SKIP_NULL_VALUES => true,
35-
]));
43+
static::assertSame($expectedJson, $serialized);
3644
}
3745

3846
public static function validObjectData(): iterable
@@ -50,16 +58,21 @@ public static function validObjectData(): iterable
5058

5159
#[Test]
5260
#[DataProvider('invalidObjectData')]
53-
public function invalidObject(
61+
public function creatingCodeAccuracyDescriptorWithInvalidValuesThrowsException(
5462
int $base,
5563
int $minLength,
5664
?int $maxRetries,
5765
?int $blockSlowdown,
5866
string $expectedMessage
5967
): void {
68+
// Then
6069
$this->expectException(MetadataStatementLoadingException::class);
6170
$this->expectExceptionMessage($expectedMessage);
6271

72+
// Given
73+
// Parameters provided by data provider
74+
75+
// When
6376
CodeAccuracyDescriptor::create($base, $minLength, $maxRetries, $blockSlowdown);
6477
}
6578

0 commit comments

Comments
 (0)