Skip to content

Commit

Permalink
Remove deprecated checks and update test dependencies
Browse files Browse the repository at this point in the history
The deprecated checks in the UrlKeySetFactory are removed. Slow test detection is added to PHPUnit tests with the Ergebnis\PHPUnit\SlowTestDetector dependency. Several method parameters in tests are also updated for clarity and to reduce cognitive load in parsing the test setup and assertions.
  • Loading branch information
Spomky committed Apr 9, 2024
1 parent 85544c0 commit dcc82ec
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 80 deletions.
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"ext-gmp": "*",
"ext-sodium": "*",
"ekino/phpstan-banned-code": "^1.0",
"ergebnis/phpunit-slow-test-detector": "^2.14",
"infection/infection": "^0.28",
"matthiasnoback/symfony-config-test": "^5.0",
"paragonie/sodium_compat": "^1.20",
Expand All @@ -74,13 +75,18 @@
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.4",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^10.5.10|^11.0",
"qossmic/deptrac-shim": "^1.0",
"rector/rector": "^1.0",
"roave/security-advisories": "dev-latest",
"spomky-labs/aes-key-wrap": "^7.0",
"staabm/phpstan-dba": "^0.2.79",
"staabm/phpstan-todo-by": "^0.1.25",
"struggle-for-php/sfp-phpstan-psr-log": "^0.20.0",
"symfony/browser-kit": "^7.0",
"symfony/clock": "^7.0",
"symfony/finder": "^7.0",
Expand Down
62 changes: 1 addition & 61 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ parameters:
count: 1
path: src/Bundle/DependencyInjection/JoseFrameworkExtension.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\DependencyInjection\\\\JoseFrameworkExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/DependencyInjection/JoseFrameworkExtension.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -890,16 +885,6 @@ parameters:
count: 1
path: src/Bundle/Resources/config/Algorithms/signature_experimental.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWEEncoder\\:\\:decode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWEEncoder.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWEEncoder\\:\\:encode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWEEncoder.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWEEncoder\\:\\:getRecipientIndex\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -915,26 +900,6 @@ parameters:
count: 1
path: src/Bundle/Serializer/JWEEncoder.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWESerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWESerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSEncoder\\:\\:decode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWSEncoder.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSEncoder\\:\\:encode\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWSEncoder.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSEncoder\\:\\:getSignatureIndex\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -950,16 +915,6 @@ parameters:
count: 1
path: src/Bundle/Serializer/JWSEncoder.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:denormalize\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWSSerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Bundle/Serializer/JWSSerializer.php

-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Services\\\\ClaimCheckerManager\\:\\:check\\(\\) has parameter \\$claims with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -1840,11 +1795,6 @@ parameters:
count: 1
path: src/Library/KeyManagement/KeyConverter/ECKey.php

-
message: "#^Access to an undefined property Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:\\$requestFactory\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Call to an undefined method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:sendPsrRequest\\(\\)\\.$#"
count: 1
Expand All @@ -1855,26 +1805,16 @@ parameters:
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Class Psr\\\\Http\\\\Client\\\\ClientInterface not found\\.$#"
count: 3
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Instanceof between Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface and Symfony\\\\Contracts\\\\HttpClient\\\\HttpClientInterface will always evaluate to true\\.$#"
count: 3
count: 2
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Method Jose\\\\Component\\\\KeyManagement\\\\UrlKeySetFactory\\:\\:getContent\\(\\) should return string but returns mixed\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Result of && is always false\\.$#"
count: 1
path: src/Library/KeyManagement/UrlKeySetFactory.php

-
message: "#^Parameter \\#2 \\$recipient of method Jose\\\\Component\\\\NestedToken\\\\NestedTokenLoader\\:\\:checkContentTypeHeader\\(\\) expects int, int\\|null given\\.$#"
count: 1
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@
<directory suffix=".php">./src</directory>
</include>
</source>
<extensions>
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
<parameter name="maximum-count" value="50"/>
<parameter name="maximum-duration" value="100"/>
</bootstrap>
</extensions>
</phpunit>
3 changes: 0 additions & 3 deletions src/Bundle/DependencyInjection/JoseFrameworkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public function getAlias(): string
return $this->alias;
}

/**
* @param array<array> $configs
*/
#[Override]
public function load(array $configs, ContainerBuilder $container): void
{
Expand Down
16 changes: 0 additions & 16 deletions src/Library/KeyManagement/UrlKeySetFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ abstract class UrlKeySetFactory
public function __construct(
private readonly HttpClientInterface $client,
) {
if ($this->client instanceof ClientInterface) {
trigger_deprecation(
'web-token/jwt-library',
'3.3',
'Using "%s" with an instance of "%s" is deprecated, use "%s" instead.',
self::class,
ClientInterface::class,
HttpClientInterface::class
);
}
if (! $this->client instanceof HttpClientInterface && $this->requestFactory === null) {
throw new RuntimeException(sprintf(
'The request factory must be provided when using an instance of "%s" as client.',
ClientInterface::class
));
}
$this->cacheItemPool = new NullAdapter();
}

Expand Down
2 changes: 2 additions & 0 deletions tests/Component/Console/KeySetCreationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Jose\Tests\Component\Console;

use Ergebnis\PHPUnit\SlowTestDetector\Attribute\MaximumDuration;
use InvalidArgumentException;
use Jose\Component\Console\EcKeysetGeneratorCommand;
use Jose\Component\Console\OctKeysetGeneratorCommand;
Expand Down Expand Up @@ -158,6 +159,7 @@ public function iCannotCreateAnRsaKeySetWithoutKeySetSize(): void
}

#[Test]
#[MaximumDuration(500)]
public function iCanCreateAnRsaKeySet(): void
{
$input = new ArrayInput([
Expand Down
2 changes: 2 additions & 0 deletions tests/Component/KeyManagement/JWKFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Jose\Tests\Component\KeyManagement;

use Ergebnis\PHPUnit\SlowTestDetector\Attribute\MaximumDuration;
use Jose\Component\Core\Util\Base64UrlSafe;
use Jose\Component\Core\Util\ECKey;
use Jose\Component\KeyManagement\JWKFactory;
Expand Down Expand Up @@ -231,6 +232,7 @@ public function createFromValues(): void

#[DataProvider('dataKeys')]
#[Test]
#[MaximumDuration(500)]
public function loadKeyPEMEncoded(string $filename, array $expectedValues): void
{
$jwk = JWKFactory::createFromKeyFile($filename);
Expand Down

0 comments on commit dcc82ec

Please sign in to comment.