From deae7fcda45f8fd890114377c007ba07d62d734a Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Tue, 20 Jan 2026 08:20:53 -0800 Subject: [PATCH 01/19] chore: replace expect deprecation with expectException Instead of using expectDeprecation now we use expectException but we do use the set_error_handler to throw that expected exceptions when expecting warnings or user notices. --- src/AwsClient.php | 23 ----------------------- src/ClientResolver.php | 17 ----------------- tests/AwsClientTest.php | 10 ++++++++-- tests/ClientResolverTest.php | 19 ------------------- tests/Handler/GuzzleV6/HandlerTest.php | 7 +++++-- tests/S3/ApplyChecksumMiddlewareTest.php | 7 +++++-- tests/S3/MultipartUploaderTest.php | 7 +++++-- tests/S3/ObjectUploaderTest.php | 7 +++++-- tests/S3/S3ClientTest.php | 5 ++++- tests/S3/TransferTest.php | 8 +++++--- 10 files changed, 37 insertions(+), 73 deletions(-) diff --git a/src/AwsClient.php b/src/AwsClient.php index a19b794119..d7683f0ffa 100644 --- a/src/AwsClient.php +++ b/src/AwsClient.php @@ -737,29 +737,6 @@ protected function isUseEndpointV2() return $this->endpointProvider instanceof EndpointProviderV2; } - public static function emitDeprecationWarning() { - trigger_error( - "This method is deprecated. It will be removed in an upcoming release." - , E_USER_DEPRECATED - ); - - $phpVersion = PHP_VERSION_ID; - if ($phpVersion < 70205) { - $phpVersionString = phpversion(); - @trigger_error( - "This installation of the SDK is using PHP version" - . " {$phpVersionString}, which will be deprecated on August" - . " 15th, 2023. Please upgrade your PHP version to a minimum of" - . " 7.2.5 before then to continue receiving updates to the AWS" - . " SDK for PHP. To disable this warning, set" - . " suppress_php_deprecation_warning to true on the client constructor" - . " or set the environment variable AWS_SUPPRESS_PHP_DEPRECATION_WARNING" - . " to true.", - E_USER_DEPRECATED - ); - } - } - /** * Returns a service model and doc model with any necessary changes diff --git a/src/ClientResolver.php b/src/ClientResolver.php index d8751b1148..ce8eb2bc23 100644 --- a/src/ClientResolver.php +++ b/src/ClientResolver.php @@ -1440,21 +1440,4 @@ private static function isValidApiVersion($service, $apiVersion) __DIR__ . "/data/{$service}/$apiVersion" ); } - - private static function emitDeprecationWarning() - { - $phpVersionString = phpversion(); - trigger_error( - "This installation of the SDK is using PHP version" - . " {$phpVersionString}, which will be deprecated on January" - . " 13th, 2025.\nPlease upgrade your PHP version to a minimum of" - . " 8.1.x to continue receiving updates for the AWS" - . " SDK for PHP.\nTo disable this warning, set" - . " suppress_php_deprecation_warning to true on the client constructor" - . " or set the environment variable AWS_SUPPRESS_PHP_DEPRECATION_WARNING" - . " to true.\nMore information can be found at: " - . "https://aws.amazon.com/blogs/developer/announcing-the-end-of-support-for-php-runtimes-8-0-x-and-below-in-the-aws-sdk-for-php/\n", - E_USER_DEPRECATED - ); - } } diff --git a/tests/AwsClientTest.php b/tests/AwsClientTest.php index 6523a5cf7f..ff62971a06 100644 --- a/tests/AwsClientTest.php +++ b/tests/AwsClientTest.php @@ -775,10 +775,16 @@ public function testAppliesConfiguredSignatureVersionViaClientConfig() { } + /** + * @return void + */ public function testCallingEmitDeprecationWarningEmitsDeprecationWarning() { - $this->expectDeprecation(); - $this->expectDeprecationMessage( + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( "This method is deprecated. It will be removed in an upcoming release." ); $client = $this->createClient(); diff --git a/tests/ClientResolverTest.php b/tests/ClientResolverTest.php index 123cf11098..3f0c3ecfcc 100644 --- a/tests/ClientResolverTest.php +++ b/tests/ClientResolverTest.php @@ -1433,25 +1433,6 @@ public function testAppliesAuthSchemeResolver() ); } - public function testEmitsDeprecationWarning() - { - if (PHP_VERSION_ID >= 80100) { - $this->markTestSkipped(); - } - - putenv('AWS_SUPPRESS_PHP_DEPRECATION_WARNING=false'); - $this->expectDeprecation(); - $this->expectDeprecationMessage('This installation of the SDK is using PHP version'); - - $r = new ClientResolver(ClientResolver::getDefaultArguments()); - - try { - $r->resolve(['service' => 'sqs', 'region' => 'x'], new HandlerList()); - } finally { - putenv('AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true'); - } - } - /** * Tests the flag `use_aws_shared_config_files` is applied to the method * for resolving a default value for a config. diff --git a/tests/Handler/GuzzleV6/HandlerTest.php b/tests/Handler/GuzzleV6/HandlerTest.php index 1a2f0b64f7..38feebbc23 100644 --- a/tests/Handler/GuzzleV6/HandlerTest.php +++ b/tests/Handler/GuzzleV6/HandlerTest.php @@ -7,8 +7,11 @@ class HandlerTest extends TestCase { public function testV6ClassExists(): void { - $this->expectDeprecation(); - $this->expectDeprecationMessage( + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( 'Using the "Aws\Handler\GuzzleV6\GuzzleHandler" class is deprecated, use "Aws\Handler\Guzzle\GuzzleHandler" instead.' ); $this->assertTrue(class_exists(\Aws\Handler\GuzzleV6\GuzzleHandler::class)); diff --git a/tests/S3/ApplyChecksumMiddlewareTest.php b/tests/S3/ApplyChecksumMiddlewareTest.php index 5abae7fb63..361aebd2e1 100644 --- a/tests/S3/ApplyChecksumMiddlewareTest.php +++ b/tests/S3/ApplyChecksumMiddlewareTest.php @@ -246,8 +246,11 @@ public function getContentSha256UseCases() public function testAddContentMd5EmitsDeprecationWarning() { - $this->expectDeprecation(); - $this->expectDeprecationMessage('S3 no longer supports MD5 checksums.'); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); $client = $this->getTestClient('s3'); $nextHandler = function ($cmd, $request) { $this->assertTrue($request->hasHeader('x-amz-checksum-crc32')); diff --git a/tests/S3/MultipartUploaderTest.php b/tests/S3/MultipartUploaderTest.php index 741a49644d..1885a0274d 100644 --- a/tests/S3/MultipartUploaderTest.php +++ b/tests/S3/MultipartUploaderTest.php @@ -352,8 +352,11 @@ public function testUploaderAddsFlexibleChecksums($stream, $size) public function testAddContentMd5EmitsDeprecationNotice() { - $this->expectDeprecation(); - $this->expectDeprecationMessage('S3 no longer supports MD5 checksums.'); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); $data = str_repeat('.', 12 * self::MB); $filename = sys_get_temp_dir() . '/' . self::FILENAME; file_put_contents($filename, $data); diff --git a/tests/S3/ObjectUploaderTest.php b/tests/S3/ObjectUploaderTest.php index de6ae0d3cc..8edbdf3a32 100644 --- a/tests/S3/ObjectUploaderTest.php +++ b/tests/S3/ObjectUploaderTest.php @@ -364,11 +364,14 @@ public function flexibleChecksumsProvider() { public function testAddContentMd5EmitsDeprecationNotice() { - $this->expectDeprecation(); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); $client = $this->getTestClient('S3'); $this->addMockResults($client, [new Result()]); - $result = (new ObjectUploader( + (new ObjectUploader( $client, 'bucket', 'key', diff --git a/tests/S3/S3ClientTest.php b/tests/S3/S3ClientTest.php index 5545d635f4..833314672e 100644 --- a/tests/S3/S3ClientTest.php +++ b/tests/S3/S3ClientTest.php @@ -2310,7 +2310,10 @@ public function addMD5Provider() { */ public function testAddContentMd5EmitsDeprecationNotice($options, $operation) { - $this->expectDeprecation(); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); $s3 = $this->getTestClient('s3'); $this->addMockResults($s3, [[]]); diff --git a/tests/S3/TransferTest.php b/tests/S3/TransferTest.php index bd95ac2d64..e957016afc 100644 --- a/tests/S3/TransferTest.php +++ b/tests/S3/TransferTest.php @@ -517,9 +517,11 @@ public function testAddContentMd5EmitsDeprecationWarning() { $s3 = $this->getTestClient('s3'); $this->addMockResults($s3, []); - - $this->expectDeprecation(); - $this->expectDeprecationMessage('S3 no longer supports MD5 checksums.'); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); $s3->getHandlerList()->appendSign(Middleware::tap( function (CommandInterface $cmd, RequestInterface $req) { $this->assertTrue(isset($command['x-amz-checksum-crc32'])); From 3f29272a81a0fc9df8a4e4dd602b1b3e22b24971 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Tue, 20 Jan 2026 08:24:37 -0800 Subject: [PATCH 02/19] chore: make data provider static functions --- tests/Api/DateTimeResultTest.php | 2 +- .../ErrorParser/JsonRpcErrorParserTest.php | 2 +- .../ErrorParser/RestJsonErrorParserTest.php | 2 +- tests/Api/ErrorParser/XmlErrorParserTest.php | 2 +- tests/Api/Parser/ComplianceTest.php | 2 +- .../DecodingEventStreamIteratorTest.php | 2 +- tests/Api/Parser/EventParsingIteratorTest.php | 4 +- tests/Api/Parser/JsonParserTest.php | 4 +- ...eStreamDecodingEventStreamIteratorTest.php | 2 +- tests/Api/Parser/RestJsonParserTest.php | 2 +- tests/Api/Parser/XmlParserTest.php | 4 +- tests/Api/Serializer/ComplianceTest.php | 2 +- tests/Api/Serializer/JsonBodyTest.php | 6 +-- .../Api/Serializer/RestJsonSerializerTest.php | 16 +++---- .../Api/Serializer/RestXmlSerializerTest.php | 10 ++-- tests/Api/ServiceTest.php | 8 ++-- tests/Api/SupportedProtocolsTest.php | 4 +- tests/Api/TimestampShapeTest.php | 2 +- tests/Api/ValidatorTest.php | 2 +- tests/Arn/AccessPointArnTest.php | 4 +- tests/Arn/ArnParserTest.php | 4 +- tests/Arn/ArnTest.php | 4 +- tests/Arn/S3/AccessPointArnTest.php | 2 +- tests/Arn/S3/OutpostsAccessPointArnTest.php | 4 +- tests/Arn/S3/OutpostsBucketArnTest.php | 4 +- tests/Auth/AuthSchemeResolverTest.php | 4 +- tests/Auth/AuthSelectionMiddlewareTest.php | 6 +-- tests/AwsClientTest.php | 6 +-- tests/Build/Docs/CodeSnippetGeneratorTest.php | 2 +- tests/ClientResolverTest.php | 22 ++++----- .../ConfigurationProviderTest.php | 2 +- tests/CloudFront/SignerTest.php | 4 +- tests/CloudFront/UrlSignerTest.php | 2 +- tests/CloudTrail/LogFileReaderTest.php | 2 +- tests/ConfigurationResolverTest.php | 4 +- .../AssumeRoleCredentialProviderTest.php | 2 +- ...eWithWebIdentityCredentialProviderTest.php | 4 +- tests/Credentials/CredentialProviderTest.php | 6 +-- tests/Credentials/CredentialsUtilsTest.php | 2 +- .../Credentials/EcsCredentialProviderTest.php | 6 +-- .../InstanceProfileProviderTest.php | 12 ++--- .../LoginCredentialProviderTest.php | 6 +-- tests/Crypto/AesGcmEncryptingStreamTest.php | 2 +- tests/DSQL/AuthTokenGeneratorTest.php | 8 ++-- .../ConfigurationProviderTest.php | 2 +- tests/DocDb/DocDbClientTest.php | 2 +- tests/DynamoDb/DynamoDbClientTest.php | 2 +- tests/DynamoDb/MarshalerTest.php | 2 +- tests/DynamoDb/WriteRequestBatchTest.php | 2 +- .../PartitionEndpointProviderTest.php | 6 +-- tests/Endpoint/PartitionTest.php | 24 +++++----- .../Endpoint/PatternEndpointProviderTest.php | 2 +- .../ConfigurationTest.php | 2 +- .../UseFipsEndpoint/ConfigurationTest.php | 2 +- .../ConfigurationProviderTest.php | 4 +- .../EndpointDiscoveryMiddlewareTest.php | 6 +-- tests/EndpointParameterMiddlewareTest.php | 2 +- .../EndpointDefinitionProviderTest.php | 2 +- tests/EndpointV2/EndpointProviderV2Test.php | 8 ++-- tests/EndpointV2/EndpointV2MiddlewareTest.php | 6 +-- tests/EndpointV2/RuleCreatorTest.php | 2 +- tests/EndpointV2/RulesetParameterTest.php | 4 +- .../EndpointV2/RulesetStandardLibraryTest.php | 16 +++---- tests/EventBridge/EventBridgeClientTest.php | 4 +- tests/Exception/AwsExceptionTest.php | 2 +- .../MultipartUploadExceptionTest.php | 2 +- tests/FunctionsTest.php | 10 ++-- tests/Glacier/MultipartUploaderTest.php | 2 +- tests/InputValidationMiddlewareTest.php | 4 +- tests/MetricsBuilderTest.php | 2 +- tests/MiddlewareTest.php | 2 +- tests/MultiRegionClientTest.php | 2 +- tests/Multipart/AbstractUploaderTest.php | 2 +- tests/Multipart/UploadStateTest.php | 6 +-- tests/Neptune/NeptuneClientTest.php | 2 +- tests/PresignUrlMiddlewareTest.php | 2 +- tests/Psr16CacheAdapterTest.php | 2 +- tests/PsrCacheAdapterTest.php | 2 +- tests/QueryCompatibleInputMiddlewareTest.php | 2 +- tests/Rds/AuthTokenGeneratorTest.php | 4 +- tests/Rds/RdsClientTest.php | 2 +- .../RequestCompressionMiddlewareTest.php | 6 +-- tests/Retry/ConfigurationProviderTest.php | 2 +- tests/Retry/RateLimiterTest.php | 2 +- tests/RetryMiddlewareTest.php | 2 +- tests/RetryMiddlewareV2Test.php | 2 +- tests/S3/AmbiguousSuccessParserTest.php | 4 +- tests/S3/ApplyChecksumMiddlewareTest.php | 4 +- tests/S3/BucketEndpointArnMiddlewareTest.php | 4 +- tests/S3/BucketEndpointMiddlewareTest.php | 2 +- tests/S3/GetBucketLocationParserTest.php | 2 +- tests/S3/MultipartCopyTest.php | 2 +- tests/S3/MultipartUploaderTest.php | 6 +-- tests/S3/ObjectCopierTest.php | 6 +-- tests/S3/ObjectUploaderTest.php | 6 +-- .../GetBucketLocationResultMutatorTest.php | 2 +- tests/S3/Parser/S3ParserTest.php | 4 +- ...idateResponseChecksumResultMutatorTest.php | 2 +- tests/S3/PostObjectTest.php | 2 +- tests/S3/PostObjectV4Test.php | 4 +- .../ConfigurationProviderTest.php | 2 +- tests/S3/S3ClientTest.php | 48 +++++++++---------- tests/S3/S3EndpointMiddlewareTest.php | 12 ++--- tests/S3/S3MultiRegionClientTest.php | 2 +- tests/S3/S3Transfer/MultipartUploaderTest.php | 12 ++--- .../PartGetMultipartDownloaderTest.php | 4 +- .../AbstractProgressBarFormatTest.php | 2 +- .../Progress/ConsoleProgressBarTest.php | 2 +- .../Progress/MultiProgressTrackerTest.php | 4 +- .../Progress/SingleProgressTrackerTest.php | 4 +- .../Progress/TransferProgressSnapshotTest.php | 2 +- .../RangeGetMultipartDownloaderTest.php | 4 +- tests/S3/S3Transfer/S3TransferManagerTest.php | 32 ++++++------- tests/S3/S3UriParserTest.php | 2 +- tests/S3/SSECMiddlewareTest.php | 2 +- tests/S3/StreamWrapperPathStyleTest.php | 4 +- tests/S3/StreamWrapperTest.php | 6 +-- tests/S3/StreamWrapperV2ExistenceTest.php | 4 +- tests/S3/TransferTest.php | 4 +- tests/S3/UseArnRegion/ConfigurationTest.php | 2 +- .../S3/ValidateResponseChecksumParserTest.php | 2 +- tests/S3Control/EndpointArnMiddlewareTest.php | 4 +- tests/Script/ComposerTest.php | 6 +-- tests/Signature/SignatureProviderTest.php | 2 +- tests/Signature/SignatureV4Test.php | 8 ++-- tests/StreamRequestPayloadMiddlewareTest.php | 2 +- .../ConfigurationProviderTest.php | 2 +- tests/Sts/StsClientTest.php | 8 ++-- tests/Token/BearerTokenAuthorizationTest.php | 2 +- tests/Token/BedrockTokenProviderTest.php | 4 +- tests/Token/TokenProviderTest.php | 6 +-- tests/TraceMiddlewareTest.php | 2 +- tests/UserAgentMiddlewareTest.php | 6 +-- tests/WaiterTest.php | 4 +- tests/WrappedHttpHandlerTest.php | 2 +- 135 files changed, 315 insertions(+), 315 deletions(-) diff --git a/tests/Api/DateTimeResultTest.php b/tests/Api/DateTimeResultTest.php index f8fe015904..7f79a557d9 100644 --- a/tests/Api/DateTimeResultTest.php +++ b/tests/Api/DateTimeResultTest.php @@ -61,7 +61,7 @@ public function testIso8601NanosecondPrecision($timestamp, $expected) $this->assertEquals($expected, (string) $parsed); } - public function nanosecondPrecisionProvider() + public static function nanosecondPrecisionProvider() { return [ ['2024-07-31T19:05:47.1234567Z', '2024-07-31T19:05:47+00:00'], diff --git a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php index 0149db699c..babb688bf0 100644 --- a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php +++ b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php @@ -49,7 +49,7 @@ public function testParsesClientErrorResponses( } } - public function errorResponsesProvider() + public static function errorResponsesProvider() { $service = $this->generateTestService('json'); $awsQueryCompatibleService = $this->generateTestService( diff --git a/tests/Api/ErrorParser/RestJsonErrorParserTest.php b/tests/Api/ErrorParser/RestJsonErrorParserTest.php index 800a2dc3ed..62581ca963 100644 --- a/tests/Api/ErrorParser/RestJsonErrorParserTest.php +++ b/tests/Api/ErrorParser/RestJsonErrorParserTest.php @@ -46,7 +46,7 @@ public function testParsesClientErrorResponses( } } - public function errorResponsesProvider() + public static function errorResponsesProvider() { $service = $this->generateTestService('rest-json'); $shapes = $service->getErrorShapes(); diff --git a/tests/Api/ErrorParser/XmlErrorParserTest.php b/tests/Api/ErrorParser/XmlErrorParserTest.php index 3bc73e5f19..207dd5498d 100644 --- a/tests/Api/ErrorParser/XmlErrorParserTest.php +++ b/tests/Api/ErrorParser/XmlErrorParserTest.php @@ -41,7 +41,7 @@ public function testParsesClientErrorResponses( } } - public function errorResponsesProvider() + public static function errorResponsesProvider() { $ec2Service = $this->generateTestService('ec2'); $ec2Client = $this->generateTestClient($ec2Service); diff --git a/tests/Api/Parser/ComplianceTest.php b/tests/Api/Parser/ComplianceTest.php index 5a63710c5c..b1f679f123 100644 --- a/tests/Api/Parser/ComplianceTest.php +++ b/tests/Api/Parser/ComplianceTest.php @@ -48,7 +48,7 @@ class ComplianceTest extends TestCase ]; /** @doesNotPerformAssertions */ - public function testCaseProvider(): \Generator + public static function testCaseProvider(): \Generator { $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( diff --git a/tests/Api/Parser/DecodingEventStreamIteratorTest.php b/tests/Api/Parser/DecodingEventStreamIteratorTest.php index 8afe8cdd73..a451a7875b 100644 --- a/tests/Api/Parser/DecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/DecodingEventStreamIteratorTest.php @@ -13,7 +13,7 @@ */ class DecodingEventStreamIteratorTest extends TestCase { - public function complianceTests(): \Generator + public static function complianceTests(): \Generator { $dataFilesIterator = \Aws\recursive_dir_iterator( realpath(__DIR__ . '/../test_cases/eventstream/encoded/') diff --git a/tests/Api/Parser/EventParsingIteratorTest.php b/tests/Api/Parser/EventParsingIteratorTest.php index f8d7c4d4e7..2f7398c9f3 100644 --- a/tests/Api/Parser/EventParsingIteratorTest.php +++ b/tests/Api/Parser/EventParsingIteratorTest.php @@ -67,7 +67,7 @@ class EventParsingIteratorTest extends TestCase * * @return \Generator */ - public function iteratorDataProvider() + public static function iteratorDataProvider() { foreach (self::$eventCases as $eventCase) { $shape = $this->loadEventStreamShapeFromJson($eventCase['shape']); @@ -412,7 +412,7 @@ public function testHandleEventWithExceptions( /** * @return array[] */ - public function handleEventWithExceptionsProvider(): array { + public static function handleEventWithExceptionsProvider(): array { return [ 'handle_event_with_exceptions_1' => [ 'event_streams' => diff --git a/tests/Api/Parser/JsonParserTest.php b/tests/Api/Parser/JsonParserTest.php index 8a2c82071b..2cc2a14156 100644 --- a/tests/Api/Parser/JsonParserTest.php +++ b/tests/Api/Parser/JsonParserTest.php @@ -14,7 +14,7 @@ class JsonParserTest extends TestCase { use ParserTestServiceTrait; - public function timeStampModelProvider() + public static function timeStampModelProvider() { return [ [932169600, "ParseIso8601", "1999-07-17T00:00:00+00:00"], @@ -59,7 +59,7 @@ public function timeStampModelProvider() ]; } - public function timeStampExceptionModelProvider() + public static function timeStampExceptionModelProvider() { return [ ["this text is not a date", "ParseIso8601", ParserException::class, "Invalid timestamp value passed to DateTimeResult::fromTimestamp"], diff --git a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php index d4b5630253..af65a127ea 100644 --- a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php @@ -126,7 +126,7 @@ public function testReadAndHashBytesHandlesPartialReads( /** * @return \Generator */ - public function readAndHashBytesHandlesPartialReadsProvider(): \Generator + public static function readAndHashBytesHandlesPartialReadsProvider(): \Generator { $cases = json_decode( file_get_contents(self::CASES_FILE), diff --git a/tests/Api/Parser/RestJsonParserTest.php b/tests/Api/Parser/RestJsonParserTest.php index 132c2cc35d..519d4ff547 100644 --- a/tests/Api/Parser/RestJsonParserTest.php +++ b/tests/Api/Parser/RestJsonParserTest.php @@ -40,7 +40,7 @@ public function testParsesDocumentTypePayload( self::assertEquals($expected, $result['documentValue']); } - public function parsesDocumentTypePayloadProvider(): iterable + public static function parsesDocumentTypePayloadProvider(): iterable { return [ 'string payload' => ["\"hello\"", 'hello'], diff --git a/tests/Api/Parser/XmlParserTest.php b/tests/Api/Parser/XmlParserTest.php index ab41a62986..9736fb1567 100644 --- a/tests/Api/Parser/XmlParserTest.php +++ b/tests/Api/Parser/XmlParserTest.php @@ -14,7 +14,7 @@ class XmlParserTest extends TestCase { use ParserTestServiceTrait; - public function timeStampModelProvider() + public static function timeStampModelProvider() { return [ [932169600, "ParseIso8601", "1999-07-17T00:00:00+00:00"], @@ -62,7 +62,7 @@ public function timeStampModelProvider() ]; } - public function timeStampExceptionModelProvider() + public static function timeStampExceptionModelProvider() { return [ ["this text is not a date", "ParseIso8601", ParserException::class, "Invalid timestamp value passed to DateTimeResult::fromTimestamp"], diff --git a/tests/Api/Serializer/ComplianceTest.php b/tests/Api/Serializer/ComplianceTest.php index c0aadf4e32..b4096dd38b 100644 --- a/tests/Api/Serializer/ComplianceTest.php +++ b/tests/Api/Serializer/ComplianceTest.php @@ -40,7 +40,7 @@ class ComplianceTest extends TestCase ]; /** @doesNotPerformAssertions */ - public function testCaseProvider(): \Generator + public static function testCaseProvider(): \Generator { $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( diff --git a/tests/Api/Serializer/JsonBodyTest.php b/tests/Api/Serializer/JsonBodyTest.php index d7c180285b..e8d397b30f 100644 --- a/tests/Api/Serializer/JsonBodyTest.php +++ b/tests/Api/Serializer/JsonBodyTest.php @@ -24,7 +24,7 @@ public function testUsesEmptyHashByDefault(): void ); } - public function formatProvider() + public static function formatProvider() { yield [['type' => 'string'], ['foo' => 'bar'], '{"foo":"bar"}']; yield [['type' => 'integer'], ['foo' => 1], '{"foo":1}']; @@ -154,7 +154,7 @@ public function testFormatsJson(array $def, array $args, string $result): void $this->assertEquals($result, $j->build($shape, $args)); } - public function formatNoReferencesProvider(): iterable + public static function formatNoReferencesProvider(): iterable { return [ // Formats nested maps and structures @@ -233,7 +233,7 @@ public function testBuildsDocTypes(string|array $args, string $expected): void $this->assertEquals($expected, $builtShape); } - public function buildsDocTypesProvider(): iterable + public static function buildsDocTypesProvider(): iterable { return [ ['hello', '"hello"'], diff --git a/tests/Api/Serializer/RestJsonSerializerTest.php b/tests/Api/Serializer/RestJsonSerializerTest.php index 1781724acd..b808d3b8f2 100644 --- a/tests/Api/Serializer/RestJsonSerializerTest.php +++ b/tests/Api/Serializer/RestJsonSerializerTest.php @@ -322,7 +322,7 @@ public function testHandlesDoctype($input, $expectedOutput): void } - public function doctypeTestProvider(): iterable + public static function doctypeTestProvider(): iterable { return [ [ @@ -378,7 +378,7 @@ public function testRestJsonContentTypeNoPayload( } - public function restJsonContentTypeProvider(): iterable + public static function restJsonContentTypeProvider(): iterable { return [ [ @@ -404,7 +404,7 @@ public function testSerializesHeaderValueToBoolString( $this->assertSame($expected, $request->getHeaderLine('Is-Bool')); } - public function boolProvider(): iterable + public static function boolProvider(): iterable { return [ [true, 'true'], @@ -443,7 +443,7 @@ public function testHandlesDocTypeAsPayload( ); } - public function handlesDocTypeAsPayloadProvider(): \Generator + public static function handlesDocTypeAsPayloadProvider(): \Generator { yield 'string payload' => ['hello', '"hello"']; yield 'simple string field' => [ @@ -497,7 +497,7 @@ public function testRejectsInvalidJsonAsPayload(array|string $input): void $this->getRequest('DocumentTypeAsPayload', ['documentValue' => $input]); } - public function rejectsInvalidJsonAsPayloadProvider(): iterable + public static function rejectsInvalidJsonAsPayloadProvider(): iterable { return [ 'malformed byte sequence' => ["\xB1\x31"], @@ -620,7 +620,7 @@ public function testGeoServiceEndpointV2Resolution( ); } - public function endpointResolutionProvider(): \Generator + public static function endpointResolutionProvider(): \Generator { // Basic endpoints without path yield 'no_base_path_simple_request' => [ @@ -813,7 +813,7 @@ public function endpointResolutionProvider(): \Generator ]; } - public function geoServiceEndpointResolutionProvider(): \Generator + public static function geoServiceEndpointResolutionProvider(): \Generator { yield 'geo_places_v2' => [ 'endpoint' => 'https://places.geo.region.amazonaws.com/v2', @@ -891,7 +891,7 @@ public function testGeoServiceEndpointResolutionE2E( $client->{$operation}($params); } - public function geoServiceE2EProvider(): \Generator + public static function geoServiceE2EProvider(): \Generator { yield 'geo_places_simple' => [ 'service' => 'geo-places', diff --git a/tests/Api/Serializer/RestXmlSerializerTest.php b/tests/Api/Serializer/RestXmlSerializerTest.php index 940c1bcecc..bbf5edfc02 100644 --- a/tests/Api/Serializer/RestXmlSerializerTest.php +++ b/tests/Api/Serializer/RestXmlSerializerTest.php @@ -101,7 +101,7 @@ public function testSerializesHeaderValueToBoolString($arg, $expected) ); } - public function boolProvider() { + public static function boolProvider() { return [ [true, 'true'], [false, 'false'] @@ -267,7 +267,7 @@ public function testRestXmlEndpointV2Resolution( ); } - public function s3EndpointResolutionProvider(): \Generator + public static function s3EndpointResolutionProvider(): \Generator { // Virtual-hosted-style (default) yield 's3_virtual_hosted_standard' => [ @@ -379,7 +379,7 @@ public function s3EndpointResolutionProvider(): \Generator ]; } - public function s3DotSegmentProvider(): \Generator + public static function s3DotSegmentProvider(): \Generator { // Virtual-hosted-style (default) yield 's3_virtual_dot_segment_start' => [ @@ -440,7 +440,7 @@ public function s3DotSegmentProvider(): \Generator ]; } - public function restXmlEndpointResolutionProvider(): \Generator + public static function restXmlEndpointResolutionProvider(): \Generator { // Basic REST XML service endpoints yield 'restxml_no_path' => [ @@ -562,7 +562,7 @@ public function testS3EndpointResolutionE2ELegacyProvider( $client->getObject(['Bucket' => $bucket, 'Key' => $key]); } - public function s3E2EProvider(): \Generator + public static function s3E2EProvider(): \Generator { // Virtual-hosted style (default) yield 's3_virtual_simple' => [ diff --git a/tests/Api/ServiceTest.php b/tests/Api/ServiceTest.php index 0a79674a0e..b1fe47dab6 100644 --- a/tests/Api/ServiceTest.php +++ b/tests/Api/ServiceTest.php @@ -144,7 +144,7 @@ public function testLoadWaiterConfigs() $api->getWaiterConfig('Fizz'); } - public function errorParserProvider() + public static function errorParserProvider() { return [ ['json', ErrorParser\JsonRpcErrorParser::class], @@ -168,7 +168,7 @@ public function testThrowsOnUnexpectedProtocol() Service::createErrorParser('undefined_protocol'); } - public function serializerDataProvider() + public static function serializerDataProvider() { return [ ['json', Serializer\JsonRpcSerializer::class], @@ -196,7 +196,7 @@ function () { return []; } $this->assertInstanceOf($cl, $serializer); } - public function parserDataProvider() + public static function parserDataProvider() { return [ ['json', Parser\JsonRpcParser::class], @@ -352,7 +352,7 @@ function () { return []; } $this->assertEquals($expected, $protocol); } - public function selectsProtocolProvider() + public static function selectsProtocolProvider() { return [ [['smithy-rpc-v2-cbor', 'json'], 'json'], diff --git a/tests/Api/SupportedProtocolsTest.php b/tests/Api/SupportedProtocolsTest.php index d96f52fa3c..c62f81fc28 100644 --- a/tests/Api/SupportedProtocolsTest.php +++ b/tests/Api/SupportedProtocolsTest.php @@ -28,7 +28,7 @@ public function testIsSupportedReturnsFalseForInvalidProtocols(string $protocol) * * @return array */ - public function validProtocolsProvider(): array + public static function validProtocolsProvider(): array { return [ ['rest-json'], @@ -44,7 +44,7 @@ public function validProtocolsProvider(): array * * @return array */ - public function invalidProtocolsProvider(): array + public static function invalidProtocolsProvider(): array { return [ ['graphql'], diff --git a/tests/Api/TimestampShapeTest.php b/tests/Api/TimestampShapeTest.php index 3a3b503af7..44f8c2930c 100644 --- a/tests/Api/TimestampShapeTest.php +++ b/tests/Api/TimestampShapeTest.php @@ -10,7 +10,7 @@ */ class TimestampShapeTest extends TestCase { - public function formatProvider() + public static function formatProvider() { $t = strtotime('january 5, 1999'); diff --git a/tests/Api/ValidatorTest.php b/tests/Api/ValidatorTest.php index 701223a7f3..82ca0822b7 100644 --- a/tests/Api/ValidatorTest.php +++ b/tests/Api/ValidatorTest.php @@ -12,7 +12,7 @@ */ class ValidatorTest extends TestCase { - public function validationProvider() + public static function validationProvider() { return [ [ diff --git a/tests/Arn/AccessPointArnTest.php b/tests/Arn/AccessPointArnTest.php index eb56b94580..6484bcdef4 100644 --- a/tests/Arn/AccessPointArnTest.php +++ b/tests/Arn/AccessPointArnTest.php @@ -31,7 +31,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public function parsedArnProvider() + public static function parsedArnProvider() { return [ // All components @@ -101,7 +101,7 @@ public function testThrowsOnInvalidArn($string, $message) } } - public function invalidArnCases() + public static function invalidArnCases() { return [ [ diff --git a/tests/Arn/ArnParserTest.php b/tests/Arn/ArnParserTest.php index d5cb5c6623..c0e26d52da 100644 --- a/tests/Arn/ArnParserTest.php +++ b/tests/Arn/ArnParserTest.php @@ -27,7 +27,7 @@ public function testDeterminesShouldAttemptToParseAsArn($string, $expected) $this->assertEquals($expected, ArnParser::isArn($string)); } - public function isArnCases() + public static function isArnCases() { return [ [ @@ -68,7 +68,7 @@ public function testCorrectlyChoosesArnClass($string, $expected) $this->assertTrue(ArnParser::parse($string) instanceof $expected); } - public function parsedArnCases() + public static function parsedArnCases() { return [ [ diff --git a/tests/Arn/ArnTest.php b/tests/Arn/ArnTest.php index 0e431b2c58..c45b9e5571 100644 --- a/tests/Arn/ArnTest.php +++ b/tests/Arn/ArnTest.php @@ -32,7 +32,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public function parsedArnProvider() + public static function parsedArnProvider() { return [ // All components @@ -132,7 +132,7 @@ public function testThrowsOnInvalidArn($string, $message) } } - public function invalidArnCases() + public static function invalidArnCases() { return [ [ diff --git a/tests/Arn/S3/AccessPointArnTest.php b/tests/Arn/S3/AccessPointArnTest.php index c014d51cc9..65042568b5 100644 --- a/tests/Arn/S3/AccessPointArnTest.php +++ b/tests/Arn/S3/AccessPointArnTest.php @@ -26,7 +26,7 @@ public function testThrowsOnInvalidArn($string, $message) } } - public function invalidArnCases() + public static function invalidArnCases() { return [ [ diff --git a/tests/Arn/S3/OutpostsAccessPointArnTest.php b/tests/Arn/S3/OutpostsAccessPointArnTest.php index 3c5cca2143..3763dcfb6e 100644 --- a/tests/Arn/S3/OutpostsAccessPointArnTest.php +++ b/tests/Arn/S3/OutpostsAccessPointArnTest.php @@ -35,7 +35,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public function parsedArnProvider() + public static function parsedArnProvider() { return [ // Colon delimiters @@ -133,7 +133,7 @@ public function testThrowsForBadArn($string, \Exception $expected) } } - public function badArnProvider() + public static function badArnProvider() { return [ [ diff --git a/tests/Arn/S3/OutpostsBucketArnTest.php b/tests/Arn/S3/OutpostsBucketArnTest.php index c9d6325dbc..af2d855edb 100644 --- a/tests/Arn/S3/OutpostsBucketArnTest.php +++ b/tests/Arn/S3/OutpostsBucketArnTest.php @@ -36,7 +36,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public function parsedArnProvider() + public static function parsedArnProvider() { return [ // Colon delimiters @@ -134,7 +134,7 @@ public function testThrowsForBadArn($string, \Exception $expected) } } - public function badArnProvider() + public static function badArnProvider() { return [ [ diff --git a/tests/Auth/AuthSchemeResolverTest.php b/tests/Auth/AuthSchemeResolverTest.php index 4ea193e9f1..4ae58ce68a 100644 --- a/tests/Auth/AuthSchemeResolverTest.php +++ b/tests/Auth/AuthSchemeResolverTest.php @@ -62,7 +62,7 @@ public function testSelectAuthSchemeReturnsCorrectSchemeForIdentity( $this->assertEquals($expectedSignatureVersion, $resolver->selectAuthScheme($authScheme, $args)); } - public function schemeForIdentityProvider() + public static function schemeForIdentityProvider() { return [ [ @@ -206,7 +206,7 @@ public function testFallsBackWhenIdentityNotAvailable( $this->assertEquals($expected, $resolver->selectAuthScheme($authSchemes)); } - public function fallsBackWhenIdentityNotAvailableProvider() + public static function fallsBackWhenIdentityNotAvailableProvider() { $credentialProvider = function () { return Promise\Create::promiseFor( diff --git a/tests/Auth/AuthSelectionMiddlewareTest.php b/tests/Auth/AuthSelectionMiddlewareTest.php index 210189e6e1..5dfb40fe7f 100644 --- a/tests/Auth/AuthSelectionMiddlewareTest.php +++ b/tests/Auth/AuthSelectionMiddlewareTest.php @@ -127,7 +127,7 @@ public function testResolvesAuthSchemeWithCRT( $middleware($command); } - public function ResolvesAuthSchemeWithCRTprovider() + public static function ResolvesAuthSchemeWithCRTprovider() { return [ [ @@ -198,7 +198,7 @@ public function testResolvesBearerAuthScheme( $middleware($command); } - public function resolvesBearerAuthSchemeProvider() + public static function resolvesBearerAuthSchemeProvider() { return [ [ @@ -380,7 +380,7 @@ public function testAuthSelectionBasedOnUserPreference( /** * @return \Generator */ - public function authSelectionBasedOnUserPreferenceProvider(): \Generator + public static function authSelectionBasedOnUserPreferenceProvider(): \Generator { $cases = [ 'user_auth_scheme_preferred_none' => [ diff --git a/tests/AwsClientTest.php b/tests/AwsClientTest.php index ff62971a06..e6ef92f48c 100644 --- a/tests/AwsClientTest.php +++ b/tests/AwsClientTest.php @@ -365,7 +365,7 @@ public function testSignOperationsWithAnAuthType($service, $clientConfig) $client->bar(); } - public function signOperationsWithAnAuthTypeProvider() + public static function signOperationsWithAnAuthTypeProvider() { return [ [ @@ -669,7 +669,7 @@ public function testDoesNotApplyConfiguredEndpointWhenConfiguredUrlsIgnored($ini putenv('AWS_IGNORE_CONFIGURED_ENDPOINT_URLS='); } - public function configuredEndpointUrlProvider() + public static function configuredEndpointUrlProvider() { return [ [ @@ -859,7 +859,7 @@ public function testSigningRegionSetResolution( putenv('AWS_SIGV4A_SIGNING_REGION_SET='); } - public function signingRegionSetProvider() + public static function signingRegionSetProvider() { return [ [null, null, null, null, 'us-west-2'], diff --git a/tests/Build/Docs/CodeSnippetGeneratorTest.php b/tests/Build/Docs/CodeSnippetGeneratorTest.php index 987ca77bed..8026aa081c 100644 --- a/tests/Build/Docs/CodeSnippetGeneratorTest.php +++ b/tests/Build/Docs/CodeSnippetGeneratorTest.php @@ -33,7 +33,7 @@ public function testCanBuildCodeExamples( $this->assertSame($expected, $builder($operation, $input, [], $isInput)); } - public function exampleProvider() + public static function exampleProvider() { $provider = ApiProvider::defaultProvider(); return [ diff --git a/tests/ClientResolverTest.php b/tests/ClientResolverTest.php index 3f0c3ecfcc..3c0174b882 100644 --- a/tests/ClientResolverTest.php +++ b/tests/ClientResolverTest.php @@ -610,7 +610,7 @@ public function testDualstackEndpoints( ); } - public function dualStackEndpointCases() + public static function dualStackEndpointCases() { return [ ["ec2", false, false, "us-west-2", "ec2.us-west-2.amazonaws.com",], @@ -688,7 +688,7 @@ public function testCanPassS3RegionalEndpointToEndpointProvider($config, $endpoi $this->assertEquals($endpoint, $conf['endpoint']); } - public function s3EndpointCases() + public static function s3EndpointCases() { return [ ['regional', 'https://s3.us-east-1.amazonaws.com'], @@ -863,7 +863,7 @@ public function testAcceptsBooleansAndArraysForSelectiveStatCollection($userValu } } - public function statValueProvider() + public static function statValueProvider() { return [ [ @@ -917,7 +917,7 @@ public function testResolvesValuesReturnedByEndpointProvider( $this->assertSame($override, $resolved[$argName]); } - public function endpointProviderReturnProvider() + public static function endpointProviderReturnProvider() { $partition = new Partition([ 'partition' => 'aws-test', @@ -977,7 +977,7 @@ public function testSigningValuesAreFetchedFromPartition( $this->assertSame($expected, $resolved[$argName]); } - public function partitionReturnProvider() + public static function partitionReturnProvider() { $invocationArgs = ['endpoint' => 'https://foo.bar.amazonaws.com']; @@ -1026,7 +1026,7 @@ public function testIdempotencyTokenMiddlewareAddedAsAppropriate( $this->assertCount($shouldAddIdempotencyMiddleware ? 1 : 0, $list); } - public function idempotencyAutoFillProvider() + public static function idempotencyAutoFillProvider() { return [ [true, true], @@ -1068,7 +1068,7 @@ public function testValidatesRegion($region, $expected) } } - public function validateRegionProvider() + public static function validateRegionProvider() { return [ [ @@ -1086,7 +1086,7 @@ public function validateRegionProvider() ]; } - public function invalidDisableRequestCompressionValues() + public static function invalidDisableRequestCompressionValues() { return [ ['foo'], @@ -1129,7 +1129,7 @@ public function testDisableRequestCompressionDefault() $this->assertFalse($conf['disable_request_compression']); } - public function invalidMinCompressionSizeValues() + public static function invalidMinCompressionSizeValues() { return [ [ true ], @@ -1217,7 +1217,7 @@ public function testConfigResolutionOrder($ini, $env, $expected, $configKey, $co } } - public function configResolutionProvider() + public static function configResolutionProvider() { return [ [ @@ -1591,7 +1591,7 @@ public function testResolvesAuthSchemePreference( /** * @return Generator */ - public function resolvesAuthSchemePreferenceProvider(): Generator + public static function resolvesAuthSchemePreferenceProvider(): Generator { $cases = [ 'provided_at_client_construction' => [ diff --git a/tests/ClientSideMonitoring/ConfigurationProviderTest.php b/tests/ClientSideMonitoring/ConfigurationProviderTest.php index 96ae1e86e2..1c8a5d9526 100644 --- a/tests/ClientSideMonitoring/ConfigurationProviderTest.php +++ b/tests/ClientSideMonitoring/ConfigurationProviderTest.php @@ -439,7 +439,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData() { $expected = new Configuration(true, '123.4.5.6', 555, 'FooApp'); return [ diff --git a/tests/CloudFront/SignerTest.php b/tests/CloudFront/SignerTest.php index daad495448..b14d22acaf 100644 --- a/tests/CloudFront/SignerTest.php +++ b/tests/CloudFront/SignerTest.php @@ -75,7 +75,7 @@ public function testReturnsSignatureAndKeyPairId() $this->assertArrayHasKey('Key-Pair-Id', $signature); } - public function getExpiresCases() + public static function getExpiresCases() { return [ [ @@ -155,7 +155,7 @@ public function testCreatesCannedPolicies($resource, $ts) ); } - public function cannedPolicyParameterProvider() + public static function cannedPolicyParameterProvider() { return [ [ diff --git a/tests/CloudFront/UrlSignerTest.php b/tests/CloudFront/UrlSignerTest.php index efea2df581..1532ea907f 100644 --- a/tests/CloudFront/UrlSignerTest.php +++ b/tests/CloudFront/UrlSignerTest.php @@ -152,7 +152,7 @@ public function testIsolatesResourceIUrls($url, $resource) $this->assertSame($resource, $result); } - public function urlAndResourceProvider() + public static function urlAndResourceProvider() { return [ ['rtmp://foo.cloudfront.net/videos/test.mp4', 'videos/test.mp4'], diff --git a/tests/CloudTrail/LogFileReaderTest.php b/tests/CloudTrail/LogFileReaderTest.php index a44211a3df..2e4ea17e49 100644 --- a/tests/CloudTrail/LogFileReaderTest.php +++ b/tests/CloudTrail/LogFileReaderTest.php @@ -30,7 +30,7 @@ public function testCorrectlyReadsLogFiles($responseBody, $recordCount) $this->assertCount($recordCount, $records); } - public function dataForLogReadingTest() + public static function dataForLogReadingTest() { return [ ['{"Records":[{"foo":"1"},{"bar":"2"},{"baz":"3"}]}', 3], diff --git a/tests/ConfigurationResolverTest.php b/tests/ConfigurationResolverTest.php index cd6fdf2198..4f758c9c20 100644 --- a/tests/ConfigurationResolverTest.php +++ b/tests/ConfigurationResolverTest.php @@ -80,7 +80,7 @@ public static function tear_down_after_class() self::$originalEnv['config_file']); } - public function getEnvValues() + public static function getEnvValues() { return [ ['true', 'bool', true], @@ -378,7 +378,7 @@ public function testResolvesServiceIniWithDuplicateSections($ini) ); } - public function duplicateIniFileProvider() + public static function duplicateIniFileProvider() { return [ [ diff --git a/tests/Credentials/AssumeRoleCredentialProviderTest.php b/tests/Credentials/AssumeRoleCredentialProviderTest.php index 3e663d70f8..1d9c63169a 100644 --- a/tests/Credentials/AssumeRoleCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleCredentialProviderTest.php @@ -37,7 +37,7 @@ public function testEnsureSourceProfileProvidedForAssumeRole($config) /** * @dataProvider insufficientArguments */ - public function insufficientArguments() + public static function insufficientArguments() { $client = [ 'client' => new StsClient([ diff --git a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php index 44f2043229..1e99253bc0 100644 --- a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php @@ -460,7 +460,7 @@ public function testRegionPrecedence( } } - public function regionPrecedenceProvider(): array + public static function regionPrecedenceProvider(): array { return [ 'config overrides env' => ['us-west-2', 'eu-west-1', 'us-west-2', false], @@ -537,7 +537,7 @@ function ($c, $r) { } } - public function endpointProvider(): array + public static function endpointProvider(): array { return [ 'us-east-1' => [ diff --git a/tests/Credentials/CredentialProviderTest.php b/tests/Credentials/CredentialProviderTest.php index bc76731efb..9cb5a36342 100644 --- a/tests/Credentials/CredentialProviderTest.php +++ b/tests/Credentials/CredentialProviderTest.php @@ -295,7 +295,7 @@ public function testCreatesFromIniFile( $this->assertEquals($expectedCreds->toArray(), $creds->toArray()); } - public function iniFileProvider(): array + public static function iniFileProvider(): array { $credentials = new Credentials( 'foo', @@ -1956,7 +1956,7 @@ public function testShouldUseEcs( $this->assertEquals($expected, $result); } - public function shouldUseEcsProvider(): array + public static function shouldUseEcsProvider(): array { return [ ['=foo', '', '', '', true], @@ -2754,7 +2754,7 @@ public function testLoginWithInvalidCache( $provider()->wait(); } - public function loginInvalidCacheProvider(): array + public static function loginInvalidCacheProvider(): array { $validDpopKey = '-----BEGIN EC PRIVATE KEY----- MHcCAQEEIFDZHUzOG1Pzq+6F0mjMlOSp1syN9LRPBuHMoCFXTcXhoAoGCCqGSM49 diff --git a/tests/Credentials/CredentialsUtilsTest.php b/tests/Credentials/CredentialsUtilsTest.php index ea97e7d9b1..03c9b7a18c 100644 --- a/tests/Credentials/CredentialsUtilsTest.php +++ b/tests/Credentials/CredentialsUtilsTest.php @@ -25,7 +25,7 @@ public function testLoopBackAddressCases(string $host, bool $expectedResult) /** * @return string[] */ - public function loopBackAddressCasesProvider(): array + public static function loopBackAddressCasesProvider(): array { return [ 'IPv6_invalid_loopBack' => diff --git a/tests/Credentials/EcsCredentialProviderTest.php b/tests/Credentials/EcsCredentialProviderTest.php index 246ccac3ff..f2697d4ca6 100644 --- a/tests/Credentials/EcsCredentialProviderTest.php +++ b/tests/Credentials/EcsCredentialProviderTest.php @@ -193,7 +193,7 @@ public function testUriAndTokenResolution($case) } } - public function uriAndTokenResolutionProvider(): \Generator + public static function uriAndTokenResolutionProvider(): \Generator { $cases = json_decode(file_get_contents( __DIR__ . '/fixtures/ecs/uri-token-resolution.json') @@ -398,7 +398,7 @@ public function testHandlesSuccessScenarios( ); } - public function successTestCases() + public static function successTestCases() { $expiry = time() + 1000; $creds = ['foo_key', 'baz_secret', 'qux_token', "@{$expiry}"]; @@ -473,7 +473,7 @@ public function testHandlesFailureScenarios($client, \Exception $expected) } } - public function failureTestCases() + public static function failureTestCases() { $getRequest = new Psr7\Request('GET', '/latest'); diff --git a/tests/Credentials/InstanceProfileProviderTest.php b/tests/Credentials/InstanceProfileProviderTest.php index 09483703df..6758a71362 100644 --- a/tests/Credentials/InstanceProfileProviderTest.php +++ b/tests/Credentials/InstanceProfileProviderTest.php @@ -349,7 +349,7 @@ public function testHandlesSuccessScenarios( } } - public function successTestCases() + public static function successTestCases() { $expiry = time() + 1000; $creds = ['foo_key', 'baz_secret', 'qux_token', "@{$expiry}"]; @@ -561,7 +561,7 @@ public function testHandlesFailureScenarios($client, \Exception $expected) } } - public function failureTestCases() + public static function failureTestCases() { $requestClass = $this->getRequestClass(); $responseClass = $this->getResponseClass(); @@ -1036,7 +1036,7 @@ public function testExtendsExpirationAndSendsRequestIfImdsYieldsExpiredCreds($cl $this->assertLessThanOrEqual(3,$this->getPropertyValue($provider,'attempts')); } - public function returnsExpiredCredsProvider() + public static function returnsExpiredCredsProvider() { $expiredTime = time() - 1000; $expiredCreds = ['foo', 'baz', null, "@{$expiredTime}"]; @@ -1121,7 +1121,7 @@ public function testExtendsExpirationAndSendsRequestIfImdsUnavailable($client) $this->assertLessThanOrEqual(3,$this->getPropertyValue($provider,'attempts')); } - public function imdsUnavailableProvider() + public static function imdsUnavailableProvider() { $requestClass = $this->getRequestClass(); $responseClass = $this->getResponseClass(); @@ -1445,7 +1445,7 @@ public function testEndpointModeResolution( * * @return array[] */ - public function endpointModeCasesProvider() : array + public static function endpointModeCasesProvider() : array { return [ 'endpoint_mode_not_specified' => [ @@ -1550,7 +1550,7 @@ public function testEndpointResolution( * * @return array[] */ - public function endpointCasesProvider() : array + public static function endpointCasesProvider() : array { return [ 'with_endpoint_mode_ipv4' => [ diff --git a/tests/Credentials/LoginCredentialProviderTest.php b/tests/Credentials/LoginCredentialProviderTest.php index 19d6304cc8..b63440ab21 100644 --- a/tests/Credentials/LoginCredentialProviderTest.php +++ b/tests/Credentials/LoginCredentialProviderTest.php @@ -327,7 +327,7 @@ public function testLoadTokenFailsWithMissingOrEmptyCacheKeys( $provider()->wait(); } - public function missingCacheKeysProvider(): array + public static function missingCacheKeysProvider(): array { $validDpopKey = "-----BEGIN EC PRIVATE KEY-----\n" . "MHcCAQEEID9l+ckeHBxlF47cg0h5qJnAErPvCm1brUY8i7b6qSJToAoGCCqGSM49\n" . @@ -1381,7 +1381,7 @@ public function testLoginCredentialProviderFromTestCases( * @return \Generator * @throws \JsonException */ - public function loginTestCasesProvider(): \Generator + public static function loginTestCasesProvider(): \Generator { $testCasesFile = __DIR__ . '/fixtures/login/test-cases.json'; @@ -1532,7 +1532,7 @@ public function testExternalRefreshBehavior( } } - public function externalRefreshProvider(): array + public static function externalRefreshProvider(): array { return [ 'external refresh detected - all conditions met' => [ diff --git a/tests/Crypto/AesGcmEncryptingStreamTest.php b/tests/Crypto/AesGcmEncryptingStreamTest.php index 7cc4293422..e02934f53f 100644 --- a/tests/Crypto/AesGcmEncryptingStreamTest.php +++ b/tests/Crypto/AesGcmEncryptingStreamTest.php @@ -82,7 +82,7 @@ public function testCorrectlyEncryptsData( ); } - public function encryptDataProvider() + public static function encryptDataProvider() { // [[ $plaintext, $key, $iv, $aad, $keySize, $expectedCipher, $expectedTag ]] return [ diff --git a/tests/DSQL/AuthTokenGeneratorTest.php b/tests/DSQL/AuthTokenGeneratorTest.php index 6e297c6358..2c49012204 100644 --- a/tests/DSQL/AuthTokenGeneratorTest.php +++ b/tests/DSQL/AuthTokenGeneratorTest.php @@ -38,7 +38,7 @@ public function testGeneratesAuthToken($credentials, $action) $this->assertStringNotContainsString('https://', $token); } - public function generateAuthTokenProvider() + public static function generateAuthTokenProvider() { $accessKeyId = 'AKID'; $secretKeyId = 'SECRET'; $credentials = new Credentials($accessKeyId, $secretKeyId); @@ -75,7 +75,7 @@ public function testThrowsOnMissingInput($action, $endpoint, $region) ); } - public function missingInputProvider() + public static function missingInputProvider() { return [ ['generateDbConnectAuthToken', 'foo.bar.baz', null], @@ -106,7 +106,7 @@ public function testThrowsOnEmptyInput($action, $endpoint, $region) ); } - public function emptyInputProvider() + public static function emptyInputProvider() { return [ ['generateDbConnectAuthToken', 'foo.bar.baz', ''], @@ -116,7 +116,7 @@ public function emptyInputProvider() ]; } - public function lifetimeFailureProvider() + public static function lifetimeFailureProvider() { return [ [0, 'generateDbConnectAuthToken'], diff --git a/tests/DefaultsMode/ConfigurationProviderTest.php b/tests/DefaultsMode/ConfigurationProviderTest.php index f7a71e2948..aa3a9b2b10 100644 --- a/tests/DefaultsMode/ConfigurationProviderTest.php +++ b/tests/DefaultsMode/ConfigurationProviderTest.php @@ -349,7 +349,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData() { $expected = new Configuration('standard'); return [ diff --git a/tests/DocDb/DocDbClientTest.php b/tests/DocDb/DocDbClientTest.php index d65c13241b..202c00a033 100644 --- a/tests/DocDb/DocDbClientTest.php +++ b/tests/DocDb/DocDbClientTest.php @@ -26,7 +26,7 @@ public static function tear_down_after_class() $_SERVER['formatAwsTime'] = null; } - public function DocDbPresignMethodProvider() + public static function DocDbPresignMethodProvider() { return [ ['CopyDBClusterSnapshot', ['SourceDBClusterSnapshotIdentifier' => 'arn:aws:rds:us-east-1:123456789012:cluster-snapshot:source-db-cluster-snapshot', 'TargetDBClusterSnapshotIdentifier' => 'target-db-cluster-snapshot'], null, null, null, null], diff --git a/tests/DynamoDb/DynamoDbClientTest.php b/tests/DynamoDb/DynamoDbClientTest.php index b2b8488f85..70cbdabfc1 100644 --- a/tests/DynamoDb/DynamoDbClientTest.php +++ b/tests/DynamoDb/DynamoDbClientTest.php @@ -137,7 +137,7 @@ public function testRetriesOnDynamoSpecificRetryableException($settings) $this->assertSame(3, $attemptCount); } - public function dataProviderRetrySettings() + public static function dataProviderRetrySettings() { return [ [ diff --git a/tests/DynamoDb/MarshalerTest.php b/tests/DynamoDb/MarshalerTest.php index bcc9f3ec83..0e1fa1ed02 100644 --- a/tests/DynamoDb/MarshalerTest.php +++ b/tests/DynamoDb/MarshalerTest.php @@ -29,7 +29,7 @@ public function testMarshalValueUseCases($value, $expectedResult, $options = []) $this->assertSame($expectedResult, $actualResult); } - public function getMarshalValueUseCases() + public static function getMarshalValueUseCases() { $m = new Marshaler; diff --git a/tests/DynamoDb/WriteRequestBatchTest.php b/tests/DynamoDb/WriteRequestBatchTest.php index 2be84a22e3..14c47397c4 100644 --- a/tests/DynamoDb/WriteRequestBatchTest.php +++ b/tests/DynamoDb/WriteRequestBatchTest.php @@ -32,7 +32,7 @@ public function testInstantiationFailsOnInvalidArgs($config) new WriteRequestBatch($this->getTestClient('DynamoDb'), $config); } - public function getInvalidArgUseCases() + public static function getInvalidArgUseCases() { return [ [['batch_size' => 1]], diff --git a/tests/Endpoint/PartitionEndpointProviderTest.php b/tests/Endpoint/PartitionEndpointProviderTest.php index 1681aefed9..31b8f44805 100644 --- a/tests/Endpoint/PartitionEndpointProviderTest.php +++ b/tests/Endpoint/PartitionEndpointProviderTest.php @@ -21,7 +21,7 @@ public function testResolvesEndpoints($input, $output) $this->assertEquals($output, $p($input)); } - public function endpointProvider() + public static function endpointProvider() { return [ [ @@ -167,7 +167,7 @@ public function testResolvesPartitionsByRegion($region, $service, $partition) $this->assertSame($partition, $p->getPartition($region, $service)->getName()); } - public function partitionRegionProvider() + public static function partitionRegionProvider() { return [ ['us-east-1', 's3', 'aws'], @@ -293,7 +293,7 @@ public function testCanMergePrefixData() } } - public function knownEndpointProvider() + public static function knownEndpointProvider() { $partitions = PartitionEndpointProvider::defaultProvider(); diff --git a/tests/Endpoint/PartitionTest.php b/tests/Endpoint/PartitionTest.php index 9642602781..707f70fc70 100644 --- a/tests/Endpoint/PartitionTest.php +++ b/tests/Endpoint/PartitionTest.php @@ -65,7 +65,7 @@ public function testFipsEndpoint(array $definition) self::assertStringContainsString('service-fips.amazonaws.com', $resolved['endpoint']); } - public function partitionDefinitionProvider() + public static function partitionDefinitionProvider() { return [ [[ @@ -89,7 +89,7 @@ public function partitionDefinitionProvider() ]; } - public function invalidPartitionDefinitionProvider() + public static function invalidPartitionDefinitionProvider() { $validDefinition = $this->partitionDefinitionProvider()[0][0]; $return = []; @@ -152,7 +152,7 @@ public function testEnumeratesRegionsForGivenService( )); } - public function serviceRegionsProvider() + public static function serviceRegionsProvider() { $partition = new Partition([ 'partition' => 'foo', @@ -214,7 +214,7 @@ public function testDeterminesSigningRegion( $this->assertSame($signingRegion, $resolved['signingRegion']); } - public function signingRegionProvider() + public static function signingRegionProvider() { $partition = new Partition([ 'partition' => 'foo', @@ -269,7 +269,7 @@ public function testDeterminesEndpoint( $this->assertSame($endpoint, $resolved['endpoint']); } - public function endpointProvider() + public static function endpointProvider() { $partition = new Partition([ 'partition' => 'foo', @@ -354,7 +354,7 @@ public function testDeterminesSignatureVersion( $this->assertSame($signatureVersion, $resolved['signatureVersion']); } - public function signatureVersionProvider() + public static function signatureVersionProvider() { $partition = new Partition([ 'partition' => 'foo', @@ -434,7 +434,7 @@ public function testDeterminesSigningName( $this->assertSame($signingName, $resolved['signingName']); } - public function signingNameProvider() + public static function signingNameProvider() { $partition = new Partition([ 'partition' => 'foo', @@ -515,7 +515,7 @@ public function testResolvesStsRegionalEndpoints( } - public function stsEndpointTestCases() + public static function stsEndpointTestCases() { return [ [ @@ -614,7 +614,7 @@ public function testResolvesS3RegionalEndpoint( } - public function s3EndpointTestCases() + public static function s3EndpointTestCases() { return [ [ @@ -691,7 +691,7 @@ public function testGetVariantIgnoresVariantTagOrder( $this->assertStringContainsString('testsuffix.com', $resolved['endpoint']); } - public function variantTagProvider() + public static function variantTagProvider() { $useFipsEndpointConfig = $this->getMockBuilder(UseFipsEndpoint\Configuration::class) ->disableOriginalConstructor() @@ -841,7 +841,7 @@ public function testGetVariantNoVariantSelectedIfTagsAreEmpty( $this->assertStringNotContainsString('testsuffix.com', $resolved['endpoint']); } - public function variantTagEmptyProvider() + public static function variantTagEmptyProvider() { $useFipsEndpointConfig = $this->getMockBuilder(UseFipsEndpoint\Configuration::class) ->disableOriginalConstructor() @@ -1013,7 +1013,7 @@ public function testGetVariantWithBooleanConfigValues( $this->assertStringContainsString('testsuffix.com', $resolved['endpoint']); } - public function booleanConfigProvider() + public static function booleanConfigProvider() { return [ [ diff --git a/tests/Endpoint/PatternEndpointProviderTest.php b/tests/Endpoint/PatternEndpointProviderTest.php index d9d7af07cc..03ce9310e2 100644 --- a/tests/Endpoint/PatternEndpointProviderTest.php +++ b/tests/Endpoint/PatternEndpointProviderTest.php @@ -16,7 +16,7 @@ public function testReturnsNullWhenUnresolved() $this->assertNull($e(['service' => 'foo', 'region' => 'bar'])); } - public function endpointProvider() + public static function endpointProvider() { return [ [ diff --git a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php index 621146e6d6..3d0e6d4545 100644 --- a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php @@ -21,7 +21,7 @@ public function testGetsCorrectValues($param, $expected) $this->assertEquals($expected, $config->isuseDualstackEndpoint()); } - public function correctValueCases() + public static function correctValueCases() { return [ [true, true], diff --git a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php index b77a7a030c..b5fdbce917 100644 --- a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php @@ -21,7 +21,7 @@ public function testGetsCorrectValues($param, $expected) $this->assertEquals($expected, $config->isuseFipsEndpoint()); } - public function correctValueCases() + public static function correctValueCases() { return [ [true, true], diff --git a/tests/EndpointDiscovery/ConfigurationProviderTest.php b/tests/EndpointDiscovery/ConfigurationProviderTest.php index 2c5127d864..31a01d8a0d 100644 --- a/tests/EndpointDiscovery/ConfigurationProviderTest.php +++ b/tests/EndpointDiscovery/ConfigurationProviderTest.php @@ -88,7 +88,7 @@ public function testCreatesFromEnvironmentVariables($envName) $this->assertSame($expected->toArray(), $result->toArray()); } - public function getEnvVariableNames() + public static function getEnvVariableNames() { return [ [ConfigurationProvider::ENV_ENABLED], @@ -432,7 +432,7 @@ public function testIgnoresIniWithUseAwsConfigFileFalse() unlink($dir . '/config'); } - public function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData() { $expected = new Configuration(true, 4000); return [ diff --git a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php index 662cf69f70..c0a1e63067 100644 --- a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php +++ b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php @@ -113,7 +113,7 @@ public function testCorrectlyModifiesRequest( $client->execute($command); } - public function getRequestTestCases() + public static function getRequestTestCases() { $baseUri = new Uri('https://awsendpointdiscoverytestservice.us-east-1.amazonaws.com/'); $baseUserAgent = 'aws-sdk-php/' . Sdk::VERSION; @@ -328,7 +328,7 @@ public function testCorrectlyConstructsDiscoveryRequest( $handler($mainCmd, new Request('POST', new Uri('https://foo.com'))); } - public function getDiscoveryRequestTestCases() + public static function getDiscoveryRequestTestCases() { $baseUri = new Uri('https://awsendpointdiscoverytestservice.us-east-1.amazonaws.com'); $baseRequest = new Request( @@ -734,7 +734,7 @@ public function testCallsDiscoveryApiOnInvalidEndpointException($exception) * * @return array */ - public function getInvalidEndpointExceptions() + public static function getInvalidEndpointExceptions() { return [ [$this->generateInvalidEndpointException()], diff --git a/tests/EndpointParameterMiddlewareTest.php b/tests/EndpointParameterMiddlewareTest.php index 44089b2feb..aa618ce237 100644 --- a/tests/EndpointParameterMiddlewareTest.php +++ b/tests/EndpointParameterMiddlewareTest.php @@ -95,7 +95,7 @@ public function testCorrectlyOutputsHost( $handler($command, new Request('POST', $endpoint)); } - public function getTestCases() + public static function getTestCases() { $service = $this->generateTestService(); diff --git a/tests/EndpointV2/EndpointDefinitionProviderTest.php b/tests/EndpointV2/EndpointDefinitionProviderTest.php index 953099bc36..c268d8f1e3 100644 --- a/tests/EndpointV2/EndpointDefinitionProviderTest.php +++ b/tests/EndpointV2/EndpointDefinitionProviderTest.php @@ -46,7 +46,7 @@ public function testThrowsExceptionOnInvalidApiVersion() EndpointDefinitionProvider::getEndpointRuleset('s3', '10-22-2022'); } - public function getEndpointFileProvider() + public static function getEndpointFileProvider() { return [ ['Ruleset'], diff --git a/tests/EndpointV2/EndpointProviderV2Test.php b/tests/EndpointV2/EndpointProviderV2Test.php index b916304972..dd58017958 100644 --- a/tests/EndpointV2/EndpointProviderV2Test.php +++ b/tests/EndpointV2/EndpointProviderV2Test.php @@ -26,7 +26,7 @@ class EndpointProviderV2Test extends TestCase * Iterates through test cases located in ../test-cases and * ../valid-rules, parses into parameters used for endpoint and error tests */ - public function basicTestCaseProvider(): \Generator + public static function basicTestCaseProvider(): \Generator { $testfileNames = [ "aws-region", @@ -103,7 +103,7 @@ public function testBasicEndpointAndErrorCases( * Iterates through test cases located in each service's endpoint test file. * Parses into parameters used for endpoint and error tests */ - public function serviceTestCaseProvider(): \Generator + public static function serviceTestCaseProvider(): \Generator { $services = \Aws\Manifest(); @@ -161,7 +161,7 @@ public function testServiceEndpointAndErrorCases( } } - public function rulesetProtocolEndpointAndErrorCaseProvider(): \Generator + public static function rulesetProtocolEndpointAndErrorCaseProvider(): \Generator { $serviceList = \Aws\manifest(); @@ -434,7 +434,7 @@ public function testStringArrayOperationInputs( } } - public function stringArrayOperationInputsProvider(): \Generator + public static function stringArrayOperationInputsProvider(): \Generator { $cases = json_decode( file_get_contents(__DIR__ . '/test-cases/string-array.json'), diff --git a/tests/EndpointV2/EndpointV2MiddlewareTest.php b/tests/EndpointV2/EndpointV2MiddlewareTest.php index 3db9e9a6b3..c1edf983e7 100644 --- a/tests/EndpointV2/EndpointV2MiddlewareTest.php +++ b/tests/EndpointV2/EndpointV2MiddlewareTest.php @@ -47,7 +47,7 @@ public function testSuccessfullyResolvesEndpointAndAuthScheme( $mw($command); } - public function providedSuccessCases() + public static function providedSuccessCases() { return [ [ @@ -153,7 +153,7 @@ function ($command, $endpoint) {}, $this->assertSame($expected, $result['version']); } - public function v4aAuthProvider() + public static function v4aAuthProvider() { return [ [ @@ -210,7 +210,7 @@ public function testInitializationWithInvalidParameters( new EndpointV2Middleware($nextHandler, $endpointProvider, $api, $args); } - public function invalidInitializationProvider() + public static function invalidInitializationProvider() { return [ 'Invalid nextHandler' => [ diff --git a/tests/EndpointV2/RuleCreatorTest.php b/tests/EndpointV2/RuleCreatorTest.php index 825bcba12f..cb435b61a3 100644 --- a/tests/EndpointV2/RuleCreatorTest.php +++ b/tests/EndpointV2/RuleCreatorTest.php @@ -52,7 +52,7 @@ public function testRuleCreation($spec, $expected) { $this->assertInstanceOf($expected, $result); } - public function invalidRuleTypeProvider() + public static function invalidRuleTypeProvider() { return [ ['foo'], diff --git a/tests/EndpointV2/RulesetParameterTest.php b/tests/EndpointV2/RulesetParameterTest.php index aeab9340df..576e22869c 100644 --- a/tests/EndpointV2/RulesetParameterTest.php +++ b/tests/EndpointV2/RulesetParameterTest.php @@ -10,7 +10,7 @@ */ class RulesetParameterTest extends TestCase { - public function wrongParameterTypeProvider() + public static function wrongParameterTypeProvider() { return [ [true], @@ -88,7 +88,7 @@ public function testRulesetCreationWithValidTypes($spec) new RulesetParameter('FooParam', $spec); } - public function validTypesProvider() + public static function validTypesProvider() { return [ [ diff --git a/tests/EndpointV2/RulesetStandardLibraryTest.php b/tests/EndpointV2/RulesetStandardLibraryTest.php index da3275c169..0ac4c78572 100644 --- a/tests/EndpointV2/RulesetStandardLibraryTest.php +++ b/tests/EndpointV2/RulesetStandardLibraryTest.php @@ -20,7 +20,7 @@ protected function set_up() $this->standardLibrary = new RulesetStandardLibrary($partitions); } - public function isSetProvider() + public static function isSetProvider() { return [ [null, false], @@ -44,7 +44,7 @@ public function testIsSet($input, $expected) $this->assertSame($expected, $this->standardLibrary->is_set($input)); } - public function notProvider() + public static function notProvider() { return [ [true, false], @@ -66,7 +66,7 @@ public function testNot($input, $expected) $this->assertSame($expected, $this->standardLibrary->not($input)); } - public function getAttrProvider() + public static function getAttrProvider() { return [ ['{"Thing1": "foo", "Thing2": ["index0", "index1"], "Thing3": {"SubThing": 42}}', "Thing1", "foo"], @@ -94,7 +94,7 @@ public function testGetAttrFromArray() $this->assertSame("foo", $this->standardLibrary->getAttr($from, 0)); } - public function stringEqualsProvider() + public static function stringEqualsProvider() { return [ ["abc", "abc", true], @@ -115,7 +115,7 @@ public function testStringEquals($string1, $string2, $expected) $this->assertSame($expected, $this->standardLibrary->stringEquals($string1, $string2)); } - public function booleanEqualsProvider() + public static function booleanEqualsProvider() { return [ [true, true, true], @@ -151,7 +151,7 @@ public function testParseUrlReturnsNullWithQuery() $this->assertEquals(null, $result); } - public function isValidHostLabelProvider() + public static function isValidHostLabelProvider() { return [ "valid" => ["exampleHostLabel", false, true], @@ -174,7 +174,7 @@ public function testIsValidHostLabel($hostLabel, $allowSubDomains, $expected) $this->assertSame($expected, $this->standardLibrary->isValidHostLabel($hostLabel, $allowSubDomains)); } - public function resolveTemplateStringProvider() + public static function resolveTemplateStringProvider() { $params = [ 'ShorthandSyntax' => [ @@ -233,7 +233,7 @@ public function testResolveTemplateString($string, $inputParams, $expected) $this->assertEquals($expected, $result); } - public function NullParamProvider() + public static function NullParamProvider() { $params = [ 'Region' => 'us-east-1', diff --git a/tests/EventBridge/EventBridgeClientTest.php b/tests/EventBridge/EventBridgeClientTest.php index c09f3ad122..7e3f112146 100644 --- a/tests/EventBridge/EventBridgeClientTest.php +++ b/tests/EventBridge/EventBridgeClientTest.php @@ -13,7 +13,7 @@ class EventBridgeClientTest extends TestCase { use UsesServiceTrait; - public function putEventsEndpointSuccessProvider() + public static function putEventsEndpointSuccessProvider() { return [ @@ -138,7 +138,7 @@ public function testPutEventsEndpointSuccessCases( $client->execute($command); } - public function putEventsEndpointFailureProvider() + public static function putEventsEndpointFailureProvider() { return [ diff --git a/tests/Exception/AwsExceptionTest.php b/tests/Exception/AwsExceptionTest.php index 4f36415cdf..0a5620acd8 100644 --- a/tests/Exception/AwsExceptionTest.php +++ b/tests/Exception/AwsExceptionTest.php @@ -235,7 +235,7 @@ public function testAcceptsVariousThrowableTypes(\Throwable $previous): void $this->assertInstanceOf(\Throwable::class, $e->getPrevious()); } - public function previousThrowableProvider(): array + public static function previousThrowableProvider(): array { return [ 'standard exception' => [new \Exception('Standard exception')], diff --git a/tests/Exception/MultipartUploadExceptionTest.php b/tests/Exception/MultipartUploadExceptionTest.php index 336e637951..3f0405f4c9 100644 --- a/tests/Exception/MultipartUploadExceptionTest.php +++ b/tests/Exception/MultipartUploadExceptionTest.php @@ -30,7 +30,7 @@ public function testCanCreateMultipartException($commandName, $status) $this->assertSame($prev, $exception->getPrevious()); } - public function getTestCases() + public static function getTestCases() { return [ ['CreateMultipartUpload', 'initiating'], diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index bd42037585..aa7d966410 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -326,7 +326,7 @@ public function testValidatesHostnames($hostname, $expected) $this->assertEquals($expected, Aws\is_valid_hostname($hostname)); } - public function getHostnameTestCases() + public static function getHostnameTestCases() { return [ ['a', true], @@ -378,7 +378,7 @@ public function testValidatesHostlabels($label, $expected) $this->assertEquals($expected, Aws\is_valid_hostlabel($label)); } - public function getHostlabelTestCases() + public static function getHostlabelTestCases() { return [ ['us-west-2', true], @@ -419,7 +419,7 @@ public function testParsesIniFile($ini, $expected) unlink($tmpFile); } - public function getIniFileTestCases() + public static function getIniFileTestCases() { return [ [ @@ -479,7 +479,7 @@ public function testParsesIniSectionsWithSubsections($ini, $expected) unlink($tmpFile); } - public function getIniFileServiceTestCases() + public static function getIniFileServiceTestCases() { return [ [ @@ -521,7 +521,7 @@ public function testIsAssociative($array, $expected) $this->assertEquals($expected, $result); } - public function isAssociativeProvider() + public static function isAssociativeProvider() { return [ [[], false], diff --git a/tests/Glacier/MultipartUploaderTest.php b/tests/Glacier/MultipartUploaderTest.php index 023dd21d19..5350138925 100644 --- a/tests/Glacier/MultipartUploaderTest.php +++ b/tests/Glacier/MultipartUploaderTest.php @@ -55,7 +55,7 @@ public function testGlacierMultipartUploadWorkflow( $this->assertSame('buzz', $result['fizz']); } - public function getTestCases() + public static function getTestCases() { $defaults = [ 'account_id' => 'foo', diff --git a/tests/InputValidationMiddlewareTest.php b/tests/InputValidationMiddlewareTest.php index 3dd52a3b55..3d619d8f6a 100644 --- a/tests/InputValidationMiddlewareTest.php +++ b/tests/InputValidationMiddlewareTest.php @@ -21,7 +21,7 @@ class InputValidationMiddlewareTest extends TestCase * * @return array */ - public function getInvalidEndpointExceptions() + public static function getInvalidEndpointExceptions() { return [ [''], @@ -36,7 +36,7 @@ public function getInvalidEndpointExceptions() * * @return array */ - public function getValidInputs() + public static function getValidInputs() { return [ ['existing data'], diff --git a/tests/MetricsBuilderTest.php b/tests/MetricsBuilderTest.php index 8e4fc703c9..2880e97f1e 100644 --- a/tests/MetricsBuilderTest.php +++ b/tests/MetricsBuilderTest.php @@ -122,7 +122,7 @@ public function testResolveAndAppendFromArgs( * * @return array[] */ - public function resolveAndAppendFromArgsProvider(): array + public static function resolveAndAppendFromArgsProvider(): array { return [ 'endpoint_override' => [ diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index 1cfd67ac71..986005ee04 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -414,7 +414,7 @@ public function testRecursionDetection($mockHandler, $name, $trace) putenv('_X_AMZN_TRACE_ID'); } - public function recursionDetectionProvider() + public static function recursionDetectionProvider() { $addHeaderMock = function ($command, $request) { $this->assertTrue($request->hasHeader('X-Amzn-Trace-Id')); diff --git a/tests/MultiRegionClientTest.php b/tests/MultiRegionClientTest.php index 419ca63f90..a7a39f4414 100644 --- a/tests/MultiRegionClientTest.php +++ b/tests/MultiRegionClientTest.php @@ -124,7 +124,7 @@ public function testProxiesCallsToRegionalizedClient($method, array $args) call_user_func_array([$this->instance, $method], $args); } - public function clientInterfaceMethodProvider() + public static function clientInterfaceMethodProvider() { return [ ['getConfig', ['someOption']], diff --git a/tests/Multipart/AbstractUploaderTest.php b/tests/Multipart/AbstractUploaderTest.php index f92331c294..784a086e7d 100644 --- a/tests/Multipart/AbstractUploaderTest.php +++ b/tests/Multipart/AbstractUploaderTest.php @@ -222,7 +222,7 @@ public function testCommandGeneratorYieldsExpectedUploadCommands( $this->assertEquals($expectedBodies, $actualBodies); } - public function getPartGeneratorTestCases() + public static function getPartGeneratorTestCases() { $expected = [ 1 => 'AA', diff --git a/tests/Multipart/UploadStateTest.php b/tests/Multipart/UploadStateTest.php index 0d810b0d20..17081d7d94 100644 --- a/tests/Multipart/UploadStateTest.php +++ b/tests/Multipart/UploadStateTest.php @@ -93,7 +93,7 @@ public function testGetDisplayProgressPrintsProgress( $this->expectOutputString($progressBar); } - public function getDisplayProgressCases() + public static function getDisplayProgressCases() { $progressBar = ["Transfer initiated...\n| | 0.0%\n", "|== | 12.5%\n", @@ -185,7 +185,7 @@ public function testUploadThresholds($totalSize) $this->assertCount(9, $threshold); } - public function getThresholdCases() + public static function getThresholdCases() { return [ [0], @@ -217,7 +217,7 @@ public function testDisplayProgressThrowsException($totalUploaded) $state->getDisplayProgress($totalUploaded); } - public function getInvalidIntCases() + public static function getInvalidIntCases() { return [ [''], diff --git a/tests/Neptune/NeptuneClientTest.php b/tests/Neptune/NeptuneClientTest.php index 9d7daac579..8eb152faa1 100644 --- a/tests/Neptune/NeptuneClientTest.php +++ b/tests/Neptune/NeptuneClientTest.php @@ -26,7 +26,7 @@ public static function tear_down_after_class() $_SERVER['formatAwsTime'] = null; } - public function neptunePresignMethodProvider() + public static function neptunePresignMethodProvider() { return [ ['CopyDBClusterSnapshot', ['SourceDBClusterSnapshotIdentifier' => 'arn:aws:rds:us-east-1:123456789012:cluster-snapshot:source-db-cluster-snapshot', 'TargetDBClusterSnapshotIdentifier' => 'target-db-cluster-snapshot'], null, null, null, null], diff --git a/tests/PresignUrlMiddlewareTest.php b/tests/PresignUrlMiddlewareTest.php index f1de50fee3..71e52410be 100644 --- a/tests/PresignUrlMiddlewareTest.php +++ b/tests/PresignUrlMiddlewareTest.php @@ -151,7 +151,7 @@ public function testExtraQueryParametersAreURLEncoded( /** * @return array[] */ - public function extraQueryParamsProvider(): array + public static function extraQueryParamsProvider(): array { return [ 'simple_parameter' => [ diff --git a/tests/Psr16CacheAdapterTest.php b/tests/Psr16CacheAdapterTest.php index 337d5db31e..f8512aa0ab 100644 --- a/tests/Psr16CacheAdapterTest.php +++ b/tests/Psr16CacheAdapterTest.php @@ -66,7 +66,7 @@ public function testProxiesRemoveCallsToPsrCache($key) $this->instance->remove($key); } - public function cacheDataProvider() + public static function cacheDataProvider() { return [ ['foo', 'bar', 300], diff --git a/tests/PsrCacheAdapterTest.php b/tests/PsrCacheAdapterTest.php index 9b1911c097..91a6743748 100644 --- a/tests/PsrCacheAdapterTest.php +++ b/tests/PsrCacheAdapterTest.php @@ -90,7 +90,7 @@ public function testProxiesRemoveCallsToPsrCache($key) $this->instance->remove($key); } - public function cacheDataProvider() + public static function cacheDataProvider() { return [ ['foo', 'bar', 300], diff --git a/tests/QueryCompatibleInputMiddlewareTest.php b/tests/QueryCompatibleInputMiddlewareTest.php index 6ac662b65b..d6460a2b90 100644 --- a/tests/QueryCompatibleInputMiddlewareTest.php +++ b/tests/QueryCompatibleInputMiddlewareTest.php @@ -68,7 +68,7 @@ function (Command $command) use ($inputParam, $expected) { * * @return array */ - public function getInputs() + public static function getInputs() { return [ ['IntParam', '10', 10, 'integer'], diff --git a/tests/Rds/AuthTokenGeneratorTest.php b/tests/Rds/AuthTokenGeneratorTest.php index c3bfdef93c..bcb02fd1f0 100644 --- a/tests/Rds/AuthTokenGeneratorTest.php +++ b/tests/Rds/AuthTokenGeneratorTest.php @@ -56,7 +56,7 @@ public function testCanCreateAuthTokenWthCredentialProvider() $this->assertStringContainsString('Action=connect', $token); } - public function lifetimeProvider() + public static function lifetimeProvider() { return [ [1], @@ -91,7 +91,7 @@ public function testCanCreateAuthTokenWthNonDefaultLifetime($lifetime) $this->assertStringContainsString('Action=connect', $token); } - public function lifetimeFailureProvider() + public static function lifetimeFailureProvider() { return [ [0], diff --git a/tests/Rds/RdsClientTest.php b/tests/Rds/RdsClientTest.php index ca862cc726..6de3885773 100644 --- a/tests/Rds/RdsClientTest.php +++ b/tests/Rds/RdsClientTest.php @@ -53,7 +53,7 @@ function ($command, $request) { ]); } - public function rdsPresignMethodProvider() + public static function rdsPresignMethodProvider() { return [ ['copyDBSnapshot', ['SourceDBSnapshotIdentifier' => 'arn:aws:rds:us-east-1:123456789012:snapshot:source-db-snapshot', 'TargetDBSnapshotIdentifier' => 'target-db-snapshot'], null, null, null, null], diff --git a/tests/RequestCompression/RequestCompressionMiddlewareTest.php b/tests/RequestCompression/RequestCompressionMiddlewareTest.php index 93f8e4237c..ff82fb18b8 100644 --- a/tests/RequestCompression/RequestCompressionMiddlewareTest.php +++ b/tests/RequestCompression/RequestCompressionMiddlewareTest.php @@ -56,7 +56,7 @@ public function testDoesNotCompressRequestWhenConfigured() ]); } - public function specificSizeProvider() + public static function specificSizeProvider() { return [ [60, 0, 65], @@ -172,7 +172,7 @@ public function testCommandLevelMinRequestSizeOverrides() ]); } - public function invalidDisableCompressionType() + public static function invalidDisableCompressionType() { return [ ['foo'], @@ -193,7 +193,7 @@ public function testThrowsExceptionWhenDisableMinCompressionNotBool($invalidType $client = $this->generateTestClient($service, ['disable_request_compression' => $invalidType]); } - public function invalidMinRequestSizeProvider() + public static function invalidMinRequestSizeProvider() { return [ [-1], diff --git a/tests/Retry/ConfigurationProviderTest.php b/tests/Retry/ConfigurationProviderTest.php index cb84898b25..846f17e68d 100644 --- a/tests/Retry/ConfigurationProviderTest.php +++ b/tests/Retry/ConfigurationProviderTest.php @@ -362,7 +362,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData() { $expected = new Configuration('standard', 30); return [ diff --git a/tests/Retry/RateLimiterTest.php b/tests/Retry/RateLimiterTest.php index d2784a4ab2..4f211b308b 100644 --- a/tests/Retry/RateLimiterTest.php +++ b/tests/Retry/RateLimiterTest.php @@ -50,7 +50,7 @@ public function testCorrectlyCalculatesSendingRate() $this->assertSame(2.048, $rateLimiter->updateSendingRate(false)); } - public function cubicSuccessProvider() + public static function cubicSuccessProvider() { return [ [5, 7], diff --git a/tests/RetryMiddlewareTest.php b/tests/RetryMiddlewareTest.php index f38a061543..8a021016d3 100644 --- a/tests/RetryMiddlewareTest.php +++ b/tests/RetryMiddlewareTest.php @@ -149,7 +149,7 @@ public function testDeciderRetriesForCustomCurlErrors() $this->assertFalse($decider(0, $command, $request, null, $err)); } - public function awsErrorCodeProvider() + public static function awsErrorCodeProvider() { $command = new Command('foo'); return [ diff --git a/tests/RetryMiddlewareV2Test.php b/tests/RetryMiddlewareV2Test.php index 325af59f49..ef214ec077 100644 --- a/tests/RetryMiddlewareV2Test.php +++ b/tests/RetryMiddlewareV2Test.php @@ -583,7 +583,7 @@ public function testDeciderRetriesForCustomCurlErrors() $this->assertFalse($decider(0, $command, $err)); } - public function awsErrorCodeProvider() + public static function awsErrorCodeProvider() { $command = new Command('foo'); return [ diff --git a/tests/S3/AmbiguousSuccessParserTest.php b/tests/S3/AmbiguousSuccessParserTest.php index 75d8f5ee1a..17044af4f7 100644 --- a/tests/S3/AmbiguousSuccessParserTest.php +++ b/tests/S3/AmbiguousSuccessParserTest.php @@ -91,7 +91,7 @@ public function testThrowsConnectionErrorForEmptyBody($operation) $instance($command, $response); } - public function opsWithAmbiguousSuccessesProvider() + public static function opsWithAmbiguousSuccessesProvider() { return [ ['CopyObject'], @@ -101,7 +101,7 @@ public function opsWithAmbiguousSuccessesProvider() ]; } - public function opsWithoutAmbiguousSuccessesProvider() + public static function opsWithoutAmbiguousSuccessesProvider() { $provider = ApiProvider::defaultProvider(); return array_map( diff --git a/tests/S3/ApplyChecksumMiddlewareTest.php b/tests/S3/ApplyChecksumMiddlewareTest.php index 361aebd2e1..c411f74bf8 100644 --- a/tests/S3/ApplyChecksumMiddlewareTest.php +++ b/tests/S3/ApplyChecksumMiddlewareTest.php @@ -54,7 +54,7 @@ public function testFlexibleChecksums( $mw($command, $request); } - public function getFlexibleChecksumUseCases() + public static function getFlexibleChecksumUseCases() { return [ 'http_checksum_not_modeled' => [ @@ -215,7 +215,7 @@ public function testAddsContentSHA256($operation, $args, $hashAdded, $hashValue) $mw($command, $request); } - public function getContentSha256UseCases() + public static function getContentSha256UseCases() { $hash = 'SHA256HASH'; diff --git a/tests/S3/BucketEndpointArnMiddlewareTest.php b/tests/S3/BucketEndpointArnMiddlewareTest.php index 81cac0cd5f..1ef7f33185 100644 --- a/tests/S3/BucketEndpointArnMiddlewareTest.php +++ b/tests/S3/BucketEndpointArnMiddlewareTest.php @@ -84,7 +84,7 @@ public function testCorrectlyModifiesUri( $s3->execute($command); } - public function accessPointArnCases() + public static function accessPointArnCases() { return [ // Standard case @@ -356,7 +356,7 @@ public function testThrowsForIncorrectArnUsage($command, $config, \Exception $ex } } - public function incorrectUsageProvider() + public static function incorrectUsageProvider() { return [ [ diff --git a/tests/S3/BucketEndpointMiddlewareTest.php b/tests/S3/BucketEndpointMiddlewareTest.php index 9d9a9f8110..a55fddfb0e 100644 --- a/tests/S3/BucketEndpointMiddlewareTest.php +++ b/tests/S3/BucketEndpointMiddlewareTest.php @@ -137,7 +137,7 @@ public function testHandlesDuplicatePath(): void $s3->execute($command); } - public function keyContainsBucketNameProvider(): iterable + public static function keyContainsBucketNameProvider(): iterable { return [ ['bucketname'], diff --git a/tests/S3/GetBucketLocationParserTest.php b/tests/S3/GetBucketLocationParserTest.php index bdfccf58df..de638dd714 100644 --- a/tests/S3/GetBucketLocationParserTest.php +++ b/tests/S3/GetBucketLocationParserTest.php @@ -33,7 +33,7 @@ public function testParsesLocationFromGetBucketLocationOperations( $this->assertEquals($expectedValue, $result['LocationConstraint']); } - public function getTestCases() + public static function getTestCases() { return [ ['GetBucketLocation', 'us-west-2', 'us-west-2'], diff --git a/tests/S3/MultipartCopyTest.php b/tests/S3/MultipartCopyTest.php index be4c9dcc34..75460d9681 100644 --- a/tests/S3/MultipartCopyTest.php +++ b/tests/S3/MultipartCopyTest.php @@ -48,7 +48,7 @@ public function testS3MultipartCopyWorkflow( $this->assertSame($url, $result['ObjectURL']); } - public function getTestCases() + public static function getTestCases() { $defaults = [ 'bucket' => 'foo', diff --git a/tests/S3/MultipartUploaderTest.php b/tests/S3/MultipartUploaderTest.php index 1885a0274d..022f93c920 100644 --- a/tests/S3/MultipartUploaderTest.php +++ b/tests/S3/MultipartUploaderTest.php @@ -60,7 +60,7 @@ public function testS3MultipartUploadWorkflow( $this->assertSame($url, $result['ObjectURL']); } - public function getTestCases() + public static function getTestCases() { $defaults = [ 'bucket' => 'foo', @@ -135,7 +135,7 @@ public function testCanUseCaseInsensitiveConfigKeys() } /** @doesNotPerformAssertions */ - public function testMultipartSuccessStreams() + public static function testMultipartSuccessStreams() { $size = 12 * self::MB; $data = str_repeat('.', $size); @@ -196,7 +196,7 @@ public function testS3MultipartUploadParams($stream, $size) $this->assertSame($url, $result['ObjectURL']); } - public function getContentTypeSettingTests() + public static function getContentTypeSettingTests() { $size = 12 * self::MB; $data = str_repeat('.', $size); diff --git a/tests/S3/ObjectCopierTest.php b/tests/S3/ObjectCopierTest.php index fd2c8bcf09..674c5ba086 100644 --- a/tests/S3/ObjectCopierTest.php +++ b/tests/S3/ObjectCopierTest.php @@ -210,7 +210,7 @@ private function getMultipartMockResults($key = 'key') ); } - public function getCopyTestCases() + public static function getCopyTestCases() { return [ [ @@ -239,7 +239,7 @@ private function getPathStyleMultipartMockResults() ); } - public function getCopyTestCasesWithPathStyle() + public static function getCopyTestCasesWithPathStyle() { return [ [ @@ -398,7 +398,7 @@ public function testS3ObjectCopierDoesTransformUnicodeKeyToEncodedURL() $this->assertSame($url, $result['ObjectURL']); } - public function MultipartCopierProvider(){ + public static function MultipartCopierProvider(){ return [ ["中文", "文件夹/文件"], ["文件夹/文件", "中文"], diff --git a/tests/S3/ObjectUploaderTest.php b/tests/S3/ObjectUploaderTest.php index 8edbdf3a32..e6e8855bc5 100644 --- a/tests/S3/ObjectUploaderTest.php +++ b/tests/S3/ObjectUploaderTest.php @@ -128,7 +128,7 @@ public function testDoesCorrectOperationAsynchronouslyWithPathStyle( $this->assertSame('https://s3.amazonaws.com/bucket/key', $result['ObjectURL']); } - public function getUploadTestCases() + public static function getUploadTestCases() { $putObject = new Result(); $initiate = new Result(['UploadId' => 'foo']); @@ -175,7 +175,7 @@ public function getUploadTestCases() ]; } - public function getUploadTestCasesWithPathStyle() + public static function getUploadTestCasesWithPathStyle() { $putObject = new Result(); $initiate = new Result(['UploadId' => 'foo']); @@ -353,7 +353,7 @@ function ($cmd, $req) use ($checksumAlgorithm, $value) { ))->upload(); } - public function flexibleChecksumsProvider() { + public static function flexibleChecksumsProvider() { return [ ['sha1', 'VfWih+7phcE4uG3HQZCHKfpUwFs='], ['sha256', 'FT+vHyoAcJfTMSC77mlEpBy4vnZDwSIva8a8aewxaI8='], diff --git a/tests/S3/Parser/GetBucketLocationResultMutatorTest.php b/tests/S3/Parser/GetBucketLocationResultMutatorTest.php index 95ed01a234..1ca5f9bd31 100644 --- a/tests/S3/Parser/GetBucketLocationResultMutatorTest.php +++ b/tests/S3/Parser/GetBucketLocationResultMutatorTest.php @@ -30,7 +30,7 @@ public function testInjectsLocationConstraint($operationName, $responseBody, $ex $this->assertEquals($expectedValue, $result['LocationConstraint']); } - public function getTestCases() + public static function getTestCases() { return [ ['GetBucketLocation', 'us-west-2', 'us-west-2'], diff --git a/tests/S3/Parser/S3ParserTest.php b/tests/S3/Parser/S3ParserTest.php index a028d0ab50..17965f12e9 100644 --- a/tests/S3/Parser/S3ParserTest.php +++ b/tests/S3/Parser/S3ParserTest.php @@ -58,7 +58,7 @@ public function testHandle200Errors(string $operation) * * @return \Generator */ - public function s3200ErrorHandlingCasesProvider(): \Generator + public static function s3200ErrorHandlingCasesProvider(): \Generator { $operations = [ 'AbortMultipartUpload', @@ -284,7 +284,7 @@ public function testValidate200ErrorValidationJustInSeekableStreams( /** * @return array[] */ - public function validate200ErrorValidationJustInSeekableStreamsProvider(): array + public static function validate200ErrorValidationJustInSeekableStreamsProvider(): array { return [ 'seekable_stream_1' => [ diff --git a/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php b/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php index 2538241c33..36437c2723 100644 --- a/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php +++ b/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php @@ -83,7 +83,7 @@ public function testChecksumValidation( * * @return array[] */ - public function checksumCasesDataProvider(): array + public static function checksumCasesDataProvider(): array { return [ //Default, when_supported, no checksum headers, skips validation diff --git a/tests/S3/PostObjectTest.php b/tests/S3/PostObjectTest.php index dd9eeec599..4d412c261c 100644 --- a/tests/S3/PostObjectTest.php +++ b/tests/S3/PostObjectTest.php @@ -103,7 +103,7 @@ public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expect $this->assertSame($expected, $formAttrs['action']); } - public function pathStyleProvider() + public static function pathStyleProvider() { return [ ['http://s3.amazonaws.com', 'foo', 'http://s3.amazonaws.com/foo'], diff --git a/tests/S3/PostObjectV4Test.php b/tests/S3/PostObjectV4Test.php index b891b96847..4a6b221802 100644 --- a/tests/S3/PostObjectV4Test.php +++ b/tests/S3/PostObjectV4Test.php @@ -268,7 +268,7 @@ public function testCanHandleVirtualStyleEndpoint($endpoint, $bucket, $expected) $this->assertSame($expected, $formAttrs['action']); } - public function virtualStyleProvider() + public static function virtualStyleProvider() { return [ ['http://foo.s3.amazonaws.com', 'foo', 'http://foo.s3.amazonaws.com'], @@ -303,7 +303,7 @@ public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expect $this->assertSame($expected, $formAttrs['action']); } - public function pathStyleProvider() + public static function pathStyleProvider() { return [ ['http://s3.amazonaws.com', 'foo', 'http://s3.amazonaws.com/foo'], diff --git a/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php b/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php index ba8ac36b3f..12936986e8 100644 --- a/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php +++ b/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php @@ -262,7 +262,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData() { $expected = new Configuration('regional'); return [ diff --git a/tests/S3/S3ClientTest.php b/tests/S3/S3ClientTest.php index 833314672e..29d273b94b 100644 --- a/tests/S3/S3ClientTest.php +++ b/tests/S3/S3ClientTest.php @@ -53,7 +53,7 @@ public function testCanUseBucketEndpoint() ); } - public function bucketNameProvider() + public static function bucketNameProvider() { return [ ['.bucket', false], @@ -261,7 +261,7 @@ public function testRegistersStreamWrapper() stream_wrapper_unregister('s3'); } - public function doesExistProvider() + public static function doesExistProvider() { $redirectException = new PermanentRedirectException( '', @@ -541,7 +541,7 @@ public function testAddsLocationConstraintAutomatically($region, $target, $comma } } - public function getTestCasesForLocationConstraints() + public static function getTestCasesForLocationConstraints() { return [ ['us-west-2', 'us-west-2', 'CreateBucket', true], @@ -568,7 +568,7 @@ public function testDoesNotAddLocationConstraintForDirectoryBuckets( $this->assertStringNotContainsString('LocationConstraint', $body); } - public function directoryBucketLocationConstraintProvider(): array + public static function directoryBucketLocationConstraintProvider(): array { return [ ['bucket-base-name--usw2-az1--x-s3'], @@ -653,7 +653,7 @@ public function testRetriesConnectionErrors($retrySettings) $this->assertSame(0, $retries); } - public function clientRetrySettingsProvider() + public static function clientRetrySettingsProvider() { return [ [ @@ -718,7 +718,7 @@ public function testRetries200Errors( * * @return \Generator */ - public function s3OperationsProvider(): \Generator + public static function s3OperationsProvider(): \Generator { $operations = $this->loadOperations(); $retryModes = [ @@ -1573,7 +1573,7 @@ public function testResolvesOptionsToProperEndpoints($options, $host) $client->listBuckets(); } - public function optionsToEndpointsCases() + public static function optionsToEndpointsCases() { $handler = function ($cmd, $req) { return Promise\Create::promiseFor(new Result([])); @@ -1691,7 +1691,7 @@ public function testRetriesAmbiguousSuccesses() $this->assertSame(3, $counter); } - public function multiRegionSuccessProvider() + public static function multiRegionSuccessProvider() { return [ @@ -1753,7 +1753,7 @@ public function testMrapParsing( $client->execute($command); } - public function mrapExceptionTestProvider() { + public static function mrapExceptionTestProvider() { return [ [ "arn:aws:s3::123456789012:accesspoint:mfzwi23gnjvgw.mrap", "us-west-2", null, null, true, @@ -1859,7 +1859,7 @@ public function testAccessPointFailures ( self::assertStringContainsString($expectedException, $e->getMessage()); } } - public function AccessPointFailureProvider() + public static function AccessPointFailureProvider() { return [ [ @@ -1948,7 +1948,7 @@ public function testPresignedMrapFailure () } } - public function jsonCaseProvider() + public static function jsonCaseProvider() { return json_decode( file_get_contents(__DIR__ . '/test_cases/uri_addressing.json'), @@ -2045,7 +2045,7 @@ public function testObjectLambdaArnSuccess( $client->execute($command); } - public function objectLambdasSuccessProvider() + public static function objectLambdasSuccessProvider() { return [ ["arn:aws:s3-object-lambda:us-east-1:123456789012:accesspoint/mybanner", "us-east-1", "none", false, null, "mybanner-123456789012.s3-object-lambda.us-east-1.amazonaws.com"], @@ -2124,7 +2124,7 @@ public function testObjectLambdaArnFailures( } } - public function objectLambdasFailureProvider() + public static function objectLambdasFailureProvider() { return [ [ @@ -2236,7 +2236,7 @@ public function testWriteGetObjectResponse( $client->execute($command); } - public function writeGetObjectResponseProvider() + public static function writeGetObjectResponseProvider() { return [ ["us-west-2", "route", null, 'route.s3-object-lambda.us-west-2.amazonaws.com'], @@ -2286,7 +2286,7 @@ public function testAddsForwardSlashIfEmptyPathAndQuery() $s3->execute($command); } - public function addMD5Provider() { + public static function addMD5Provider() { return [ [ ['Bucket' => 'foo', 'Key' => 'foo', 'Body' => 'test'], @@ -2338,7 +2338,7 @@ public function testHandlesDotSegmentsInKey($key, $expectedUri) $s3->execute($command); } - public function dotSegmentProvider() + public static function dotSegmentProvider() { return [ ['../foo' , 'https://foo.s3.amazonaws.com/../foo'], @@ -2365,7 +2365,7 @@ public function testHandlesDotSegmentsInKeyWithPathStyle($key, $expectedUri) $s3->execute($command); } - public function dotSegmentPathStyleProvider() + public static function dotSegmentPathStyleProvider() { return [ ['../foo' , 'https://s3.amazonaws.com/bucket/../foo'], @@ -2480,7 +2480,7 @@ public function testBucketNotModifiedWithLegacyEndpointProvider() ); } - public function builtinRegionProvider() + public static function builtinRegionProvider() { return [ ['us-east-1' , true], @@ -2530,7 +2530,7 @@ public function testIsDirectoryBucket(string $bucketName, bool $expected): void $this->assertEquals($expected, $client::isDirectoryBucket($bucketName)); } - public function directoryBucketProvider(): array + public static function directoryBucketProvider(): array { return [ ['bucket-base-name--usw2-az1--x-s3', true], @@ -2582,7 +2582,7 @@ public function testAddsContentSHA256AsAppropriate($operation, $args, $hashAdded $s3->execute($command); } - public function getContentSha256UseCases() + public static function getContentSha256UseCases() { $hash = 'SHA256HASH'; @@ -2637,7 +2637,7 @@ public function testAddsFlexibleChecksumAsAppropriate($operation, $clientArgs, $ $s3->execute($command); } - public function getFlexibleChecksumUseCases() + public static function getFlexibleChecksumUseCases() { return [ // httpChecksum not modeled @@ -2777,7 +2777,7 @@ public function testResponseChecksumValidation( $this->assertEquals($checksumAlgorithm, $result['ChecksumValidated']); } - public function responseChecksumValidationProvider(): array + public static function responseChecksumValidationProvider(): array { return [ [ @@ -2835,7 +2835,7 @@ public function testChecksumConfigThrowsForInvalidInput( ); } - public function checksumConfigProvider() + public static function checksumConfigProvider() { return [ ['request_checksum_calculation', 'foo'], @@ -2976,7 +2976,7 @@ public function testRetriesWithoutRecalculatingChecksum( ); } - public function retriesWithoutRecalculatingChecksumProvider(): array + public static function retriesWithoutRecalculatingChecksumProvider(): array { return [ 'PutObject legacy' => [ diff --git a/tests/S3/S3EndpointMiddlewareTest.php b/tests/S3/S3EndpointMiddlewareTest.php index 58b6ac7480..35dcd529f2 100644 --- a/tests/S3/S3EndpointMiddlewareTest.php +++ b/tests/S3/S3EndpointMiddlewareTest.php @@ -354,14 +354,14 @@ public function testApplyingEndpointWhenEndpointOptionAndPathStyleAreSet() $middleware($command, $request); } - public function excludedCommandProvider() + public static function excludedCommandProvider() { return array_map(function ($commandName) { return [new Command($commandName, ['Bucket' => 'bucket'])]; }, ['ListBuckets', 'CreateBucket', 'DeleteBucket']); } - public function includedCommandProvider() + public static function includedCommandProvider() { $excludedOperations = array_map(function (array $args) { return $args[0]->getName(); @@ -488,7 +488,7 @@ private function ipAddressPathStyleFallbackAssertingHandler(CommandInterface $co }; } - public function jsonCaseProvider() + public static function jsonCaseProvider() { return json_decode( file_get_contents(__DIR__ . '/test_cases/uri_addressing.json'), @@ -585,7 +585,7 @@ public function testObjectLambdaArnSuccess( $client->execute($command); } - public function objectLambdasSuccessProvider() + public static function objectLambdasSuccessProvider() { return [ ["arn:aws:s3-object-lambda:us-east-1:123456789012:accesspoint/mybanner", "us-east-1", "none", false, null, "mybanner-123456789012.s3-object-lambda.us-east-1.amazonaws.com"], @@ -664,7 +664,7 @@ public function testObjectLambdaArnFailures( } } - public function objectLambdasFailureProvider() + public static function objectLambdasFailureProvider() { return [ ["arn:aws:s3-object-lambda:us-east-1:123456789012:accesspoint/mybanner", "us-west-2", "none", false, null, @@ -775,7 +775,7 @@ public function testWriteGetObjectResponse( $client->execute($command); } - public function writeGetObjectResponseProvider() + public static function writeGetObjectResponseProvider() { return [ diff --git a/tests/S3/S3MultiRegionClientTest.php b/tests/S3/S3MultiRegionClientTest.php index dde751fff4..54ee3d6ed2 100644 --- a/tests/S3/S3MultiRegionClientTest.php +++ b/tests/S3/S3MultiRegionClientTest.php @@ -602,7 +602,7 @@ public function testCallbacksAttachedToCommandHandlerListsAreInvoked($regionaliz $this->assertSame('object!object!', (string) $result['Body']); } - public function booleanProvider() + public static function booleanProvider() { return [[true], [false]]; } diff --git a/tests/S3/S3Transfer/MultipartUploaderTest.php b/tests/S3/S3Transfer/MultipartUploaderTest.php index 20876cfba5..8688773c7d 100644 --- a/tests/S3/S3Transfer/MultipartUploaderTest.php +++ b/tests/S3/S3Transfer/MultipartUploaderTest.php @@ -137,7 +137,7 @@ public function testMultipartUpload( /** * @return array[] */ - public function multipartUploadProvider(): array { + public static function multipartUploadProvider(): array { return [ '5_parts_upload' => [ 'source_config' => [ @@ -310,7 +310,7 @@ public function testValidatePartSize( /** * @return array */ - public function validatePartSizeProvider(): array { + public static function validatePartSizeProvider(): array { return [ 'part_size_over_max' => [ 'part_size' => AbstractMultipartUploader::PART_MAX_SIZE + 1, @@ -385,7 +385,7 @@ public function testInvalidSourceStringThrowsException( /** * @return array[] */ - public function invalidSourceStringProvider(): array { + public static function invalidSourceStringProvider(): array { return [ 'invalid_source_file_path_1' => [ 'source' => 'invalid', @@ -629,7 +629,7 @@ function (callable $handler) use (&$operationsCalled, $expectedOperationHeaders) /** * @return array */ - public function multipartUploadWithCustomChecksumProvider(): array { + public static function multipartUploadWithCustomChecksumProvider(): array { return [ 'custom_checksum_crc32_1' => [ 'source_config' => [ @@ -893,7 +893,7 @@ public function testFullObjectChecksumWorksJustWithCRC( /** * @return Generator */ - public function fullObjectChecksumWorksJustWithCRCProvider(): Generator { + public static function fullObjectChecksumWorksJustWithCRCProvider(): Generator { yield 'sha_256_should_fail' => [ 'checksum_config' => [ 'ChecksumSHA256' => '47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' @@ -1020,7 +1020,7 @@ function ($commandName, $args) /** * @return Generator */ - public function inputArgumentsPerOperationProvider(): Generator + public static function inputArgumentsPerOperationProvider(): Generator { yield 'test_input_fields_are_copied_without_custom_checksums' => [ // Source config to generate a stub body diff --git a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php index c1d3b4d50f..0300ba3edf 100644 --- a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php @@ -95,7 +95,7 @@ public function testPartGetMultipartDownloader( * * @return array[] */ - public function partGetMultipartDownloaderProvider(): array { + public static function partGetMultipartDownloaderProvider(): array { return [ [ 'objectKey' => 'ObjectKey_1', @@ -288,7 +288,7 @@ public function testIfMatchIsPresentInEachRangeRequestAfterFirst( /** * @return Generator */ - public function ifMatchIsPresentInEachPartRequestAfterFirstProvider(): Generator + public static function ifMatchIsPresentInEachPartRequestAfterFirstProvider(): Generator { yield 'multipart_download_with_3_parts_1' => [ 'object_size_in_bytes' => 1024 * 1024 * 20, diff --git a/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php b/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php index 8536b47cee..def762a2c2 100644 --- a/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php +++ b/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php @@ -39,7 +39,7 @@ public function testProgressBarFormat( /** * @return array[] */ - public function progressBarFormatProvider(): array + public static function progressBarFormatProvider(): array { return [ 'plain_progress_bar_format_1' => [ diff --git a/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php b/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php index 83bb3dd028..fb19ca9902 100644 --- a/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php +++ b/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php @@ -124,7 +124,7 @@ public function testProgressBarRendering( * * @return array */ - public function progressBarRenderingProvider(): array + public static function progressBarRenderingProvider(): array { return [ 'plain_progress_bar_format_1' => [ diff --git a/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php b/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php index 3aaa1d715a..ceb169718b 100644 --- a/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php +++ b/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php @@ -107,7 +107,7 @@ public function testMultiProgressTracker( /** * @return array */ - public function customInitializationProvider(): array + public static function customInitializationProvider(): array { return [ 'custom_initialization_1' => [ @@ -147,7 +147,7 @@ public function customInitializationProvider(): array /** * @return array */ - public function multiProgressTrackerProvider(): array + public static function multiProgressTrackerProvider(): array { return [ 'multi_progress_tracker_1_single_tracking_object' => [ diff --git a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php index a33abc86e8..bc3898f9a5 100644 --- a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php +++ b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php @@ -57,7 +57,7 @@ public function testCustomInitialization( /** * @return array[] */ - public function customInitializationProvider(): array + public static function customInitializationProvider(): array { return [ 'initialization_1' => [ @@ -131,7 +131,7 @@ public function testSingleProgressTracking( /** * @return array[] */ - public function singleProgressTrackingProvider(): array + public static function singleProgressTrackingProvider(): array { return [ 'progress_rendering_1_transfer_initiated' => [ diff --git a/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php b/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php index 5a003a8159..6c81545f07 100644 --- a/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php +++ b/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php @@ -51,7 +51,7 @@ public function testRatioTransferred( /** * @return array */ - public function ratioTransferredProvider(): array + public static function ratioTransferredProvider(): array { return [ 'ratio_1' => [ diff --git a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php index ab6816e014..7b15a6e9d5 100644 --- a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php @@ -96,7 +96,7 @@ public function testRangeGetMultipartDownloader( * * @return array[] */ - public function rangeGetMultipartDownloaderProvider(): array { + public static function rangeGetMultipartDownloaderProvider(): array { return [ [ 'objectKey' => 'ObjectKey_1', @@ -336,7 +336,7 @@ public function testIfMatchIsPresentInEachRangeRequestAfterFirst( /** * @return Generator */ - public function ifMatchIsPresentInEachRangeRequestAfterFirstProvider(): Generator + public static function ifMatchIsPresentInEachRangeRequestAfterFirstProvider(): Generator { yield 'multipart_download_with_3_parts_1' => [ 'object_size_in_bytes' => 1024 * 1024 * 20, diff --git a/tests/S3/S3Transfer/S3TransferManagerTest.php b/tests/S3/S3Transfer/S3TransferManagerTest.php index 0bc349d24d..5def42808c 100644 --- a/tests/S3/S3Transfer/S3TransferManagerTest.php +++ b/tests/S3/S3Transfer/S3TransferManagerTest.php @@ -226,7 +226,7 @@ public function testUploadFailsWhenBucketAndKeyAreNotProvided( /** * @return array[] */ - public function uploadBucketAndKeyProvider(): array + public static function uploadBucketAndKeyProvider(): array { return [ 'bucket_missing' => [ @@ -430,7 +430,7 @@ public function testUploadUsesCustomMupThreshold( /** * @return array */ - public function uploadUsesCustomMupThresholdProvider(): array + public static function uploadUsesCustomMupThresholdProvider(): array { return [ 'mup_threshold_multipart_upload' => [ @@ -564,7 +564,7 @@ public function testUploadUsesCustomChecksumAlgorithm( /** * @return array[] */ - public function uploadUsesCustomChecksumAlgorithmProvider(): array + public static function uploadUsesCustomChecksumAlgorithmProvider(): array { return [ 'checksum_crc32c' => [ @@ -676,7 +676,7 @@ public function testUploadDirectoryValidatesProvidedDirectory( /** * @return array[] */ - public function uploadDirectoryValidatesProvidedDirectoryProvider(): array + public static function uploadDirectoryValidatesProvidedDirectoryProvider(): array { return [ 'valid_directory' => [ @@ -1575,7 +1575,7 @@ public function testDownloadFailsWhenSourceAsArrayMissesBucketOrKeyProperty( /** * @return array */ - public function downloadFailsWhenSourceAsArrayMissesBucketOrKeyPropertyProvider(): array + public static function downloadFailsWhenSourceAsArrayMissesBucketOrKeyPropertyProvider(): array { return [ 'missing_key' => [ @@ -1727,7 +1727,7 @@ public function testDownloadAppliesChecksumMode( /** * @return array */ - public function downloadAppliesChecksumProvider(): array + public static function downloadAppliesChecksumProvider(): array { return [ 'checksum_mode_from_default_transfer_manager_config' => [ @@ -1840,7 +1840,7 @@ public function testDownloadChoosesMultipartDownloadType( /** * @return array */ - public function downloadChoosesMultipartDownloadTypeProvider(): array + public static function downloadChoosesMultipartDownloadTypeProvider(): array { return [ 'part_get_multipart_download' => [ @@ -1913,7 +1913,7 @@ public function testRangeGetMultipartDownloadMinimumPartSize( /** * @return array */ - public function rangeGetMultipartDownloadMinimumPartSizeProvider(): array + public static function rangeGetMultipartDownloadMinimumPartSizeProvider(): array { return [ 'minimum_part_size_1' => [ @@ -2077,7 +2077,7 @@ public function testDownloadDirectoryAppliesS3Prefix( /** * @return array */ - public function downloadDirectoryAppliesS3PrefixProvider(): array + public static function downloadDirectoryAppliesS3PrefixProvider(): array { return [ 's3_prefix_from_config' => [ @@ -2398,7 +2398,7 @@ public function testDownloadDirectoryAppliesFilter( /** * @return array[] */ - public function downloadDirectoryAppliesFilterProvider(): array + public static function downloadDirectoryAppliesFilterProvider(): array { return [ 'filter_1' => [ @@ -2688,7 +2688,7 @@ public function testDownloadDirectoryCreateFiles( /** * @return array */ - public function downloadDirectoryCreateFilesProvider(): array + public static function downloadDirectoryCreateFilesProvider(): array { return [ 'files_1' => [ @@ -2822,7 +2822,7 @@ public function testResolvesOutsideTargetDirectory( /** * @return array */ - public function resolvesOutsideTargetDirectoryProvider(): array + public static function resolvesOutsideTargetDirectoryProvider(): array { return [ 'download_directory_1_linux' => [ @@ -3682,7 +3682,7 @@ private function parseConfigFromCamelCaseToSnakeCase( /** * @return Generator */ - public function modeledDownloadCasesProvider(): Generator + public static function modeledDownloadCasesProvider(): Generator { $downloadCases = json_decode( file_get_contents( @@ -3704,7 +3704,7 @@ public function modeledDownloadCasesProvider(): Generator /** * @return Generator */ - public function modeledUploadCasesProvider(): Generator + public static function modeledUploadCasesProvider(): Generator { $downloadCases = json_decode( file_get_contents( @@ -3726,7 +3726,7 @@ public function modeledUploadCasesProvider(): Generator /** * @return Generator */ - public function modeledUploadDirectoryCasesProvider(): Generator + public static function modeledUploadDirectoryCasesProvider(): Generator { $uploadDirectoryCases = json_decode( file_get_contents( @@ -3761,7 +3761,7 @@ public function modeledUploadDirectoryCasesProvider(): Generator /** * @return Generator */ - public function modeledDownloadDirectoryCasesProvider(): Generator + public static function modeledDownloadDirectoryCasesProvider(): Generator { $downloadDirectoryCases = json_decode( file_get_contents( diff --git a/tests/S3/S3UriParserTest.php b/tests/S3/S3UriParserTest.php index 39c9b4d864..6a9a173fbb 100644 --- a/tests/S3/S3UriParserTest.php +++ b/tests/S3/S3UriParserTest.php @@ -10,7 +10,7 @@ */ class S3UriParserTest extends TestCase { - public function uriProvider() + public static function uriProvider() { return [ ['http://s3.amazonaws.com', ['region' => null, 'bucket' => null, 'key' => null, 'path_style' => true]], diff --git a/tests/S3/SSECMiddlewareTest.php b/tests/S3/SSECMiddlewareTest.php index 21dfd1f83d..5dc03103a9 100644 --- a/tests/S3/SSECMiddlewareTest.php +++ b/tests/S3/SSECMiddlewareTest.php @@ -31,7 +31,7 @@ public function testSseCpkListener($operation, array $params, array $expectedRes $s3->execute($cmd); } - public function getListenerTestCases() + public static function getListenerTestCases() { return [ [ diff --git a/tests/S3/StreamWrapperPathStyleTest.php b/tests/S3/StreamWrapperPathStyleTest.php index b0a4e373dd..e647ebd55f 100644 --- a/tests/S3/StreamWrapperPathStyleTest.php +++ b/tests/S3/StreamWrapperPathStyleTest.php @@ -349,7 +349,7 @@ public function testCanDeleteBucketWithRmDir() $this->assertSame('s3.amazonaws.com', $entries[0]['request']->getUri()->getHost()); } - public function rmdirProvider() + public static function rmdirProvider() { return [ ['s3://bucket/object/'], @@ -579,7 +579,7 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, stat('s3://bucket/prefix'); } - public function fileTypeProvider() + public static function fileTypeProvider() { $err = function ($cmd, $r) { return new S3Exception('404', $cmd); }; diff --git a/tests/S3/StreamWrapperTest.php b/tests/S3/StreamWrapperTest.php index 88840c2c27..59027eb3c1 100644 --- a/tests/S3/StreamWrapperTest.php +++ b/tests/S3/StreamWrapperTest.php @@ -462,7 +462,7 @@ public function testCanDeleteBucketWithRmDir() $this->assertSame('bucket.s3.amazonaws.com', $entries[0]['request']->getUri()->getHost()); } - public function rmdirProvider() + public static function rmdirProvider() { return [ ['s3://bucket/object/'], @@ -717,7 +717,7 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, stat('s3://bucket/prefix'); } - public function fileTypeProvider() + public static function fileTypeProvider() { $err = function ($cmd, $r) { return new S3Exception('404', $cmd); }; @@ -1025,7 +1025,7 @@ public function testStatDataIsClearedOnWriteUsingCustomProtocol() stream_wrapper_unregister('foo'); } - public function contentProvider() + public static function contentProvider() { return [ ['foo'], diff --git a/tests/S3/StreamWrapperV2ExistenceTest.php b/tests/S3/StreamWrapperV2ExistenceTest.php index 2aef340996..f466680ea9 100644 --- a/tests/S3/StreamWrapperV2ExistenceTest.php +++ b/tests/S3/StreamWrapperV2ExistenceTest.php @@ -435,7 +435,7 @@ public function testCanDeleteBucketWithRmDir() $this->assertSame('bucket.s3.amazonaws.com', $entries[0]['request']->getUri()->getHost()); } - public function rmdirProvider() + public static function rmdirProvider() { return [ ['s3://bucket/object/'], @@ -682,7 +682,7 @@ function ($cmd, $r) { return new S3Exception( stat('s3://bucket/prefix'); } - public function fileTypeProvider() + public static function fileTypeProvider() { $err = function ($cmd, $r) { return new S3Exception( '404', diff --git a/tests/S3/TransferTest.php b/tests/S3/TransferTest.php index e957016afc..3171d1a9e4 100644 --- a/tests/S3/TransferTest.php +++ b/tests/S3/TransferTest.php @@ -409,7 +409,7 @@ public function testCannotDownloadObjectsOutsideTarget($key) $this->deleteDirectory($dir); } - public function providedPathsOutsideTarget() { + public static function providedPathsOutsideTarget() { return [ ['bar/../a/b'], //ensures if path resolves to target directory @@ -614,7 +614,7 @@ function (CommandInterface $cmd, RequestInterface $req) use ($checksumAlgorithm) $this->deleteDirectory($dir); } - public function flexibleChecksumsProvider() { + public static function flexibleChecksumsProvider() { return [ ['sha256'], ['sha1'], diff --git a/tests/S3/UseArnRegion/ConfigurationTest.php b/tests/S3/UseArnRegion/ConfigurationTest.php index 9f05028cee..4100da4e50 100644 --- a/tests/S3/UseArnRegion/ConfigurationTest.php +++ b/tests/S3/UseArnRegion/ConfigurationTest.php @@ -21,7 +21,7 @@ public function testGetsCorrectValues($param, $expected) $this->assertEquals($expected, $config->isUseArnRegion()); } - public function correctValueCases() + public static function correctValueCases() { return [ [true, true], diff --git a/tests/S3/ValidateResponseChecksumParserTest.php b/tests/S3/ValidateResponseChecksumParserTest.php index e987bbf51a..14d18fe69d 100644 --- a/tests/S3/ValidateResponseChecksumParserTest.php +++ b/tests/S3/ValidateResponseChecksumParserTest.php @@ -46,7 +46,7 @@ public function testValidatesChoosesRightChecksum( $this->assertEquals($expectedChecksum, $chosenChecksum); } - public function getChosenChecksumCases() + public static function getChosenChecksumCases() { return [ [['crc32', 'crc32c'], [], null], diff --git a/tests/S3Control/EndpointArnMiddlewareTest.php b/tests/S3Control/EndpointArnMiddlewareTest.php index 4b5bb26761..4c6f37fd62 100644 --- a/tests/S3Control/EndpointArnMiddlewareTest.php +++ b/tests/S3Control/EndpointArnMiddlewareTest.php @@ -71,7 +71,7 @@ public function testCorrectlyModifiesRequestAndCommand( $s3control->execute($command); } - public function providedSuccessCases() + public static function providedSuccessCases() { return [ // Outposts accesspoint ARN @@ -455,7 +455,7 @@ public function testCorrectlyThrowsForBadInputsOrConfig( } } - public function providedFailureCases() + public static function providedFailureCases() { return [ // Outposts accesspoint ARN, different region diff --git a/tests/Script/ComposerTest.php b/tests/Script/ComposerTest.php index 9dd8cf436e..cdd333b08c 100644 --- a/tests/Script/ComposerTest.php +++ b/tests/Script/ComposerTest.php @@ -9,7 +9,7 @@ class ComposerTest extends TestCase { - public function invalidServiceNameProvider() + public static function invalidServiceNameProvider() { return [ [['foo'], 'foo'], @@ -45,7 +45,7 @@ public function testNoListedServices() Composer::removeUnusedServices($this->getMockEvent([])); } - public function servicesToKeepProvider() + public static function servicesToKeepProvider() { return [ [['S3']], @@ -166,7 +166,7 @@ public function testRetriesOnException($success, $writeCalls) ); } - public function retryProvider() + public static function retryProvider() { return [ 'success' => [true , 3], diff --git a/tests/Signature/SignatureProviderTest.php b/tests/Signature/SignatureProviderTest.php index 5dc9c498b6..4811f949bc 100644 --- a/tests/Signature/SignatureProviderTest.php +++ b/tests/Signature/SignatureProviderTest.php @@ -15,7 +15,7 @@ */ class SignatureProviderTest extends TestCase { - public function versionProvider() + public static function versionProvider() { return [ ['v4', SignatureV4::class, 'foo'], diff --git a/tests/Signature/SignatureV4Test.php b/tests/Signature/SignatureV4Test.php index a101eb8619..950e15d67e 100644 --- a/tests/Signature/SignatureV4Test.php +++ b/tests/Signature/SignatureV4Test.php @@ -118,7 +118,7 @@ private function decodeQueryPairs(string $query): array return $pairs; } - public function getExpiresDateTimeInterfaceInputs() + public static function getExpiresDateTimeInterfaceInputs() { return [ [ @@ -181,7 +181,7 @@ public function testAddsSecurityTokenIfPresentInPresigned() $this->assertStringContainsString('X-Amz-Expires=518400', $url); } - public function getStartDateTimeInterfaceInputs() + public static function getStartDateTimeInterfaceInputs() { return [ [ @@ -393,7 +393,7 @@ public function testEnsuresContentSha256CanBeCalculatedWhenSeekFails() } /** @doesNotPerformAssertions */ - public function testUnsignedPayloadProvider() + public static function testUnsignedPayloadProvider() { return [ // POST headers should be signed. @@ -468,7 +468,7 @@ public function testSignRequestUnsignedPayload($req, $sreq, $creq) } /** @doesNotPerformAssertions */ - public function testProvider() + public static function testProvider() { return [ // POST headers should be signed. diff --git a/tests/StreamRequestPayloadMiddlewareTest.php b/tests/StreamRequestPayloadMiddlewareTest.php index ed0443505a..23fe07185c 100644 --- a/tests/StreamRequestPayloadMiddlewareTest.php +++ b/tests/StreamRequestPayloadMiddlewareTest.php @@ -54,7 +54,7 @@ public function testAddsProperHeaders( $handler($command, new Request('POST', 'https://foo.com')); } - public function generateTestCases() + public static function generateTestCases() { $service = $this->generateTestService(); $client = $this->generateTestClient($service); diff --git a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php index 0406271cc6..8c1d7f454d 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php @@ -352,7 +352,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData() { $expected = new Configuration('regional'); return [ diff --git a/tests/Sts/StsClientTest.php b/tests/Sts/StsClientTest.php index 04369a93e3..5aaae803cc 100644 --- a/tests/Sts/StsClientTest.php +++ b/tests/Sts/StsClientTest.php @@ -206,7 +206,7 @@ public function testStsAssumeRoleOperationsWithAccountId($response, $expected) self::assertSame($expected->toArray(), $response->toArray()); } - public function stsAssumeRoleOperationsDataProvider(): array + public static function stsAssumeRoleOperationsDataProvider(): array { return [ 'Sts::AssumeRole' => [ @@ -266,7 +266,7 @@ public function testStsAssumeRoleWithSAMLOperationsWithAccountId( self::assertSame($expected->toArray(), $response->toArray()); } - public function stsAssumeRoleWithSAMLOperationsDataProvider(): array + public static function stsAssumeRoleWithSAMLOperationsDataProvider(): array { return [ 'Sts::AssumeRoleWithSaml' => [ @@ -321,7 +321,7 @@ public function testStsAssumeRoleWithWebIdentityOperationsWithAccountId( self::assertSame($expected->toArray(), $response->toArray()); } - public function stsAssumeRoleWithWebIdentityOperationsDataProvider(): array + public static function stsAssumeRoleWithWebIdentityOperationsDataProvider(): array { return [ 'Sts::AssumeRoleWithWebIdentity' => [ @@ -379,7 +379,7 @@ public function testStsGetFederationTokenOperationsWithAccountId( self::assertSame($expected->toArray(), $response->toArray()); } - public function stsGetFederationTokenOperationsDataProvider(): array + public static function stsGetFederationTokenOperationsDataProvider(): array { return [ 'Sts::GetFederationToken' => [ diff --git a/tests/Token/BearerTokenAuthorizationTest.php b/tests/Token/BearerTokenAuthorizationTest.php index 9ee33c603f..f7bce113a9 100644 --- a/tests/Token/BearerTokenAuthorizationTest.php +++ b/tests/Token/BearerTokenAuthorizationTest.php @@ -10,7 +10,7 @@ */ class BearerTokenAuthorizationTest extends TestCase { - public function bearerTestProvider() { + public static function bearerTestProvider() { return [ "Minimal bearer auth case" => [ diff --git a/tests/Token/BedrockTokenProviderTest.php b/tests/Token/BedrockTokenProviderTest.php index d4dd36e757..9b7aa70988 100644 --- a/tests/Token/BedrockTokenProviderTest.php +++ b/tests/Token/BedrockTokenProviderTest.php @@ -315,7 +315,7 @@ public function testIntegrationWithClient( } } - public function integrationWithClientProvider(): \Generator + public static function integrationWithClientProvider(): \Generator { static $services = [ 'bedrock', @@ -440,7 +440,7 @@ function (callable $handler) { $client->{$operation}($args); } - public function tokenSourceUserAgentProvider(): \Generator + public static function tokenSourceUserAgentProvider(): \Generator { yield 'bedrock' => [ 'service' => 'bedrock', diff --git a/tests/Token/TokenProviderTest.php b/tests/Token/TokenProviderTest.php index 534b934b2d..08a57623d6 100644 --- a/tests/Token/TokenProviderTest.php +++ b/tests/Token/TokenProviderTest.php @@ -124,7 +124,7 @@ public function testCreatesFromCache() $this->assertEquals($token->getExpiration(), $found->getExpiration()); } - public function tokenProviderSuccessCases() { + public static function tokenProviderSuccessCases() { return [ "Valid token with all fields" => [ @@ -187,7 +187,7 @@ public function testTokenProviderCachedSuccess($cachedToken, $expectedToken) $this->assertEquals(strtotime($expectedToken['expiration']), $found->getExpiration()); } - public function tokenProviderSuccessCasesWithRefresh() { + public static function tokenProviderSuccessCasesWithRefresh() { return [ "Expired token refresh with refresh token" => [ @@ -350,7 +350,7 @@ public function testTokenProviderCachedSuccessWithRefresh( } } - public function tokenProviderFailureCases() { + public static function tokenProviderFailureCases() { return [ "Minimal expired cached token" => [ diff --git a/tests/TraceMiddlewareTest.php b/tests/TraceMiddlewareTest.php index 6fb5190bc6..be23c32685 100644 --- a/tests/TraceMiddlewareTest.php +++ b/tests/TraceMiddlewareTest.php @@ -239,7 +239,7 @@ public function testEmitsForMiddlewareThatDoesNotReturnRequest() $this->assertEquals('success', $result[0]); } - public function authStringProvider() + public static function authStringProvider() { return [ // v4 signature example from http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html diff --git a/tests/UserAgentMiddlewareTest.php b/tests/UserAgentMiddlewareTest.php index 0565e19a8f..ec1580d5c4 100644 --- a/tests/UserAgentMiddlewareTest.php +++ b/tests/UserAgentMiddlewareTest.php @@ -165,7 +165,7 @@ public function testUserAgentContainsValue(array $args, string $expected) * * @return \Generator */ - public function userAgentCasesDataProvider(): \Generator + public static function userAgentCasesDataProvider(): \Generator { yield 'sdkVersion' => [[], 'aws-sdk-php/' . Sdk::VERSION]; @@ -355,7 +355,7 @@ public function testUserAgentCaptureRetryConfigMetric( * * @return array[] */ - public function retryConfigMetricProvider(): array + public static function retryConfigMetricProvider(): array { return [ 'retryAdaptive' => [ @@ -874,7 +874,7 @@ public function testUserAgentCaptureFlexibleChecksumMetric( * * @return array[] */ - public function flexibleChecksumTestProvider(): array + public static function flexibleChecksumTestProvider(): array { return [ 'metric_checksum_crc32' => [ diff --git a/tests/WaiterTest.php b/tests/WaiterTest.php index b5c5dc3dca..8c960da971 100644 --- a/tests/WaiterTest.php +++ b/tests/WaiterTest.php @@ -178,7 +178,7 @@ public function testWaiterWorkflow($results, $expectedException) $this->assertEquals($expectedException, $actualException); } - public function getWaiterWorkflowTestCases() + public static function getWaiterWorkflowTestCases() { return [ [ @@ -275,7 +275,7 @@ public function testMatchers($matcher, $result, $acceptor, $expected) /** * @return array */ - public function getMatchersTestCases(): array + public static function getMatchersTestCases(): array { return [ 'matches_path_1' => [ diff --git a/tests/WrappedHttpHandlerTest.php b/tests/WrappedHttpHandlerTest.php index 9311b47ae6..7ebfa5e7f7 100644 --- a/tests/WrappedHttpHandlerTest.php +++ b/tests/WrappedHttpHandlerTest.php @@ -133,7 +133,7 @@ public function testCanRejectWithAndParseResponse( } } - public function responseAndParserProvider() + public static function responseAndParserProvider() { $services = [ 'ec2' => $this->generateTestService('ec2'), From ef91a515510ad7bc746ff156d057e354e1c0ee1b Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Sun, 25 Jan 2026 19:47:09 -0800 Subject: [PATCH 03/19] chore: enhance data providers Enhance data providers within test cases to avoid the usage of instance members since they become now static functions. --- .../ErrorParser/JsonRpcErrorParserTest.php | 67 +-- .../ErrorParser/RestJsonErrorParserTest.php | 80 +-- tests/Api/ErrorParser/XmlErrorParserTest.php | 76 ++- tests/Api/Parser/EventParsingIteratorTest.php | 43 +- tests/Auth/AuthSchemeResolverTest.php | 77 +-- tests/Auth/AuthSelectionMiddlewareTest.php | 30 +- tests/AwsClientTest.php | 92 ++-- .../Credentials/EcsCredentialProviderTest.php | 79 +-- .../InstanceProfileProviderTest.php | 504 +++++++++--------- tests/Endpoint/PartitionTest.php | 122 +++-- .../EndpointDiscoveryMiddlewareTest.php | 18 +- tests/EndpointParameterMiddlewareTest.php | 13 +- tests/EndpointV2/EndpointV2MiddlewareTest.php | 48 +- tests/MiddlewareTest.php | 172 ++++-- tests/S3/AmbiguousSuccessParserTest.php | 2 +- tests/S3/ObjectCopierTest.php | 34 +- tests/S3/ObjectUploaderTest.php | 44 +- tests/S3/S3ClientTest.php | 79 ++- tests/S3/S3EndpointMiddlewareTest.php | 291 +++++----- tests/S3/StreamWrapperV2ExistenceTest.php | 4 +- tests/StreamRequestPayloadMiddlewareTest.php | 48 +- tests/Token/TokenProviderTest.php | 9 +- tests/UserAgentMiddlewareTest.php | 8 +- tests/WaiterTest.php | 80 ++- tests/WrappedHttpHandlerTest.php | 196 ++++--- 25 files changed, 1199 insertions(+), 1017 deletions(-) diff --git a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php index babb688bf0..1125bc6d3a 100644 --- a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php +++ b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php @@ -2,10 +2,7 @@ namespace Aws\Test\Api\ErrorParser; use Aws\Api\ErrorParser\JsonRpcErrorParser; -use Aws\Api\ErrorParser\RestJsonErrorParser; -use Aws\Api\StructureShape; use Aws\Test\TestServiceTrait; -use GuzzleHttp\Promise\Promise; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; @@ -20,17 +17,37 @@ class JsonRpcErrorParserTest extends TestCase /** * @dataProvider errorResponsesProvider * - * @param $response - * @param $command - * @param $parser - * @param $expected + * @param string $response + * @param string|null $commandName + * @param bool $parserWithService + * @param array $expected */ public function testParsesClientErrorResponses( - $response, - $command, - $parser, - $expected + string $response, + ?string $commandName, + bool $parserWithService, + array $expected ) { + $service = $this->generateTestService('json'); + $awsQueryCompatibleService = $this->generateTestService( + 'json', + ['awsQueryCompatible' => true] + ); + $shapes = $service->getErrorShapes(); + $errorShape = $shapes[0]; + $client = $this->generateTestClient($service); + $command = $commandName === null + ? null + : $client->getCommand($commandName); + $parser = $parserWithService + ? new JsonRpcErrorParser($awsQueryCompatibleService) + : new JsonRpcErrorParser(); + + // If error shape required in the expected + if ($expected['error_shape'] ?? false) { + $expected['error_shape'] = $errorShape; + } + $response = Psr7\Message::parseResponse($response); $parsed = $parser($response, $command); $this->assertCount( @@ -49,18 +66,8 @@ public function testParsesClientErrorResponses( } } - public static function errorResponsesProvider() + public static function errorResponsesProvider(): array { - $service = $this->generateTestService('json'); - $awsQueryCompatibleService = $this->generateTestService( - 'json', - ['awsQueryCompatible' => true] - ); - $shapes = $service->getErrorShapes(); - $errorShape = $shapes[0]; - $client = $this->generateTestClient($service); - $command = $client->getCommand('TestOperation', []); - return [ // Non-modeled exception, mixed casing [ @@ -68,7 +75,7 @@ public static function errorResponsesProvider() "x-amzn-requestid: xyz\r\n\r\n" . '{ "__Type": "foo", "Message": "lorem ipsum" }', null, - new JsonRpcErrorParser(), + false, [ 'code' => 'foo', 'message' => 'lorem ipsum', @@ -89,8 +96,8 @@ public static function errorResponsesProvider() "x-meta-bar: bar-meta\r\n" . "x-amzn-requestid: xyz\r\n\r\n" . '{ "TestString": "foo", "TestInt": 123, "NotModeled": "bar", "__type": "TestException", "message": "Test Message" }', - $command, - new JsonRpcErrorParser($service), + 'TestOperation', + true, [ 'code' => 'TestException', 'type' => 'client', @@ -113,7 +120,7 @@ public static function errorResponsesProvider() 'TestStatus' => 400, ], 'message' => 'Test Message', - 'error_shape' => $errorShape + 'error_shape' => true ] ], // Unmodeled shape, with service @@ -125,7 +132,7 @@ public static function errorResponsesProvider() "x-amzn-requestid: xyz\r\n\r\n" . '{ "TestString": "foo", "TestInt": 123, "NotModeled": "bar", "__type": "NonExistentException", "message": "Test Message" }', null, - new JsonRpcErrorParser($service), + true, [ 'code' => 'NonExistentException', 'message' => 'Test Message', @@ -148,7 +155,7 @@ public static function errorResponsesProvider() "x-amzn-query-error: NonExistentException;Sender\r\n\r\n" . '{ "__Type": "foo", "Message": "lorem ipsum" }', null, - new JsonRpcErrorParser($awsQueryCompatibleService), + true, [ 'code' => 'NonExistentException', 'message' => 'lorem ipsum', @@ -168,7 +175,7 @@ public static function errorResponsesProvider() "x-amzn-query-error: ;Sender\r\n\r\n" . '{ "__Type": "foo", "Message": "lorem ipsum" }', null, - new JsonRpcErrorParser($awsQueryCompatibleService), + true, [ 'code' => 'foo', 'message' => 'lorem ipsum', @@ -188,7 +195,7 @@ public static function errorResponsesProvider() "x-amzn-query-error: \r\n\r\n" . '{ "__Type": "foo", "Message": "lorem ipsum" }', null, - new JsonRpcErrorParser(), + false, [ 'code' => 'foo', 'message' => 'lorem ipsum', diff --git a/tests/Api/ErrorParser/RestJsonErrorParserTest.php b/tests/Api/ErrorParser/RestJsonErrorParserTest.php index 62581ca963..85600c28a2 100644 --- a/tests/Api/ErrorParser/RestJsonErrorParserTest.php +++ b/tests/Api/ErrorParser/RestJsonErrorParserTest.php @@ -17,17 +17,33 @@ class RestJsonErrorParserTest extends TestCase /** * @dataProvider errorResponsesProvider * - * @param $response - * @param $command - * @param $parser - * @param $expected + * @param string $response + * @param string|null $commandName + * @param bool $parserWithService + * @param array $expected */ public function testParsesClientErrorResponses( - $response, - $command, - $parser, - $expected + string $response, + ?string $commandName, + bool $parserWithService, + array $expected ) { + $service = $this->generateTestService('rest-json'); + $shapes = $service->getErrorShapes(); + $errorShape = $shapes[0]; + $client = $this->generateTestClient($service); + $command = $commandName === null + ? null + : $client->getCommand($commandName); + $parser = $parserWithService + ? new RestJsonErrorParser($service) + : new RestJsonErrorParser(); + + // If error shape required in the expected + if ($expected['error_shape'] ?? false) { + $expected['error_shape'] = $errorShape; + } + $response = Psr7\Message::parseResponse($response); $parsed = $parser($response, $command); $this->assertCount( @@ -46,14 +62,8 @@ public function testParsesClientErrorResponses( } } - public static function errorResponsesProvider() + public static function errorResponsesProvider(): array { - $service = $this->generateTestService('rest-json'); - $shapes = $service->getErrorShapes(); - $errorShape = $shapes[0]; - $client = $this->generateTestClient($service); - $command = $client->getCommand('TestOperation', []); - return [ // Error code in body [ @@ -61,7 +71,7 @@ public static function errorResponsesProvider() "x-amzn-requestid: xyz\r\n\r\n" . '{ "type": "client", "message": "lorem ipsum", "code": "foo" }', null, - new RestJsonErrorParser(), + false, [ 'code' => 'foo', 'message' => 'lorem ipsum', @@ -82,7 +92,7 @@ public static function errorResponsesProvider() "x-amzn-ErrorType: foo:bar\r\n\r\n" . '{"message": "lorem ipsum"}', null, - new RestJsonErrorParser(), + false, [ 'code' => 'foo', 'message' => 'lorem ipsum', @@ -102,8 +112,8 @@ public static function errorResponsesProvider() "x-meta-bar: bar-meta\r\n" . "x-amzn-requestid: xyz\r\n\r\n" . '{ "TestString": "foo", "TestInt": 123, "NotModeled": "bar", "code": "TestException" }', - $command, - new RestJsonErrorParser($service), + 'TestOperation', + true, [ 'code' => 'TestException', 'type' => 'client', @@ -128,7 +138,7 @@ public static function errorResponsesProvider() 'TestStatus' => 400, ], 'message' => null, - 'error_shape' => $errorShape + 'error_shape' => true ] ], // Error code in header, with service, modeled exception @@ -140,8 +150,8 @@ public static function errorResponsesProvider() "x-amzn-ErrorType: TestException\r\n" . "x-amzn-requestid: xyz\r\n\r\n" . '{ "TestString": "foo", "TestInt": 123, "NotModeled": "bar"}', - $command, - new RestJsonErrorParser($service), + 'TestOperation', + true, [ 'code' => 'TestException', 'type' => 'client', @@ -165,7 +175,7 @@ public static function errorResponsesProvider() 'TestStatus' => 400, ], 'message' => null, - 'error_shape' => $errorShape + 'error_shape' => true ] ], // Error code in header, with service, unmodeled code @@ -175,7 +185,7 @@ public static function errorResponsesProvider() "x-amzn-ErrorType: NonExistentException\r\n\r\n" . '{"message": "lorem ipsum"}', null, - new RestJsonErrorParser($service), + true, [ 'code' => 'NonExistentException', 'message' => 'lorem ipsum', @@ -193,7 +203,7 @@ public static function errorResponsesProvider() "x-amzn-requestid: xyz\r\n\r\n" . '{ "type": "client", "message": "lorem ipsum", "code": "NonExistentException" }', null, - new RestJsonErrorParser($service), + true, [ 'code' => 'NonExistentException', 'message' => 'lorem ipsum', @@ -213,7 +223,7 @@ public static function errorResponsesProvider() "x-amzn-requestid: xyz\r\n\r\n" . '{ "type": "client", "Message": "lorem ipsum", "code": "NonExistentException" }', null, - new RestJsonErrorParser($service), + true, [ 'code' => 'NonExistentException', 'message' => 'lorem ipsum', @@ -234,8 +244,8 @@ public static function errorResponsesProvider() "TestHeader: 0\r\n" . "x-amzn-requestid: xyz\r\n\r\n" . '{ "code": "TestException" }', - $command, - new RestJsonErrorParser($service), + 'TestOperation', + true, [ 'code' => 'TestException', 'type' => 'client', @@ -247,7 +257,7 @@ public static function errorResponsesProvider() 'TestStatus' => 400, ], 'message' => null, - 'error_shape' => $errorShape + 'error_shape' => true ] ], // Test false value in header @@ -256,8 +266,8 @@ public static function errorResponsesProvider() "TestHeader: false\r\n" . "x-amzn-requestid: xyz\r\n\r\n" . '{ "code": "TestException" }', - $command, - new RestJsonErrorParser($service), + 'TestOperation', + true, [ 'code' => 'TestException', 'type' => 'client', @@ -269,7 +279,7 @@ public static function errorResponsesProvider() 'TestStatus' => 400, ], 'message' => null, - 'error_shape' => $errorShape + 'error_shape' => true ] ], // Test empty string in header (should be skipped) @@ -278,8 +288,8 @@ public static function errorResponsesProvider() "TestHeader: \r\n" . "x-amzn-requestid: xyz\r\n\r\n" . '{ "code": "TestException" }', - $command, - new RestJsonErrorParser($service), + 'TestOperation', + true, [ 'code' => 'TestException', 'type' => 'client', @@ -291,7 +301,7 @@ public static function errorResponsesProvider() 'TestStatus' => 400, ], 'message' => null, - 'error_shape' => $errorShape + 'error_shape' => true ] ] ]; diff --git a/tests/Api/ErrorParser/XmlErrorParserTest.php b/tests/Api/ErrorParser/XmlErrorParserTest.php index 207dd5498d..a5c7b33a08 100644 --- a/tests/Api/ErrorParser/XmlErrorParserTest.php +++ b/tests/Api/ErrorParser/XmlErrorParserTest.php @@ -18,18 +18,26 @@ class XmlErrorParserTest extends TestCase /** * @dataProvider errorResponsesProvider * - * @param $response - * @param $command - * @param $parser - * @param $expected + * @param string $response + * @param string $protocol + * @param string $parser + * @param array $expected + * @param string|null $expectedParsedType + * + * @throws \Exception */ public function testParsesClientErrorResponses( - $response, - $command, - $parser, - $expected, - $expectedParsedType + string $response, + string $protocol, + string $parser, + array $expected, + ?string $expectedParsedType ) { + $service = $this->generateTestService($protocol); + $client = $this->generateTestClient($service); + $command = $client->getCommand('TestOperation'); + $parser = new $parser($service); + $response = Psr7\Message::parseResponse($response); $result = $parser($response, $command); $this->assertArraySubset($expected, $result); @@ -41,20 +49,8 @@ public function testParsesClientErrorResponses( } } - public static function errorResponsesProvider() + public static function errorResponsesProvider(): array { - $ec2Service = $this->generateTestService('ec2'); - $ec2Client = $this->generateTestClient($ec2Service); - $ec2Command = $ec2Client->getCommand('TestOperation', []); - - $queryService = $this->generateTestService('query'); - $queryClient = $this->generateTestClient($queryService); - $queryCommand = $queryClient->getCommand('TestOperation', []); - - $restXmlService = $this->generateTestService('query'); - $restXmlClient = $this->generateTestClient($restXmlService); - $restXmlCommand = $restXmlClient->getCommand('TestOperation', []); - return [ // ec2, modeled exception [ @@ -75,8 +71,8 @@ public static function errorResponsesProvider() ' ' . ' xyz' . '', - $ec2Command, - new XmlErrorParser($ec2Service), + 'ec2', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -114,8 +110,8 @@ public static function errorResponsesProvider() ' ' . ' xyz' . '', - $ec2Command, - new XmlErrorParser($ec2Service), + 'ec2', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -141,8 +137,8 @@ public static function errorResponsesProvider() ' ' . ' xyz' . '', - $queryCommand, - new XmlErrorParser($queryService), + 'query', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -178,8 +174,8 @@ public static function errorResponsesProvider() ' ' . ' xyz' . '', - $queryCommand, - new XmlErrorParser($queryService), + 'query', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -205,8 +201,8 @@ public static function errorResponsesProvider() ' ' . ' xyz' . '', - $restXmlCommand, - new XmlErrorParser($restXmlService), + 'query', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -242,8 +238,8 @@ public static function errorResponsesProvider() ' ' . ' xyz' . '', - $restXmlCommand, - new XmlErrorParser($restXmlService), + 'query', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -268,8 +264,8 @@ public static function errorResponsesProvider() ' 456' . ' baz' . '', - $restXmlCommand, - new XmlErrorParser($restXmlService), + 'query', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -304,8 +300,8 @@ public static function errorResponsesProvider() ' 456' . ' baz' . '', - $restXmlCommand, - new XmlErrorParser($restXmlService), + 'query', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', @@ -321,8 +317,8 @@ public static function errorResponsesProvider() "x-meta-foo: foo-meta\r\n" . "x-meta-bar: bar-meta\r\n" . "x-amz-request-id: xyz\r\n\r\n", - $restXmlCommand, - new XmlErrorParser($restXmlService), + 'query', + XmlErrorParser::class, [ 'type' => 'client', 'request_id' => 'xyz', diff --git a/tests/Api/Parser/EventParsingIteratorTest.php b/tests/Api/Parser/EventParsingIteratorTest.php index 2f7398c9f3..a2400c1876 100644 --- a/tests/Api/Parser/EventParsingIteratorTest.php +++ b/tests/Api/Parser/EventParsingIteratorTest.php @@ -70,8 +70,8 @@ class EventParsingIteratorTest extends TestCase public static function iteratorDataProvider() { foreach (self::$eventCases as $eventCase) { - $shape = $this->loadEventStreamShapeFromJson($eventCase['shape']); - $restParser = $this->createRestParser($eventCase['protocol']); + $shape = self::loadEventStreamShapeFromJson($eventCase['shape']); + $restParser = self::createRestParser($eventCase['protocol']); foreach ($eventCase['eventNames'] as $eventName) { $input = base64_decode(file_get_contents( __DIR__ . '/../eventstream_fixtures/input/' . $eventName @@ -197,7 +197,7 @@ public function testThrowsOnErrorEvent() __DIR__ . '/../eventstream_fixtures/input/error_event' )) ); - $shape = $this->loadEventStreamShapeFromJson(self::EVENT_STREAM_SHAPE); + $shape = self::loadEventStreamShapeFromJson(self::EVENT_STREAM_SHAPE); $iterator = new EventParsingIterator( $stream, $shape, @@ -226,7 +226,7 @@ public function testThrowsOnUnknownMessageType() { $this->expectExceptionMessage("Failed to parse unknown message type."); $this->expectException(\Aws\Api\Parser\Exception\ParserException::class); - $shape = $this->loadEventStreamShapeFromJson(self::EVENT_STREAM_SHAPE); + $shape = self::loadEventStreamShapeFromJson(self::EVENT_STREAM_SHAPE); $stream = Psr7\Utils::streamFor( base64_decode(file_get_contents( __DIR__ . '/../eventstream_fixtures/input/unknown_message_type' @@ -251,7 +251,7 @@ public function testThrowsOnUnknownEventType() { $this->expectExceptionMessage("Failed to parse without event type."); $this->expectException(\Aws\Api\Parser\Exception\ParserException::class); - $shape = $this->loadEventStreamShapeFromJson(self::EVENT_STREAM_SHAPE); + $shape = self::loadEventStreamShapeFromJson(self::EVENT_STREAM_SHAPE); $stream = Psr7\Utils::streamFor( base64_decode(file_get_contents( __DIR__ . '/../eventstream_fixtures/input/unknown_event_type' @@ -277,7 +277,7 @@ public function testThrowsOnUnknownEventType() * * @return StructureShape */ - private function loadEventStreamShapeFromJson($jsonFilePath) + private static function loadEventStreamShapeFromJson($jsonFilePath): StructureShape { $shape = json_decode( file_get_contents($jsonFilePath), @@ -293,22 +293,21 @@ private function loadEventStreamShapeFromJson($jsonFilePath) /** * This method creates an instance of a RestParser class based on the protocol provided. * + * @param $protocol + * * @return AbstractRestParser */ - private function createRestParser($protocol) + private static function createRestParser($protocol): AbstractRestParser { - switch ($protocol) { - case self::PROTOCOL_XML: - return new RestXmlParser(new Service([], function () { - return []; - })); - case self::PROTOCOL_JSON: - return new RestJsonParser(new Service([], function () { - return []; - })); - default: - throw new ParserException('Unknown parser protocol "' . $protocol . '"'); - } + return match ($protocol) { + self::PROTOCOL_XML => new RestXmlParser(new Service([], function () { + return []; + })), + self::PROTOCOL_JSON => new RestJsonParser(new Service([], function () { + return []; + })), + default => throw new ParserException('Unknown parser protocol "' . $protocol . '"'), + }; } public function testCanHandleNonSeekableStream() @@ -345,7 +344,7 @@ public function testCanHandleNonSeekableStream() $eventParsingIterator = new EventParsingIterator( $noSeekableStream, $structureShape, - $this->createRestParser(self::PROTOCOL_JSON) + self::createRestParser(self::PROTOCOL_JSON) ); $expected = [ 'person' => [ @@ -366,7 +365,7 @@ public function testHandleInitialResponse() EOF; $stream = Psr7\Utils::streamFor(base64_decode($event)); $structureShape = new StructureShape([], new ShapeMap([])); - $iterator = new EventParsingIterator($stream, $structureShape, $this->createRestParser(self::PROTOCOL_JSON)); + $iterator = new EventParsingIterator($stream, $structureShape, self::createRestParser(self::PROTOCOL_JSON)); $this->assertEquals(['initial-response' => []], $iterator->current()); } @@ -404,7 +403,7 @@ public function testHandleEventWithExceptions( $iterator = new EventParsingIterator( $stream, $structureShape, - $this->createRestParser(self::PROTOCOL_JSON) + self::createRestParser(self::PROTOCOL_JSON) ); foreach ($iterator as $_) {} } diff --git a/tests/Auth/AuthSchemeResolverTest.php b/tests/Auth/AuthSchemeResolverTest.php index 4ae58ce68a..db3f114b12 100644 --- a/tests/Auth/AuthSchemeResolverTest.php +++ b/tests/Auth/AuthSchemeResolverTest.php @@ -193,12 +193,22 @@ public function testUnmetV4aRequirementsThrows() * @dataProvider fallsBackWhenIdentityNotAvailableProvider */ public function testFallsBackWhenIdentityNotAvailable( - $credentialProvider, - $tokenProvider, - $authSchemes, - $expected + string $credentialIdentityClass, + string $tokenIdentityClass, + array $authSchemes, + string $expected ) { + $credentialProvider = function () use ($credentialIdentityClass) { + return Promise\Create::promiseFor( + $this->createMock($credentialIdentityClass) + ); + }; + $tokenProvider = function () use ($tokenIdentityClass) { + return Promise\Create::promiseFor( + $this->createMock($tokenIdentityClass) + ); + }; if ($expected === 'error') { $this->expectException(UnresolvedAuthSchemeException::class); } @@ -206,35 +216,42 @@ public function testFallsBackWhenIdentityNotAvailable( $this->assertEquals($expected, $resolver->selectAuthScheme($authSchemes)); } - public static function fallsBackWhenIdentityNotAvailableProvider() + public static function fallsBackWhenIdentityNotAvailableProvider(): array { - $credentialProvider = function () { - return Promise\Create::promiseFor( - $this->createMock(AwsCredentialIdentity::class) - ); - }; - $tokenProvider = function () { - return Promise\Create::promiseFor( - $this->createMock(BearerTokenIdentity::class) - ); - }; - $badCredentialProvider = function () { - return Promise\Create::promiseFor( - $this->createMock(BearerTokenIdentity::class) - ); - }; - $badTokenProvider = function () { - return Promise\Create::promiseFor( - $this->createMock(AwsCredentialIdentity::class) - ); - }; + $credentialIdentity = AwsCredentialIdentity::class; + $tokenIdentity = BearerTokenIdentity::class; return [ - [$credentialProvider, $tokenProvider, ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], 'v4'], - [$badCredentialProvider, $tokenProvider, ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], 'bearer'], - [$credentialProvider, $badTokenProvider, ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], 'v4'], - [$badCredentialProvider, $badTokenProvider, ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], 'error'], - [$badCredentialProvider, $tokenProvider, ['aws.auth#sigv4'], 'error'] + 'credential_provider' => [ + 'credential_identity' => $credentialIdentity, + 'token_identity' => $tokenIdentity, + 'auth_schemes' => ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], + 'resolved_auth_scheme' => 'v4' + ], + 'bad_credential_provider' => [ + 'credential_identity' => $tokenIdentity, + 'token_identity' => $tokenIdentity, + 'auth_schemes' => ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], + 'resolved_auth_scheme' => 'bearer' + ], + 'bad_token_provider' => [ + 'credential_identity' => $credentialIdentity, + 'token_identity' => $credentialIdentity, + 'auth_schemes' => ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], + 'resolved_auth_scheme' => 'v4' + ], + 'bad_credential_provider_2' => [ + 'credential_identity' => $tokenIdentity, + 'token_identity' => $credentialIdentity, + 'auth_schemes' => ['aws.auth#sigv4', 'smithy.api#httpBearerAuth'], + 'resolved_auth_scheme' => 'error' + ], + 'bad_credential_provider_3' => [ + 'credential_identity' => $tokenIdentity, + 'token_identity' => $tokenIdentity, + 'auth_schemes' => ['aws.auth#sigv4'], + 'resolved_auth_scheme' => 'error' + ] ]; } } diff --git a/tests/Auth/AuthSelectionMiddlewareTest.php b/tests/Auth/AuthSelectionMiddlewareTest.php index 5dfb40fe7f..4c22934231 100644 --- a/tests/Auth/AuthSelectionMiddlewareTest.php +++ b/tests/Auth/AuthSelectionMiddlewareTest.php @@ -170,9 +170,17 @@ public static function ResolvesAuthSchemeWithCRTprovider() public function testResolvesBearerAuthScheme( $serviceAuth, $operationAuth, - $tokenProvider, + $identity, $expected ){ + // Normalize token provider + $tokenProvider = $identity === null + ? null + : function () use ($identity) { + return Promise\Create::promiseFor( + $this->createMock($identity) + ); + }; $nextHandler = function (CommandInterface $command) use ($expected) { $this->assertEquals($expected, $command['@context']['signature_version']); }; @@ -198,37 +206,25 @@ public function testResolvesBearerAuthScheme( $middleware($command); } - public static function resolvesBearerAuthSchemeProvider() + public static function resolvesBearerAuthSchemeProvider(): array { return [ [ ['smithy.api#httpBearerAuth', 'aws.auth#sigv4'], [], - function () { - return Promise\Create::promiseFor( - $this->createMock(BearerTokenIdentity::class) - ); - }, + BearerTokenIdentity::class, 'bearer' ], [ ['smithy.api#httpBearerAuth', 'aws.auth#sigv4'], [], - function () { - return Promise\Create::promiseFor( - null - ); - }, + null, 'v4' ], [ ['aws.auth#sigv4', 'aws.auth#sigv4a'], ['smithy.api#httpBearerAuth'], - function () { - return Promise\Create::promiseFor( - $this->createMock(BearerTokenIdentity::class) - ); - }, + BearerTokenIdentity::class, 'bearer' ] ]; diff --git a/tests/AwsClientTest.php b/tests/AwsClientTest.php index e6ef92f48c..54708b7de2 100644 --- a/tests/AwsClientTest.php +++ b/tests/AwsClientTest.php @@ -354,22 +354,47 @@ public function testDoesNotSignOperationsWithAnAuthTypeOfNone() } /** - * @param $service - * @param $clientConfig + * @param array $serviceDefinition + * @param array $clientArguments + * @param array $expectedHeaders + * @param array $expectedHeaderValues * * @dataProvider signOperationsWithAnAuthTypeProvider */ - public function testSignOperationsWithAnAuthType($service, $clientConfig) - { - $client = $this->createHttpsEndpointClient($service, $clientConfig); + public function testSignOperationsWithAnAuthType( + array $serviceDefinition, + array $clientArguments, + array $expectedHeaders, + array $expectedHeaderValues + ) + { + $clientArguments += [ + 'handler' => function(CommandInterface $command, + RequestInterface $request) + use ($expectedHeaders, $expectedHeaderValues) { + foreach ($expectedHeaders as $header) { + $this->assertTrue($request->hasHeader($header)); + } + + foreach ($expectedHeaderValues as $headerValue) { + $this->assertEquals( + $headerValue['value'], + $request->getHeaderLine($headerValue['header']) + ); + } + + return new Result(); + } + ]; + $client = $this->createHttpsEndpointClient($serviceDefinition, $clientArguments); $client->bar(); } - public static function signOperationsWithAnAuthTypeProvider() + public static function signOperationsWithAnAuthTypeProvider(): array { return [ - [ - [ + 'unsigned_payload' => [ + 'service_definition' => [ 'metadata' => [ 'signatureVersion' => 'v4', ], @@ -380,21 +405,14 @@ public static function signOperationsWithAnAuthTypeProvider() ], ], ], - [ - 'handler' => function ( - CommandInterface $command, - RequestInterface $request - ) { - foreach (['Authorization','X-Amz-Content-Sha256', 'X-Amz-Date'] as $signatureHeader) { - $this->assertTrue($request->hasHeader($signatureHeader)); - } - $this->assertSame('UNSIGNED-PAYLOAD', $request->getHeader('X-Amz-Content-Sha256')[0]); - return new Result; - } + 'client_arguments' => [], + 'expected_headers' => ['Authorization','X-Amz-Content-Sha256', 'X-Amz-Date'], + 'expected_header_values' => [ + ['header' => 'X-Amz-Content-Sha256', 'value' => 'UNSIGNED-PAYLOAD'] ] ], - [ - [ + 'bearer_token' => [ + 'service_definition' => [ 'metadata' => [ 'signatureVersion' => 'v4', ], @@ -405,17 +423,12 @@ public static function signOperationsWithAnAuthTypeProvider() ], ], ], - [ - 'handler' => function ( - CommandInterface $command, - RequestInterface $request - ) { - - $this->assertTrue($request->hasHeader('Authorization')); - $this->assertSame('Bearer foo', $request->getHeader('Authorization')[0]); - return new Result; - }, + 'client_arguments' => [ 'token' => new Token('foo', time() + 1000) + ], + 'expected_headers' => ['Authorization'], + 'expected_header_values' => [ + ['header' => 'Authorization', 'value' => 'Bearer foo'] ] ] ]; @@ -774,23 +787,6 @@ public function testAppliesConfiguredSignatureVersionViaClientConfig() { $client->foo(); } - - /** - * @return void - */ - public function testCallingEmitDeprecationWarningEmitsDeprecationWarning() - { - set_error_handler(function ($err, $message) { - throw new \RuntimeException($message); - }); - $this->expectException(\RuntimeException::class); - $this->expectExceptionMessage( - "This method is deprecated. It will be removed in an upcoming release." - ); - $client = $this->createClient(); - $client::emitDeprecationWarning(); - } - /** * @dataProvider signingRegionSetProvider * @runInSeparateProcess diff --git a/tests/Credentials/EcsCredentialProviderTest.php b/tests/Credentials/EcsCredentialProviderTest.php index f2697d4ca6..e65b8aee75 100644 --- a/tests/Credentials/EcsCredentialProviderTest.php +++ b/tests/Credentials/EcsCredentialProviderTest.php @@ -85,7 +85,7 @@ public function testThrowsExceptionOnInvalidEcsCredential() $this->expectExceptionMessage("Unexpected container metadata credentials value"); $this->expectException(\Aws\Exception\CredentialsException::class); $this->getTestCreds( - $this->getCredentialArray(null, null, null, null, false) + self::getCredentialArray(null, null, null, null, false) )->wait(); } @@ -93,7 +93,7 @@ public function testLoadsCredentialsAndProfile() { $t = time() + 1000; $c = $this->getTestCreds( - $this->getCredentialArray('foo', 'baz', null, "@{$t}") + self::getCredentialArray('foo', 'baz', null, "@{$t}") )->wait(); $this->assertSame('foo', $c->getAccessKeyId()); $this->assertSame('baz', $c->getSecretKey()); @@ -180,7 +180,7 @@ public function testUriAndTokenResolution($case) } $t = time() + 1000; - $creds = $this->getCredentialArray( + $creds = self::getCredentialArray( 'foo', 'baz', 'bar', $t, true ); $c = $this->resolveCredentials($creds)->wait(); @@ -205,7 +205,7 @@ public static function uriAndTokenResolutionProvider(): \Generator } } - private function getCredentialArray( + private static function getCredentialArray( $key, $secret, $token = null, $time = null, $success = true ){ return [ @@ -261,8 +261,8 @@ private function resolveCredentials($result, ?Response $more = null) private function getProxyCheckGuzzleClient() { $t = (time() + 1000); - $credentials = $this->getCredentialArray('foo', 'baz', null, "@{$t}"); - return new \Aws\Handler\Guzzle\GuzzleHandler( + $credentials = self::getCredentialArray('foo', 'baz', null, "@{$t}"); + return new GuzzleHandler( new Client([ 'handler' => function ( Psr7\Request $request, @@ -364,17 +364,21 @@ public function testResolveCredentialsWithAccountIdFromArn() } /** - * @dataProvider successTestCases + * @dataProvider successDataProvider * - * @param callable $client + * @param array $clientDef * @param CredentialsInterface $expected + * @throws GuzzleException */ public function testHandlesSuccessScenarios( - callable $client, + array $clientDef, CredentialsInterface $expected ) { $provider = new EcsCredentialProvider([ - 'client' => $client, + 'client' => $this->getTestClient( + $clientDef['responses'], + $clientDef['credentials'] + ), 'retries' => 5 ]); @@ -398,7 +402,7 @@ public function testHandlesSuccessScenarios( ); } - public static function successTestCases() + public static function successDataProvider(): array { $expiry = time() + 1000; $creds = ['foo_key', 'baz_secret', 'qux_token', "@{$expiry}"]; @@ -415,7 +419,7 @@ public static function successTestCases() $promiseCreds = Promise\Create::promiseFor( new Response(200, [], Psr7\Utils::streamFor( json_encode(call_user_func_array( - [$this, 'getCredentialArray'], + [__CLASS__, 'getCredentialArray'], $creds ))) ) @@ -423,42 +427,51 @@ public static function successTestCases() return [ 'Happy path' => [ - $this->getTestClient([], $creds), + [ + 'responses' => [], + 'credentials' => $creds + ], $credsObject ], 'With retries for ConnectException (Guzzle 7)' => [ - $this->getTestClient( - [ + [ + 'responses' => [ $rejectionConnection, $promiseCreds ], - $creds - ), + 'credentials' => $creds + ], $credsObject ], 'With 4 retries for ConnectException (Guzzle 7)' => [ - $this->getTestClient( - [ + [ + 'responses' => [ $rejectionConnection, $rejectionConnection, $rejectionConnection, $promiseCreds ], - $creds - ), + 'credentials' => $creds + ], $credsObject ], ]; } /** - * @dataProvider failureTestCases + * @dataProvider failureDataProvider * * @param $client * @param \Exception $expected + * + * @throws GuzzleException */ - public function testHandlesFailureScenarios($client, \Exception $expected) + public function testHandlesFailureScenarios( + array $responses, + \Exception $expected + ) { + $client = $this->getTestClient($responses); $provider = new EcsCredentialProvider([ 'client' => $client, 'retries' => 1, @@ -473,7 +486,7 @@ public function testHandlesFailureScenarios($client, \Exception $expected) } } - public static function failureTestCases() + public static function failureDataProvider(): array { $getRequest = new Psr7\Request('GET', '/latest'); @@ -494,22 +507,18 @@ public static function failureTestCases() return [ 'Non-retryable error' => [ - $this->getTestClient( - [ - $rejectionCreds, - ] - ), + [ + $rejectionCreds, + ], new CredentialsException( 'Error retrieving credentials from container metadata after attempt 0/1 (401 Unathorized)' ) ], 'Retryable error' => [ - $this->getTestClient( - [ - $rejectionConnection, - $rejectionConnection, - ] - ), + [ + $rejectionConnection, + $rejectionConnection, + ], new CredentialsException( 'Error retrieving credentials from container metadata after attempt 1/1 (cURL error 28: Connection timed out after 1000 milliseconds)' ) diff --git a/tests/Credentials/InstanceProfileProviderTest.php b/tests/Credentials/InstanceProfileProviderTest.php index 6758a71362..fff0796620 100644 --- a/tests/Credentials/InstanceProfileProviderTest.php +++ b/tests/Credentials/InstanceProfileProviderTest.php @@ -74,7 +74,7 @@ protected function tearDown(): void $this->tempFiles = []; } - private function getCredentialArray( + private static function getCredentialArray( $key, $secret, $token = null, @@ -90,17 +90,17 @@ private function getCredentialArray( ]; } - private function getRequestClass() + private static function getRequestClass(): string { return "\GuzzleHttp\Psr7\Request"; } - private function getResponseClass() + private static function getResponseClass(): string { return "\GuzzleHttp\Psr7\Response"; } - private function getRequestException() + private static function getRequestException(): RequestException { return new RequestException('test', new Psr7\Request('GET', 'http://www.example.com')); } @@ -114,7 +114,7 @@ private function getRequestException() * @param bool $throwConnectException * @return \Closure */ - private function getSecureTestClient( + private static function getSecureTestClient( $responses = [], $profile = 'MockProfile', $creds = ['foo_key', 'baz_secret', 'qux_token', null], @@ -195,7 +195,7 @@ private function getSecureTestClient( [], Psr7\Utils::streamFor( json_encode(call_user_func_array( - [$this, 'getCredentialArray'], + [__CLASS__, 'getCredentialArray'], array_values($creds) )) ) @@ -222,14 +222,14 @@ private function getSecureTestClient( * @param bool $throwConnectException * @return \Closure */ - private function getInsecureTestClient( + private static function getInsecureTestClient( $responses = [], $profile = 'MockProfile', $creds = ['foo_key', 'baz_secret', 'qux_token', null], $throwConnectException = false ) { - $requestClass = $this->getRequestClass(); - $responseClass = $this->getResponseClass(); + $requestClass = self::getRequestClass(); + $responseClass = self::getResponseClass(); $getProfileRequests = 0; $getCredsRequests = 0; @@ -292,13 +292,12 @@ private function getInsecureTestClient( [], Psr7\Utils::streamFor( json_encode(call_user_func_array( - [$this, 'getCredentialArray'], + [__CLASS__, 'getCredentialArray'], $creds )) ) ) ); - break; } } @@ -311,16 +310,32 @@ private function getInsecureTestClient( } /** - * @dataProvider successTestCases + * @dataProvider successDataProvider * - * @param $client - * @param $expected + * @param array $clientDefinition + * @param CredentialsInterface $expected + * @param int|null $expectedAttempts */ public function testHandlesSuccessScenarios( - callable $client, + array $clientDefinition, CredentialsInterface $expected, - $expectedAttempts = null + ?int $expectedAttempts ) { + $clientParameters = [ + $clientDefinition['responses'], + 'MockProfile', + $clientDefinition['credentials'] + ?? ['foo_key', 'baz_secret', 'qux_token', null], + $clientDefinition['throw_on_connect_exception'] ?? false, + + ]; + + if ($clientDefinition['secure']) { + $client = self::getSecureTestClient(...$clientParameters); + } else { + $client = self::getInsecureTestClient(...$clientParameters); + } + $provider = new InstanceProfileProvider([ 'client' => $client, 'retries' => 5 @@ -349,14 +364,14 @@ public function testHandlesSuccessScenarios( } } - public static function successTestCases() + public static function successDataProvider(): \Generator { $expiry = time() + 1000; $creds = ['foo_key', 'baz_secret', 'qux_token', "@{$expiry}"]; $credsObject = new Credentials($creds[0], $creds[1], $creds[2], $expiry); - $requestClass = $this->getRequestClass(); - $responseClass = $this->getResponseClass(); + $requestClass = self::getRequestClass(); + $responseClass = self::getResponseClass(); $getRequest = new $requestClass('GET', '/latest/meta-data/foo'); $putRequest = new $requestClass('PUT', '/latest/meta-data/foo'); $throttledResponse = new $responseClass(503); @@ -378,7 +393,7 @@ public static function successTestCases() $promiseCreds = Promise\Create::promiseFor( new Response(200, [], Psr7\Utils::streamFor( json_encode(call_user_func_array( - [$this, 'getCredentialArray'], + [__CLASS__, 'getCredentialArray'], $creds ))) ) @@ -394,23 +409,28 @@ public static function successTestCases() 'exception' => $getThrottleException ]); - return [ - // Secure data flow, happy path - [ - $this->getSecureTestClient([], 'MockProfile', $creds), - $credsObject + $cases = [ + 'secure_data_flow_happy_path' => [ + 'client_definition' => [ + 'responses' => [], + 'credentials' => $creds, + 'secure' => true, + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => null ], - - // Insecure data flow, happy path - [ - $this->getInsecureTestClient([], 'MockProfile', $creds), - $credsObject + 'insecure_data_flow_happy_path' => [ + 'client_definition' => [ + 'responses' => [], + 'credentials' => $creds, + 'secure' => false, + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => null ], - - // Secure data flow, with retries for request exception - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_with_retries_for_request_exception' => [ + 'client_definition' => [ + 'responses' => [ 'put' => [ Promise\Create::rejectionFor([ 'exception' => $putThrottleException @@ -428,17 +448,15 @@ public static function successTestCases() $promiseCreds ], ], - 'MockProfile', - $creds - ), - $credsObject, - 6 + 'secure' => true, + 'credentials' => $creds + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => 6 ], - - // Insecure data flow, with retries for request exception - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_with_retries_for_request_exception' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [ $rejectionThrottleProfile, $promiseProfile @@ -448,49 +466,43 @@ public static function successTestCases() $promiseCreds ], ], - 'MockProfile', - $creds - ), - $credsObject, - 5 + 'secure' => false, + 'credentials' => $creds + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => 5 ], - - // Secure data flow, with retries for json exception - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_with_retries_for_json_exception' => [ + 'client_definition' => [ + 'responses' => [ 'get_creds' => [ $promiseBadJsonCreds, $promiseCreds ], ], - 'MockProfile', - $creds - ), - $credsObject, - 4 + 'secure' => true, + 'credentials' => $creds + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => 4 ], - - // Insecure data flow, with retries for json exception - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_with_retries_for_json_exception' => [ + 'client_definition' => [ + 'responses' => [ 'get_creds' => [ $promiseBadJsonCreds, $promiseCreds ], ], - 'MockProfile', - $creds - ), - $credsObject, - 4 + 'secure' => false, + 'credentials' => $creds + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => 4 ], - - // Secure data flow, with retries for ConnectException (Guzzle 7) - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_with_retries_for_connect_exception' => [ + 'client_definition' => [ + 'responses' => [ 'put' => [ Promise\Create::rejectionFor([ 'exception' => $putThrottleException @@ -508,18 +520,16 @@ public static function successTestCases() $promiseCreds ], ], - 'MockProfile', - $creds, - true - ), - $credsObject, - 6 + 'secure' => true, + 'credentials' => $creds, + 'throw_on_connect_exception' => true + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => 6 ], - - // Insecure data flow, with retries for ConnectException (Guzzle 7) - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_with_retries_for_connect_exception' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [ $rejectionThrottleProfile, $promiseProfile @@ -529,24 +539,46 @@ public static function successTestCases() $promiseCreds ], ], - 'MockProfile', - $creds, - true - ), - $credsObject, - 5 - ], + 'secure' => false, + 'credentials' => $creds, + 'throw_on_connect_exception' => true + ], + 'expected_credentials' => $credsObject, + 'expected_retries' => 5 + ] ]; + + foreach ($cases as $key => $case) { + yield $key => $case; + } } /** - * @dataProvider failureTestCases + * @dataProvider failureDataProvider * - * @param $client + * @param array $clientDefinition * @param \Exception $expected */ - public function testHandlesFailureScenarios($client, \Exception $expected) + public function testHandlesFailureScenarios( + array $clientDefinition, + \Exception $expected + ) { + $clientParameters = [ + $clientDefinition['responses'], + 'MockProfile', + $clientDefinition['credentials'] + ?? ['foo_key', 'baz_secret', 'qux_token', null], + $clientDefinition['throw_on_connect_exception'] ?? false, + + ]; + + if ($clientDefinition['secure']) { + $client = self::getSecureTestClient(...$clientParameters); + } else { + $client = self::getInsecureTestClient(...$clientParameters); + } + $provider = new InstanceProfileProvider([ 'client' => $client, 'retries' => 1, @@ -561,10 +593,10 @@ public function testHandlesFailureScenarios($client, \Exception $expected) } } - public static function failureTestCases() + public static function failureDataProvider(): \Generator { - $requestClass = $this->getRequestClass(); - $responseClass = $this->getResponseClass(); + $requestClass = self::getRequestClass(); + $responseClass = self::getResponseClass(); $getRequest = new $requestClass('GET', '/latest/meta-data/foo'); $putRequest = new $requestClass('PUT', '/latest/meta-data/foo'); @@ -607,230 +639,206 @@ public static function failureTestCases() ) ]); - return [ - - // Secure data flow, profile call, non-retryable error - [ - $this->getSecureTestClient( - [ + $cases = [ + 'secure_data_flow_profile_call_non_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [$rejectionProfile] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => true, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (401 Unathorized)' - ) + ), ], - - // Insecure data flow, profile call, non-retryable error - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_profile_call_non_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [$rejectionProfile] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => false, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (401 Unathorized)' - ) + ), ], - - // Secure data flow, profile call, non-retryable error, ConnectException (Guzzle 7) - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_profile_call_non_retryable_error_connect_exception' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [$rejectionProfile] ], - 'MockProfile', - ['foo_key', 'baz_secret', 'qux_token', null], - true - ), - new CredentialsException( + 'throw_on_connect_exception' => true, + 'secure' => true, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (401 Unathorized)' - ) + ), ], - - // Insecure data flow, profile call, non-retryable error, ConnectException (Guzzle 7) - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_profile_call_non_retryable_error_connect_exception' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [$rejectionProfile] ], - 'MockProfile', - ['foo_key', 'baz_secret', 'qux_token', null], - true - ), - new CredentialsException( + 'throw_on_connect_exception' => true, + 'secure' => false, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (401 Unathorized)' - ) + ), ], - - // Secure data flow, credentials call, non-retryable error - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_credentials_call_non_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_creds' => [$rejectionCreds] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => true, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (401 Unathorized)' - ) + ), ], - - // Insecure data flow, credentials call, non-retryable error - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_credentials_call_non_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_creds' => [$rejectionCreds] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => false, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (401 Unathorized)' - ) + ), ], - - // Secure data flow, token call, retryable error - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_token_call_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ 'put' => [ $rejectionThrottleToken, $rejectionThrottleToken, $rejectionThrottleToken, ] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => true, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (Error retrieving metadata token)' - ) + ), ], - - // Secure data flow, profile call, retryable error - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_profile_call_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [ $rejectionThrottleProfile, $rejectionThrottleProfile, $rejectionThrottleProfile, ] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => true, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (503 ThrottlingException)' - ) + ), ], - - // Insecure data flow, profile call, retryable error - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_profile_call_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_profile' => [ $rejectionThrottleProfile, $rejectionThrottleProfile, $rejectionThrottleProfile, - ], + ] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => false, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (503 ThrottlingException)' - ) + ), ], - - // Secure data flow, credentials call, retryable error - [ - $this->getSecureTestClient( - [ - 'get_creds' => [ + 'secure_data_flow_credentials_call_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ + 'get_profile' => [ $rejectionThrottleCreds, $rejectionThrottleCreds, $rejectionThrottleCreds, - ], + ] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => true, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (503 ThrottlingException)' - ) + ), ], - - // Insecure data flow, credentials call, retryable error - [ - $this->getInsecureTestClient( - [ - 'get_creds' => [ + 'insecure_data_flow_credentials_call_retryable_error' => [ + 'client_definition' => [ + 'responses' => [ + 'get_profile' => [ $rejectionThrottleCreds, $rejectionThrottleCreds, $rejectionThrottleCreds, - ], + ] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => false, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (503 ThrottlingException)' - ) + ), ], - - // Secure data flow, credentials call, retryable invalid json error - [ - $this->getSecureTestClient( - [ + 'secure_data_flow_credentials_call_retryable_invalid_json_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_creds' => [ $promiseBadJsonCreds, $promiseBadJsonCreds, - $promiseBadJsonCreds + $promiseBadJsonCreds, ] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => true, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (Invalid JSON response, retries exhausted)' - ) + ), ], - - // Insecure data flow, credentials call, retryable invalid json error - [ - $this->getInsecureTestClient( - [ + 'insecure_data_flow_credentials_call_retryable_invalid_json_error' => [ + 'client_definition' => [ + 'responses' => [ 'get_creds' => [ $promiseBadJsonCreds, $promiseBadJsonCreds, - $promiseBadJsonCreds + $promiseBadJsonCreds, ] ], - 'MockProfile' - ), - new CredentialsException( + 'secure' => false, + ], + 'expected' => new CredentialsException( 'Error retrieving credentials from the instance profile ' . 'metadata service. (Invalid JSON response, retries exhausted)' - ) - ], + ), + ] ]; + + foreach ($cases as $key => $case) { + yield $key => $case; + } } public function testSwitchesBackToSecureModeOn401() { $this->expectExceptionMessage("Error retrieving credentials from the instance profile metadata service. (999 Expected Exception)"); $this->expectException(\Aws\Exception\CredentialsException::class); - $requestClass = $this->getRequestClass(); - $responseClass = $this->getResponseClass(); + $requestClass = self::getRequestClass(); + $responseClass = self::getResponseClass(); $getRequest = new $requestClass('GET', '/latest/meta-data/foo'); $putRequest = new $requestClass('PUT', '/latest/meta-data/foo'); $reqNumber = 0; @@ -891,7 +899,7 @@ private function getTestCreds( array $args = [] ) { $args['profile'] = $profile; - $args['client'] = $this->getSecureTestClient([], $profile, $result); + $args['client'] = self::getSecureTestClient([], $profile, $result); $provider = new InstanceProfileProvider($args); return $provider(); @@ -930,7 +938,7 @@ public function testThrowsExceptionOnInvalidMetadata() $this->expectExceptionMessage("Unexpected instance profile response"); $this->expectException(\Aws\Exception\CredentialsException::class); $this->getTestCreds( - $this->getCredentialArray(null, null, null, null, false), + self::getCredentialArray(null, null, null, null, false), 'foo' )->wait(); } @@ -950,7 +958,7 @@ public function testEnvDisableFlag() putenv(InstanceProfileProvider::ENV_DISABLE . '=true'); $t = time() + 1000; $this->getTestCreds( - json_encode($this->getCredentialArray('foo', 'baz', null, "@{$t}")) + json_encode(self::getCredentialArray('foo', 'baz', null, "@{$t}")) )->wait(); $this->fail('Did not throw expected CredentialException.'); } catch (CredentialsException $e) { @@ -969,7 +977,7 @@ public function testRetriesEnvVarIsUsed() $retries = (int) getenv(InstanceProfileProvider::ENV_RETRIES); $t = time() + 1000; - $result = json_encode($this->getCredentialArray('foo', 'baz', null, "@{$t}")); + $result = json_encode(self::getCredentialArray('foo', 'baz', null, "@{$t}")); $responses = [new Response(200, [], Psr7\Utils::streamFor($result))]; $client = function () use (&$retries, $responses) { @@ -1044,7 +1052,7 @@ public static function returnsExpiredCredsProvider() $promiseCreds = Promise\Create::promiseFor( new Response(200, [], Psr7\Utils::streamFor( json_encode(call_user_func_array( - [$this, 'getCredentialArray'], + [__CLASS__, 'getCredentialArray'], $expiredCreds ))) ) @@ -1052,7 +1060,7 @@ public static function returnsExpiredCredsProvider() return [ [ - $client = $this->getSecureTestClient( + $client = self::getSecureTestClient( [ 'get_creds' => [ $promiseCreds @@ -1063,7 +1071,7 @@ public static function returnsExpiredCredsProvider() ) ], [ - $client = $this->getInsecureTestClient( + $client = self::getInsecureTestClient( [ 'get_creds' => [ $promiseCreds @@ -1123,8 +1131,8 @@ public function testExtendsExpirationAndSendsRequestIfImdsUnavailable($client) public static function imdsUnavailableProvider() { - $requestClass = $this->getRequestClass(); - $responseClass = $this->getResponseClass(); + $requestClass = self::getRequestClass(); + $responseClass = self::getResponseClass(); $getRequest = new $requestClass('GET', '/latest/meta-data/foo'); $putRequest = new $requestClass('PUT', '/latest/meta-data/foo'); @@ -1151,7 +1159,7 @@ public static function imdsUnavailableProvider() return [ [ - $client = $this->getSecureTestClient( + $client = self::getSecureTestClient( [ 'put' => [ $profileRejection500 @@ -1161,7 +1169,7 @@ public static function imdsUnavailableProvider() ) ], [ - $client = $this->getSecureTestClient( + $client = self::getSecureTestClient( [ 'get_creds' => [ $credsRejection500 @@ -1171,7 +1179,7 @@ public static function imdsUnavailableProvider() ) ], [ - $client = $this->getSecureTestClient( + $client = self::getSecureTestClient( [ 'get_creds' => [ $credsRejectionReadTimeout @@ -1181,7 +1189,7 @@ public static function imdsUnavailableProvider() ) ], [ - $client = $this->getInsecureTestClient( + $client = self::getInsecureTestClient( [ 'get_creds' => [ $credsRejection500 @@ -1191,7 +1199,7 @@ public static function imdsUnavailableProvider() ) ], [ - $client = $this->getInsecureTestClient( + $client = self::getInsecureTestClient( [ 'get_creds' => [ $credsRejectionReadTimeout @@ -1208,7 +1216,7 @@ public function testResetsAttempts() $now = time() + 10000; $creds = ['foo', 'baz', null, "@{$now}"]; - $client = $this->getSecureTestClient( + $client = self::getSecureTestClient( [], 'MockProfile', $creds @@ -1348,7 +1356,7 @@ private function fetchMockedCredentialsAndAlwaysExpectAToken($config=[]) { 200, [], Psr7\Utils::streamFor( - json_encode($this->getCredentialArray('foo', 'baz', null, "@$expiration")) + json_encode(self::getCredentialArray('foo', 'baz', null, "@$expiration")) ) ) ); @@ -1667,7 +1675,7 @@ private function createMockHandlerWithUriCapture(): callable 200, [], Psr7\Utils::streamFor( - json_encode($this->getCredentialArray('foo', 'baz', null, "@$expiration")) + json_encode(self::getCredentialArray('foo', 'baz', null, "@$expiration")) ) ) ); diff --git a/tests/Endpoint/PartitionTest.php b/tests/Endpoint/PartitionTest.php index 707f70fc70..bcfd9b0baa 100644 --- a/tests/Endpoint/PartitionTest.php +++ b/tests/Endpoint/PartitionTest.php @@ -65,7 +65,7 @@ public function testFipsEndpoint(array $definition) self::assertStringContainsString('service-fips.amazonaws.com', $resolved['endpoint']); } - public static function partitionDefinitionProvider() + public static function partitionDefinitionProvider(): array { return [ [[ @@ -89,9 +89,9 @@ public static function partitionDefinitionProvider() ]; } - public static function invalidPartitionDefinitionProvider() + public static function invalidPartitionDefinitionProvider(): array { - $validDefinition = $this->partitionDefinitionProvider()[0][0]; + $validDefinition = self::partitionDefinitionProvider()[0][0]; $return = []; foreach ($validDefinition as $requiredKey => $v) { @@ -669,15 +669,35 @@ public static function s3EndpointTestCases() * @dataProvider variantTagProvider * * @param array $definition - * @param @fipsConfig - * @param @dualstackConfig + * @param bool $useFipsConfig + * @param bool $useDualstackConfig */ public function testGetVariantIgnoresVariantTagOrder( array $definition, - $fipsConfig, - $dualstackConfig + bool $useFipsConfig, + bool $useDualstackConfig ) { + $fipsConfig = null; + if ($useFipsConfig) { + $fipsConfig = $this->getMockBuilder(UseFipsEndpoint\Configuration::class) + ->disableOriginalConstructor() + ->getMock(); + $fipsConfig->expects($this->any()) + ->method('isUseFipsEndpoint') + ->willReturn(true); + } + + $dualstackConfig = null; + if ($useDualstackConfig) { + $dualstackConfig = $this->getMockBuilder(UseDualstackEndpoint\Configuration::class) + ->disableOriginalConstructor() + ->getMock(); + $dualstackConfig->expects($this->any()) + ->method('isUseDualstackEndpoint') + ->willReturn(true); + } + $partition = new Partition($definition); $resolved = $partition([ 'region' => 'us-east-1', @@ -691,22 +711,8 @@ public function testGetVariantIgnoresVariantTagOrder( $this->assertStringContainsString('testsuffix.com', $resolved['endpoint']); } - public static function variantTagProvider() + public static function variantTagProvider(): array { - $useFipsEndpointConfig = $this->getMockBuilder(UseFipsEndpoint\Configuration::class) - ->disableOriginalConstructor() - ->getMock(); - $useFipsEndpointConfig->expects($this->any()) - ->method('isUseFipsEndpoint') - ->willReturn(true); - - $useDualstackEndpointConfig = $this->getMockBuilder(UseDualstackEndpoint\Configuration::class) - ->disableOriginalConstructor() - ->getMock(); - $useDualstackEndpointConfig->expects($this->any()) - ->method('isUseDualstackEndpoint') - ->willReturn(true); - return [ [ [ @@ -731,8 +737,8 @@ public static function variantTagProvider() ], ], ], - $useFipsEndpointConfig, - $useDualstackEndpointConfig + true, + true ], [ [ @@ -757,8 +763,8 @@ public static function variantTagProvider() ], ], ], - $useFipsEndpointConfig, - $useDualstackEndpointConfig + true, + true ], [ [ @@ -783,8 +789,8 @@ public static function variantTagProvider() ], ], ], - $useFipsEndpointConfig, - null + true, + false ], [ [ @@ -809,8 +815,8 @@ public static function variantTagProvider() ], ], ], - null, - $useDualstackEndpointConfig + false, + true ] ]; } @@ -824,10 +830,30 @@ public static function variantTagProvider() */ public function testGetVariantNoVariantSelectedIfTagsAreEmpty( array $definition, - $fipsConfig, - $dualstackConfig + bool $useFipsConfig, + bool $useDualstackConfig ) { + $fipsConfig = null; + if ($useFipsConfig) { + $fipsConfig = $this->getMockBuilder(UseFipsEndpoint\Configuration::class) + ->disableOriginalConstructor() + ->getMock(); + $fipsConfig->expects($this->any()) + ->method('isUseFipsEndpoint') + ->willReturn(true); + } + + $dualstackConfig = null; + if ($useDualstackConfig) { + $dualstackConfig = $this->getMockBuilder(UseDualstackEndpoint\Configuration::class) + ->disableOriginalConstructor() + ->getMock(); + $dualstackConfig->expects($this->any()) + ->method('isUseDualstackEndpoint') + ->willReturn(true); + } + $partition = new Partition($definition); $resolved = $partition([ 'region' => 'us-east-1', @@ -841,22 +867,8 @@ public function testGetVariantNoVariantSelectedIfTagsAreEmpty( $this->assertStringNotContainsString('testsuffix.com', $resolved['endpoint']); } - public static function variantTagEmptyProvider() + public static function variantTagEmptyProvider(): array { - $useFipsEndpointConfig = $this->getMockBuilder(UseFipsEndpoint\Configuration::class) - ->disableOriginalConstructor() - ->getMock(); - $useFipsEndpointConfig->expects($this->any()) - ->method('isUseFipsEndpoint') - ->willReturn(true); - - $useDualstackEndpointConfig = $this->getMockBuilder(UseDualstackEndpoint\Configuration::class) - ->disableOriginalConstructor() - ->getMock(); - $useDualstackEndpointConfig->expects($this->any()) - ->method('isUseDualstackEndpoint') - ->willReturn(true); - return [ [ [ @@ -881,8 +893,8 @@ public static function variantTagEmptyProvider() ], ], ], - $useFipsEndpointConfig, - $useDualstackEndpointConfig + true, + true ], [ [ @@ -907,8 +919,8 @@ public static function variantTagEmptyProvider() ], ], ], - $useFipsEndpointConfig, - null + true, + false ], [ [ @@ -933,8 +945,8 @@ public static function variantTagEmptyProvider() ], ], ], - null, - $useDualstackEndpointConfig + false, + true ], [ [ @@ -959,8 +971,8 @@ public static function variantTagEmptyProvider() ], ], ], - null, - null + false, + false ] ]; } diff --git a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php index c0a1e63067..71f73ad62e 100644 --- a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php +++ b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php @@ -551,7 +551,7 @@ public function testThrowsExceptionOnDescribeFailure() } /** - * @dataProvider getInvalidEndpointExceptions + * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception */ public function testUsesCachedEndpointForInvalidEndpointException($exception) @@ -586,7 +586,7 @@ public function testUsesCachedEndpointForInvalidEndpointException($exception) } /** - * @dataProvider getInvalidEndpointExceptions + * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception */ public function testUseRegionalEndpointForInvalidEndpointException($exception) @@ -629,7 +629,7 @@ public function testUseRegionalEndpointForInvalidEndpointException($exception) } /** - * @dataProvider getInvalidEndpointExceptions + * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception */ public function testThrowsExceptionOnInvalidEndpointException($exception) @@ -670,7 +670,7 @@ public function testThrowsExceptionOnInvalidEndpointException($exception) } /** - * @dataProvider getInvalidEndpointExceptions + * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception */ public function testCallsDiscoveryApiOnInvalidEndpointException($exception) @@ -734,11 +734,11 @@ public function testCallsDiscoveryApiOnInvalidEndpointException($exception) * * @return array */ - public static function getInvalidEndpointExceptions() + public static function invalidEndpointExceptionsDataProvider(): array { return [ - [$this->generateInvalidEndpointException()], - [$this->generate421Exception()], + [self::generateInvalidEndpointException()], + [self::generate421Exception()], ]; } @@ -862,7 +862,7 @@ private function generateGenericResult() return Promise\Create::promiseFor(new Result([])); } - private function generateInvalidEndpointException() + private static function generateInvalidEndpointException(): Promise\PromiseInterface { $message = 'Test invalid endpoint exception'; return Promise\Create::rejectionFor(new AwsException( @@ -875,7 +875,7 @@ private function generateInvalidEndpointException() )); } - private function generate421Exception() + private static function generate421Exception(): Promise\PromiseInterface { $message = 'Test invalid endpoint exception'; return Promise\Create::rejectionFor(new AwsException( diff --git a/tests/EndpointParameterMiddlewareTest.php b/tests/EndpointParameterMiddlewareTest.php index aa618ce237..fd60f2a258 100644 --- a/tests/EndpointParameterMiddlewareTest.php +++ b/tests/EndpointParameterMiddlewareTest.php @@ -67,16 +67,16 @@ public function testThrowsExceptionForInvalidParameter() } /** - * @dataProvider getTestCases + * @dataProvider correctlyOutputsHostDataProvider */ public function testCorrectlyOutputsHost( - Service $service, $clientArgs, $cmdName, $params, $endpoint, $expectedHost ) { + $service = $this->generateTestService(); if ($cmdName === 'NoEndpointOp') { $this->addToAssertionCount(1); // To be replaced with $this->expectNotToPerformAssertions(); } @@ -95,14 +95,11 @@ public function testCorrectlyOutputsHost( $handler($command, new Request('POST', $endpoint)); } - public static function getTestCases() + public static function correctlyOutputsHostDataProvider(): array { - $service = $this->generateTestService(); - return [ // Operation without any prefix injection [ - $service, [], 'NoEndpointOp', [ @@ -113,7 +110,6 @@ public static function getTestCases() ], // Operation with static prefix injection [ - $service, [], 'StaticOp', [ @@ -124,7 +120,6 @@ public static function getTestCases() ], // Operation with host parameter injection [ - $service, [], 'MemberRefOp', [ @@ -135,7 +130,6 @@ public static function getTestCases() ], // Operation with multiple host parameter injections [ - $service, [], 'MultiRefOp', [ @@ -147,7 +141,6 @@ public static function getTestCases() ], // Operation with host parameter injection, disabled via client argument [ - $service, [ 'disable_host_prefix_injection' => true ], diff --git a/tests/EndpointV2/EndpointV2MiddlewareTest.php b/tests/EndpointV2/EndpointV2MiddlewareTest.php index c1edf983e7..b8c2669a98 100644 --- a/tests/EndpointV2/EndpointV2MiddlewareTest.php +++ b/tests/EndpointV2/EndpointV2MiddlewareTest.php @@ -201,52 +201,54 @@ function ($command, $endpoint) {}, */ public function testInitializationWithInvalidParameters( $nextHandler, - $endpointProvider, - $api, + bool $validEndpointProvider, + bool $validApi, $args ) { + $endpointProvider = 'invalid'; + if ($validEndpointProvider) { + $endpointProvider = $this->getMockBuilder(EndpointProviderV2::class) + ->disableOriginalConstructor() + ->getMock(); + } + + $api = 'invalid'; + if ($validApi) { + $api = $this->getMockBuilder(Service::class) + ->disableOriginalConstructor() + ->getMock(); + } + $this->expectException(\TypeError::class); new EndpointV2Middleware($nextHandler, $endpointProvider, $api, $args); } - public static function invalidInitializationProvider() + public static function invalidInitializationProvider(): array { return [ 'Invalid nextHandler' => [ 'not_a_callable', - $this->getMockBuilder(EndpointProviderV2::class) - ->disableOriginalConstructor() - ->getMock(), - $this->getMockBuilder(Service::class) - ->disableOriginalConstructor() - ->getMock(), + true, + true, [] ], 'Invalid endpointProvider' => [ function ($command, $endpoint) {}, - 'not_an_endpoint_provider', - $this->getMockBuilder(Service::class) - ->disableOriginalConstructor() - ->getMock(), + false, + true, [] ], 'Invalid api' => [ function ($command, $endpoint) {}, - $this->getMockBuilder(EndpointProviderV2::class) - ->disableOriginalConstructor() - ->getMock(), - 'not_a_service', + true, + false, [] ], 'Invalid array' => [ function ($command, $endpoint) {}, - $this->getMockBuilder(EndpointProviderV2::class) - ->disableOriginalConstructor() - ->getMock(), - $this->getMockBuilder(Service::class) - ->disableOriginalConstructor() - ->getMock(), + true, + true, 'not_an_array' ], ]; diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index 986005ee04..f02829f8d3 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -397,14 +397,43 @@ function (AwsException $e) { /** * @dataProvider recursionDetectionProvider * - * @param $mockHandler - * @param $name - * @param $trace + * @param string|null $functionName + * @param string|null $traceId + * @param bool $traceHeaderExpected + * @param string $traceHeaderExpectedValue */ - public function testRecursionDetection($mockHandler, $name, $trace) + public function testRecursionDetection( + ?string $functionName, + ?string $traceId, + bool $traceHeaderExpected, + string $traceHeaderExpectedValue, + ) { - $name !== null && putenv("AWS_LAMBDA_FUNCTION_NAME={$name}"); - $trace !== null && putenv("_X_AMZN_TRACE_ID={$trace}"); + $mockHandler = function (CommandInterface $command, RequestInterface $request) + use ($traceHeaderExpected, $traceHeaderExpectedValue) { + static $traceHeaderName = 'X-Amzn-Trace-Id'; + if ($traceHeaderExpected) { + $this->assertTrue($request->hasHeader($traceHeaderName)); + $this->assertEquals( + $traceHeaderExpectedValue, + $request->getHeaderLine($traceHeaderName) + ); + } else { + $this->assertNotTrue($request->hasHeader($traceHeaderName)); + } + + return Promise\Create::promiseFor( + new Result(['@metadata' => ['statusCode' => 200]]) + ); + }; + + if ($functionName !== null) { + putenv("AWS_LAMBDA_FUNCTION_NAME={$functionName}"); + } + if ($traceId !== null) { + putenv("_X_AMZN_TRACE_ID={$traceId}"); + } + $list = new HandlerList(); $list->setHandler($mockHandler); $list->appendBuild(Middleware::recursionDetection()); @@ -414,63 +443,102 @@ public function testRecursionDetection($mockHandler, $name, $trace) putenv('_X_AMZN_TRACE_ID'); } - public static function recursionDetectionProvider() + public static function recursionDetectionProvider(): \Generator { - $addHeaderMock = function ($command, $request) { - $this->assertTrue($request->hasHeader('X-Amzn-Trace-Id')); - $headerValue = $request->getHeaders()['X-Amzn-Trace-Id'][0]; - $this->assertEquals('bar', $headerValue); - return Promise\Create::promiseFor( - new Result(['@metadata' => ['statusCode' => 200]]) - ); - }; + $cases = [ + 'add_header' => [ + 'function_name' => 'foo', + 'trace_id' => 'bar', + 'trace_header_expected' => true, + 'trace_header_expected_value' => 'bar', + ], + 'add_header_with_encoding' => [ + 'function_name' => 'foo', + 'trace_id' => 'bar\ebaz', + 'trace_header_expected' => true, + 'trace_header_expected_value' => 'bar%1Bbaz', + ], + 'add_header_with_no_encoding' => [ + 'function_name' => 'foo', + 'trace_id' => 'bar=;:+&[]{}"\',baz', + 'trace_header_expected' => true, + 'trace_header_expected_value' => 'bar=;:+&[]{}"\',baz', + ], + 'dont_add_header' => [ + 'function_name' => '', + 'trace_id' => 'bar', + 'trace_header_expected' => false, + 'trace_header_expected_value' => '', + ], + 'dont_add_header_2' => [ + 'function_name' => 'foo', + 'trace_id' => '', + 'trace_header_expected' => false, + 'trace_header_expected_value' => '', + ], + 'dont_add_header_3' => [ + 'function_name' => '', + 'trace_id' => '', + 'trace_header_expected' => false, + 'trace_header_expected_value' => '', + ], + 'dont_add_header_4' => [ + 'function_name' => null, + 'trace_id' => 'bar', + 'trace_header_expected' => false, + 'trace_header_expected_value' => '', + ], + 'dont_add_header_5' => [ + 'function_name' => 'foo', + 'trace_id' => null, + 'trace_header_expected' => false, + 'trace_header_expected_value' => '', + ], + 'dont_add_header_6' => [ + 'function_name' => null, + 'trace_id' => null, + 'trace_header_expected' => false, + 'trace_header_expected_value' => '', + ], + ]; - $addHeaderWithEncodingMock = function ($command, $request) { - $this->assertTrue($request->hasHeader('X-Amzn-Trace-Id')); - $headerValue = $request->getHeaders()['X-Amzn-Trace-Id'][0]; - $this->assertEquals('bar%1Bbaz', $headerValue); - return Promise\Create::promiseFor( - new Result(['@metadata' => ['statusCode' => 200]]) - ); - }; + foreach ($cases as $key => $case) { + yield $key => $case; + } + } - $addHeaderWithNoEncodingMock = function ($command, $request) { - $this->assertTrue($request->hasHeader('X-Amzn-Trace-Id')); - $headerValue = $request->getHeaders()['X-Amzn-Trace-Id'][0]; - $this->assertEquals('bar=;:+&[]{}"\',baz', $headerValue); - return Promise\Create::promiseFor( - new Result(['@metadata' => ['statusCode' => 200]]) + public function testRecursionDetectionNotOverrideTraceHeaderIfExists() + { + $mockHandler = function (CommandInterface $command, RequestInterface $request) { + static $traceHeaderName = 'X-Amzn-Trace-Id'; + $this->assertTrue($request->hasHeader($traceHeaderName)); + $this->assertEquals( + 'already_exists', + $request->getHeaderLine($traceHeaderName) ); - }; - $dontAddHeaderMock = function ($command, $request) { - $this->assertFalse($request->hasHeader('X-Amzn-Trace-Id')); return Promise\Create::promiseFor( new Result(['@metadata' => ['statusCode' => 200]]) ); }; - $headerAlreadyExistsMock = function ($command, $request) { - $request = $request->withHeader('X-Amzn-Trace-Id', 'baz'); - $headerValue = $request->getHeaders()['X-Amzn-Trace-Id'][0]; - $this->assertNotEquals('bar', $headerValue); - return Promise\Create::promiseFor( - new Result(['@metadata' => ['statusCode' => 200]]) - ); - }; + putenv("AWS_LAMBDA_FUNCTION_NAME=foo"); + putenv("_X_AMZN_TRACE_ID=bazz"); - return [ - [$addHeaderMock, 'foo', 'bar'], - [$addHeaderWithEncodingMock, 'foo', 'bar\ebaz'], - [$addHeaderWithNoEncodingMock, 'foo', 'bar=;:+&[]{}"\',baz'], - [$dontAddHeaderMock, '', 'bar'], - [$dontAddHeaderMock, 'foo', ''], - [$dontAddHeaderMock, '', ''], - [$dontAddHeaderMock, null, 'bar'], - [$dontAddHeaderMock, 'foo', null], - [$dontAddHeaderMock, null, null], - [$headerAlreadyExistsMock, 'foo', 'bar'] - ]; + $list = new HandlerList(); + $list->setHandler($mockHandler); + $list->appendBuild(function (callable $handler) { + return function (CommandInterface $command, RequestInterface $request) + use ($handler) { + $request = $request->withHeader('X-Amzn-Trace-Id', 'already_exists'); + return $handler($command, $request); + }; + }); + $list->appendBuild(Middleware::recursionDetection()); + $handler = $list->resolve(); + $handler(new Command('foo'), new Request('GET', 'http://exmaple.com')); + putenv('AWS_LAMBDA_FUNCTION_NAME'); + putenv('_X_AMZN_TRACE_ID'); } /** diff --git a/tests/S3/AmbiguousSuccessParserTest.php b/tests/S3/AmbiguousSuccessParserTest.php index 17044af4f7..2f96c0e087 100644 --- a/tests/S3/AmbiguousSuccessParserTest.php +++ b/tests/S3/AmbiguousSuccessParserTest.php @@ -110,7 +110,7 @@ function ($op) { return [$op]; }, array_keys($provider('api', 's3', 'latest')['operations']), array_map( function (array $args) { return $args[0]; }, - $this->opsWithAmbiguousSuccessesProvider() + self::opsWithAmbiguousSuccessesProvider() ) ) ); diff --git a/tests/S3/ObjectCopierTest.php b/tests/S3/ObjectCopierTest.php index 674c5ba086..fc87c75014 100644 --- a/tests/S3/ObjectCopierTest.php +++ b/tests/S3/ObjectCopierTest.php @@ -18,7 +18,7 @@ class ObjectCopierTest extends TestCase use UsesServiceTrait; /** - * @dataProvider getCopyTestCases + * @dataProvider copyDataProvider */ public function testDoesCorrectOperation( array $mockedResults, @@ -39,7 +39,7 @@ public function testDoesCorrectOperation( } /** - * @dataProvider getCopyTestCasesWithPathStyle + * @dataProvider copyWithPathStyleDataProvider */ public function testDoesCorrectOperationWithPathStyle( array $mockedResults, @@ -62,7 +62,7 @@ public function testDoesCorrectOperationWithPathStyle( } /** - * @dataProvider getCopyTestCases + * @dataProvider copyDataProvider * @param array $mockedResults * @param array $options */ @@ -140,7 +140,7 @@ function (CommandInterface $cmd, RequestInterface $req) { } /** - * @dataProvider getCopyTestCases + * @dataProvider copyDataProvider */ public function testDoesCorrectOperationAsynchronously( array $mockedResults, @@ -163,7 +163,7 @@ public function testDoesCorrectOperationAsynchronously( } /** - * @dataProvider getCopyTestCasesWithPathStyle + * @dataProvider copyWithPathStyleDataProvider */ public function testDoesCorrectOperationAsynchronouslyWithPathStyle( array $mockedResults, @@ -187,7 +187,7 @@ public function testDoesCorrectOperationAsynchronouslyWithPathStyle( $this->assertTrue($this->mockQueueEmpty()); } - private function getSmallPutObjectMockResult() + private static function getSmallPutObjectMockResult(): array { $smallHeadObject = new Result(['ContentLength' => 1024 * 1024 * 6]); $putObject = new Result(); @@ -195,7 +195,7 @@ private function getSmallPutObjectMockResult() return [$smallHeadObject, $putObject]; } - private function getMultipartMockResults($key = 'key') + private static function getMultipartMockResults($key = 'key'): array { $smallHeadObject = new Result(['ContentLength' => 1024 * 1024 * 6]); $partCount = ceil($smallHeadObject['ContentLength'] / MultipartUploader::PART_MIN_SIZE); @@ -210,21 +210,21 @@ private function getMultipartMockResults($key = 'key') ); } - public static function getCopyTestCases() + public static function copyDataProvider(): array { return [ [ - $this->getSmallPutObjectMockResult(), + self::getSmallPutObjectMockResult(), [] ], [ - $this->getMultipartMockResults(), + self::getMultipartMockResults(), ['mup_threshold' => MultipartUploader::PART_MIN_SIZE] ], ]; } - private function getPathStyleMultipartMockResults() + private static function getPathStyleMultipartMockResults(): array { $smallHeadObject = new Result(['ContentLength' => 1024 * 1024 * 6]); $partCount = ceil($smallHeadObject['ContentLength'] / MultipartUploader::PART_MIN_SIZE); @@ -239,15 +239,15 @@ private function getPathStyleMultipartMockResults() ); } - public static function getCopyTestCasesWithPathStyle() + public static function copyWithPathStyleDataProvider(): array { return [ [ - $this->getSmallPutObjectMockResult(), + self::getSmallPutObjectMockResult(), [] ], [ - $this->getPathStyleMultipartMockResults(), + self::getPathStyleMultipartMockResults(), ['mup_threshold' => MultipartUploader::PART_MIN_SIZE] ], ]; @@ -317,7 +317,7 @@ public function testS3ObjectCopierCopyObjectParams() $this->addMockResults( $client, - $this->getSmallPutObjectMockResult() + self::getSmallPutObjectMockResult() ); $uploader = new ObjectCopier( @@ -357,7 +357,7 @@ public function testS3ObjectCopierMultipartParams() $this->addMockResults( $client, - $this->getMultipartMockResults() + self::getMultipartMockResults() ); $uploader = new ObjectCopier( @@ -382,7 +382,7 @@ public function testS3ObjectCopierDoesTransformUnicodeKeyToEncodedURL() $this->addMockResults( $client, - $this->getSmallPutObjectMockResult() + self::getSmallPutObjectMockResult() ); $uploader = new ObjectCopier( diff --git a/tests/S3/ObjectUploaderTest.php b/tests/S3/ObjectUploaderTest.php index e6e8855bc5..62e2e3a69c 100644 --- a/tests/S3/ObjectUploaderTest.php +++ b/tests/S3/ObjectUploaderTest.php @@ -19,7 +19,7 @@ class ObjectUploaderTest extends TestCase const MB = 1048576; /** - * @dataProvider getUploadTestCases + * @dataProvider uploadDataProvider */ public function testDoesCorrectOperation( StreamInterface $body, @@ -55,7 +55,7 @@ public function testDoesCorrectOperationWithPathStyle( } /** - * @dataProvider getUploadTestCases + * @dataProvider uploadDataProvider */ public function testDoesCorrectOperationWithAccessPointArn( StreamInterface $body, @@ -91,7 +91,7 @@ function(CommandInterface $cmd, RequestInterface $req) { } /** - * @dataProvider getUploadTestCases + * @dataProvider uploadDataProvider */ public function testDoesCorrectOperationAsynchronously( StreamInterface $body, @@ -128,7 +128,7 @@ public function testDoesCorrectOperationAsynchronouslyWithPathStyle( $this->assertSame('https://s3.amazonaws.com/bucket/key', $result['ObjectURL']); } - public static function getUploadTestCases() + public static function uploadDataProvider(): array { $putObject = new Result(); $initiate = new Result(['UploadId' => 'foo']); @@ -138,44 +138,44 @@ public static function getUploadTestCases() return [ [ // 3 MB, known-size stream (put) - $this->generateStream(1024 * 1024 * 3), + self::generateStream(1024 * 1024 * 3), [$putObject], ['before_upload' => function () {}] ], [ // 3 MB, unknown-size stream (put) - $this->generateStream(1024 * 1024 * 3, false), + self::generateStream(1024 * 1024 * 3, false), [$putObject], [] ], [ // 6 MB, known-size stream (put) - $this->generateStream(1024 * 1024 * 6), + self::generateStream(1024 * 1024 * 6), [$putObject], [] ], [ // 6 MB, known-size stream, above threshold (mup) - $this->generateStream(1024 * 1024 * 6), + self::generateStream(1024 * 1024 * 6), [$initiate, $putPart, $putPart, $complete], ['mup_threshold' => 1024 * 1024 * 4] ], [ // 6 MB, unknown-size stream (mup) - $this->generateStream(1024 * 1024 * 6, false), + self::generateStream(1024 * 1024 * 6, false), [$initiate, $putPart, $putPart, $complete], [] ], [ // 6 MB, unknown-size, non-seekable stream (mup) - $this->generateStream(1024 * 1024 * 6, false, false), + self::generateStream(1024 * 1024 * 6, false, false), [$initiate, $putPart, $putPart, $complete], [] ] ]; } - public static function getUploadTestCasesWithPathStyle() + public static function getUploadTestCasesWithPathStyle(): array { $putObject = new Result(); $initiate = new Result(['UploadId' => 'foo']); @@ -185,44 +185,48 @@ public static function getUploadTestCasesWithPathStyle() return [ [ // 3 MB, known-size stream (put) - $this->generateStream(1024 * 1024 * 3), + self::generateStream(1024 * 1024 * 3), [$putObject], ['before_upload' => function () {}] ], [ // 3 MB, unknown-size stream (put) - $this->generateStream(1024 * 1024 * 3, false), + self::generateStream(1024 * 1024 * 3, false), [$putObject], [] ], [ // 6 MB, known-size stream (put) - $this->generateStream(1024 * 1024 * 6), + self::generateStream(1024 * 1024 * 6), [$putObject], [] ], [ // 6 MB, known-size stream, above threshold (mup) - $this->generateStream(1024 * 1024 * 6), + self::generateStream(1024 * 1024 * 6), [$initiate, $putPart, $putPart, $complete], ['mup_threshold' => 1024 * 1024 * 4] ], [ // 6 MB, unknown-size stream (mup) - $this->generateStream(1024 * 1024 * 6, false), + self::generateStream(1024 * 1024 * 6, false), [$initiate, $putPart, $putPart, $complete], [] ], [ // 6 MB, unknown-size, non-seekable stream (mup) - $this->generateStream(1024 * 1024 * 6, false, false), + self::generateStream(1024 * 1024 * 6, false, false), [$initiate, $putPart, $putPart, $complete], [] ] ]; } - private function generateStream($size, $sizeKnown = true, $seekable = true) + private static function generateStream( + $size, + $sizeKnown = true, + $seekable = true + ): FnStream { return FnStream::decorate(Psr7\Utils::streamFor(str_repeat('.', $size)), [ 'getSize' => function () use ($sizeKnown, $size) { @@ -347,7 +351,7 @@ function ($cmd, $req) use ($checksumAlgorithm, $value) { $client, 'bucket', 'key', - $this->generateStream(1024 * 1024 * 1), + self::generateStream(1024 * 1024 * 1), 'private', ['params' => ['ChecksumAlgorithm' => $checksumAlgorithm]] ))->upload(); @@ -375,7 +379,7 @@ public function testAddContentMd5EmitsDeprecationNotice() $client, 'bucket', 'key', - $this->generateStream(1024 * 1024 * 1), + self::generateStream(1024 * 1024 * 1), 'private', ['add_content_md5' => true] ))->upload(); diff --git a/tests/S3/S3ClientTest.php b/tests/S3/S3ClientTest.php index 29d273b94b..a179be1ae3 100644 --- a/tests/S3/S3ClientTest.php +++ b/tests/S3/S3ClientTest.php @@ -261,42 +261,42 @@ public function testRegistersStreamWrapper() stream_wrapper_unregister('s3'); } - public static function doesExistProvider() + public static function doesExistProvider(): array { $redirectException = new PermanentRedirectException( '', new Command('mockCommand'), ['response' => new Response(301)] ); - $deleteMarkerMock = $this->getS3ErrorMock('Foo', 404, true); + $deleteMarkerMock = self::getS3ErrorMock('Foo', 404, true); return [ ['foo', null, true, []], ['foo', 'bar', true, []], - ['foo', null, true, $this->getS3ErrorMock('AccessDenied', 403)], - ['foo', 'bar', true, $this->getS3ErrorMock('AccessDenied', 403)], - ['foo', null, false, $this->getS3ErrorMock('Foo', 401)], - ['foo', 'bar', false, $this->getS3ErrorMock('Foo', 401)], - ['foo', null, -1, $this->getS3ErrorMock('Foo', 500)], - ['foo', 'bar', -1, $this->getS3ErrorMock('Foo', 500)], + ['foo', null, true, self::getS3ErrorMock('AccessDenied', 403)], + ['foo', 'bar', true, self::getS3ErrorMock('AccessDenied', 403)], + ['foo', null, false, self::getS3ErrorMock('Foo', 401)], + ['foo', 'bar', false, self::getS3ErrorMock('Foo', 401)], + ['foo', null, -1, self::getS3ErrorMock('Foo', 500)], + ['foo', 'bar', -1, self::getS3ErrorMock('Foo', 500)], ['foo', null, true, [], true], ['foo', 'bar', true, [] , true], - ['foo', null, false, $this->getS3ErrorMock('Foo', 404), true], - ['foo', 'bar', false, $this->getS3ErrorMock('Foo', 404), true], - ['foo', null, -1, $this->getS3ErrorMock('Forbidden', 403), true], - ['foo', 'bar', -1, $this->getS3ErrorMock('Forbidden', 403), true], - ['foo', null, true, $this->getS3ErrorMock('Forbidden', 403), true, true], + ['foo', null, false, self::getS3ErrorMock('Foo', 404), true], + ['foo', 'bar', false, self::getS3ErrorMock('Foo', 404), true], + ['foo', null, -1, self::getS3ErrorMock('Forbidden', 403), true], + ['foo', 'bar', -1, self::getS3ErrorMock('Forbidden', 403), true], + ['foo', null, true, self::getS3ErrorMock('Forbidden', 403), true, true], ['foo', 'bar', true, $deleteMarkerMock, true, false, true], ['foo', 'bar', false, $deleteMarkerMock, true, false, false], ['foo', null, true, $redirectException, true], ]; } - private function getS3ErrorMock( + private static function getS3ErrorMock( $errCode, $statusCode, $deleteMarker = false - ) + ): S3Exception { $response = new Response($statusCode); $deleteMarker && $response = $response->withHeader( @@ -308,6 +308,7 @@ private function getS3ErrorMock( 'code' => $errCode, 'response' => $response, ]; + return new S3Exception('', new Command('mockCommand'), $context); } @@ -720,7 +721,10 @@ public function testRetries200Errors( */ public static function s3OperationsProvider(): \Generator { - $operations = $this->loadOperations(); + $jsonContent = file_get_contents( + self::OPERATIONS_WITH_PARAMS_LOCATION + ); + $operations = json_decode($jsonContent, true); $retryModes = [ 'legacy', 'standard', @@ -741,18 +745,6 @@ public static function s3OperationsProvider(): \Generator } } - /** - * Load a list of s3 operations along with the required params populated. - * - * @return array - */ - private function loadOperations(): array - { - $jsonContent = file_get_contents(self::OPERATIONS_WITH_PARAMS_LOCATION); - - return json_decode($jsonContent, true); - } - private function getErrorXml() { return <<expectWarning(); - $this->expectWarningMessage( + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( "Failed to parse the `expires` header as a timestamp due to " . " an invalid timestamp format.\nPlease refer to `ExpiresString` " . "for the unparsed string format of this header.\n" ); - $client = new S3Client([ - 'region' => 'us-east-1', - 'http_handler' => function (RequestInterface $request) { - return Promise\Create::promiseFor(new Response( - 200, - ['expires' => 'this-is-not-a-timestamp'] - )); - }, - ]); + try { + $client = new S3Client([ + 'region' => 'us-east-1', + 'http_handler' => function (RequestInterface $request) { + return Promise\Create::promiseFor(new Response( + 200, + ['expires' => 'this-is-not-a-timestamp'] + )); + }, + ]); - $client->headObject(['Bucket' => 'foo', 'Key' => 'bar']); + $client->headObject(['Bucket' => 'foo', 'Key' => 'bar']); + } finally { + restore_error_handler(); + } } public function testExpiresRemainsTimestamp() { diff --git a/tests/S3/S3EndpointMiddlewareTest.php b/tests/S3/S3EndpointMiddlewareTest.php index 35dcd529f2..276f17a649 100644 --- a/tests/S3/S3EndpointMiddlewareTest.php +++ b/tests/S3/S3EndpointMiddlewareTest.php @@ -16,25 +16,36 @@ class S3EndpointMiddlewareTest extends TestCase { + private static array $excludedOperations = [ + 'ListBuckets', + 'CreateBucket', + 'DeleteBucket' + ]; use UsesServiceTrait; - /** - * @dataProvider includedCommandProvider - * - * @param CommandInterface $command - */ - public function testAppliesAccelerateDualStackEndpointToCommand(CommandInterface $command) + public function testAppliesAccelerateDualStackEndpointToCommand() { - $middleware = new S3EndpointMiddleware( - $this->acceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), - 'us-west-2', - [ - 'dual_stack' => true, - 'accelerate' => true, - ] - ); + $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); + foreach (self::$excludedOperations as $excludedOperation) { + unset($s3Operations[$excludedOperation]); + } - $middleware($command, $this->getRequest($command)); + $commands = array_map(function ($commandName) { + return new Command($commandName, ['Bucket' => 'bucket']); + }, array_keys($s3Operations)); + + foreach ($commands as $command) { + $middleware = new S3EndpointMiddleware( + $this->acceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), + 'us-west-2', + [ + 'dual_stack' => true, + 'accelerate' => true, + ] + ); + + $middleware($command, $this->getRequest($command)); + } } /** @@ -76,49 +87,61 @@ public function testAppliesDualStackWithPathStyleToCommandForInvalidOperationsWh $middleware($command, $this->getPathStyleRequest($command)); } - /** - * @dataProvider includedCommandProvider - * - * @param CommandInterface $command - */ - public function testDoesNothingWithoutOptIn(CommandInterface $command) + public function testDoesNothingWithoutOptIn() { - $middleware = new S3EndpointMiddleware( - $this->noAcceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), - 'us-west-2', - [] - ); + $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); + foreach (self::$excludedOperations as $excludedOperation) { + unset($s3Operations[$excludedOperation]); + } - $middleware($command, $this->getRequest($command)); + $commands = array_map(function ($commandName) { + return new Command($commandName, ['Bucket' => 'bucket']); + }, array_keys($s3Operations)); - $middleware = new S3EndpointMiddleware( - $this->noDualStackAssertingHandler($command), - 'us-west-2', - [] - ); + foreach ($commands as $command) { + $middleware = new S3EndpointMiddleware( + $this->noAcceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), + 'us-west-2', + [] + ); - $middleware($command, $this->getRequest($command)); + $middleware($command, $this->getRequest($command)); + + $middleware = new S3EndpointMiddleware( + $this->noDualStackAssertingHandler($command), + 'us-west-2', + [] + ); + + $middleware($command, $this->getRequest($command)); + } } - /** - * @dataProvider includedCommandProvider - * - * @param CommandInterface $command - */ - public function testAppliesAccelerateDualStackEndpointWithOperationalLevelOptIn(CommandInterface $command) + public function testAppliesAccelerateDualStackEndpointWithOperationalLevelOptIn() { - $middleware = new S3EndpointMiddleware( - $this->acceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), - 'us-west-2', - [ - 'dual_stack' => false, - 'accelerate' => false, - ] - ); + $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); + foreach (self::$excludedOperations as $excludedOperation) { + unset($s3Operations[$excludedOperation]); + } - $command['@use_accelerate_endpoint'] = true; - $command['@use_dual_stack_endpoint'] = true; - $middleware($command, $this->getRequest($command)); + $commands = array_map(function ($commandName) { + return new Command($commandName, ['Bucket' => 'bucket']); + }, array_keys($s3Operations)); + + foreach ($commands as $command) { + $middleware = new S3EndpointMiddleware( + $this->acceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), + 'us-west-2', + [ + 'dual_stack' => false, + 'accelerate' => false, + ] + ); + + $command['@use_accelerate_endpoint'] = true; + $command['@use_dual_stack_endpoint'] = true; + $middleware($command, $this->getRequest($command)); + } } /** @@ -158,36 +181,42 @@ public function testAppliesDualStackForInvalidOperationsWhenEnableBothWithPathSt $middleware($command, $this->getPathStyleRequest($command)); } - /** - * @dataProvider includedCommandProvider - * - * @param CommandInterface $command - */ - public function testDoesNothingWhenDisabledBothOnOperationLevel(CommandInterface $command) + public function testDoesNothingWhenDisabledBothOnOperationLevel() { - $middleware = new S3EndpointMiddleware( - $this->noAcceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), - 'us-west-2', - [ - 'dual_stack' => true, - 'accelerate' => true, - ] - ); - $command['@use_accelerate_endpoint'] = false; - $command['@use_dual_stack_endpoint'] = false; - $middleware($command, $this->getRequest($command)); + $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); + foreach (self::$excludedOperations as $excludedOperation) { + unset($s3Operations[$excludedOperation]); + } - $middleware = new S3EndpointMiddleware( - $this->noDualStackAssertingHandler($command), - 'us-west-2', - [ - 'dual_stack' => true, - 'accelerate' => true, - ] - ); - $command['@use_accelerate_endpoint'] = false; - $command['@use_dual_stack_endpoint'] = false; - $middleware($command, $this->getRequest($command)); + $commands = array_map(function ($commandName) { + return new Command($commandName, ['Bucket' => 'bucket']); + }, array_keys($s3Operations)); + + foreach ($commands as $command) { + $middleware = new S3EndpointMiddleware( + $this->noAcceleratePatternAssertingHandler($command, 's3-accelerate.dualstack'), + 'us-west-2', + [ + 'dual_stack' => true, + 'accelerate' => true, + ] + ); + $command['@use_accelerate_endpoint'] = false; + $command['@use_dual_stack_endpoint'] = false; + $middleware($command, $this->getRequest($command)); + + $middleware = new S3EndpointMiddleware( + $this->noDualStackAssertingHandler($command), + 'us-west-2', + [ + 'dual_stack' => true, + 'accelerate' => true, + ] + ); + $command['@use_accelerate_endpoint'] = false; + $command['@use_dual_stack_endpoint'] = false; + $middleware($command, $this->getRequest($command)); + } } /** @@ -206,48 +235,71 @@ public function testIgnoresExcludedCommands(CommandInterface $command) $middleware($command, $this->getRequest($command)); } - /** - * @dataProvider includedCommandProvider - * - * @param CommandInterface $command - */ - public function testAppliesAccelerateEndpointToCommands(CommandInterface $command) + public function testAppliesAccelerateEndpointToCommands() { - $middleware = new S3EndpointMiddleware( - $this->acceleratePatternAssertingHandler($command, 's3-accelerate'), - 'us-west-2', - ['accelerate' => true,] - ); + $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); + foreach (self::$excludedOperations as $excludedOperation) { + unset($s3Operations[$excludedOperation]); + } - $middleware($command, $this->getRequest($command)); + $commands = array_map(function ($commandName) { + return new Command($commandName, ['Bucket' => 'bucket']); + }, array_keys($s3Operations)); + + foreach ($commands as $command) { + $middleware = new S3EndpointMiddleware( + $this->acceleratePatternAssertingHandler($command, 's3-accelerate'), + 'us-west-2', + ['accelerate' => true,] + ); + + $middleware($command, $this->getRequest($command)); + } } - /** - * @dataProvider includedCommandProvider - * - * @param CommandInterface $command - */ - public function testDoesNothingWhenAccelerationDisabledOnOperationLevel(CommandInterface $command) + public function testDoesNothingWhenAccelerationDisabledOnOperationLevel() { - $middleware = new S3EndpointMiddleware( - $this->noAcceleratePatternAssertingHandler($command, 's3-accelerate'), - 'us-west-2', - ['accelerate' => true,] - ); + $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); + foreach (self::$excludedOperations as $excludedOperation) { + unset($s3Operations[$excludedOperation]); + } - $command['@use_accelerate_endpoint'] = false; - $middleware($command, $this->getRequest($command)); + $commands = array_map(function ($commandName) { + return new Command($commandName, ['Bucket' => 'bucket']); + }, array_keys($s3Operations)); + + foreach ($commands as $command) { + $middleware = new S3EndpointMiddleware( + $this->noAcceleratePatternAssertingHandler($command, 's3-accelerate'), + 'us-west-2', + ['accelerate' => true,] + ); + + $command['@use_accelerate_endpoint'] = false; + $middleware($command, $this->getRequest($command)); + } } public function testAppliesDualStackEndpointToCommand() { - $command = new Command('CreateBucket', ['Bucket' => 'bucket']); - $middleware = new S3EndpointMiddleware( - $this->dualStackAssertingHandler($command), - 'us-west-2', - ['dual_stack' => true,] - ); - $middleware($command, $this->getRequest($command)); + $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); + foreach (self::$excludedOperations as $excludedOperation) { + unset($s3Operations[$excludedOperation]); + } + + $commands = array_map(function ($commandName) { + return new Command($commandName, ['Bucket' => 'bucket']); + }, array_keys($s3Operations)); + + foreach ($commands as $command) { + $command = new Command('CreateBucket', ['Bucket' => 'bucket']); + $middleware = new S3EndpointMiddleware( + $this->dualStackAssertingHandler($command), + 'us-west-2', + ['dual_stack' => true,] + ); + $middleware($command, $this->getRequest($command)); + } } public function testAppliesDualStackWithPathStyleEndpointToCommand() @@ -354,26 +406,11 @@ public function testApplyingEndpointWhenEndpointOptionAndPathStyleAreSet() $middleware($command, $request); } - public static function excludedCommandProvider() + public static function excludedCommandProvider(): array { return array_map(function ($commandName) { return [new Command($commandName, ['Bucket' => 'bucket'])]; - }, ['ListBuckets', 'CreateBucket', 'DeleteBucket']); - } - - public static function includedCommandProvider() - { - $excludedOperations = array_map(function (array $args) { - return $args[0]->getName(); - }, $this->excludedCommandProvider()); - $s3Operations = $this->getTestClient('s3')->getApi()->getOperations(); - foreach ($excludedOperations as $excludedOperation) { - unset($s3Operations[$excludedOperation]); - } - - return array_map(function ($commandName) { - return [new Command($commandName, ['Bucket' => 'bucket'])]; - }, array_keys($s3Operations)); + }, self::$excludedOperations); } private function getRequest(CommandInterface $command) diff --git a/tests/S3/StreamWrapperV2ExistenceTest.php b/tests/S3/StreamWrapperV2ExistenceTest.php index f466680ea9..c74c3cdf01 100644 --- a/tests/S3/StreamWrapperV2ExistenceTest.php +++ b/tests/S3/StreamWrapperV2ExistenceTest.php @@ -239,8 +239,8 @@ public function testCanWriteEmptyFileToStream() public function testTriggersErrorInsteadOfExceptionWhenWriteFlushFails() { - $this->expectError(); - $this->expectErrorMessage('403 Forbidden'); + $this->expectException(S3Exception::class); + $this->expectExceptionMessage('403 Forbidden'); $this->addMockResults($this->client, [ function ($cmd, $req) { return new S3Exception('403 Forbidden', $cmd); } ]); diff --git a/tests/StreamRequestPayloadMiddlewareTest.php b/tests/StreamRequestPayloadMiddlewareTest.php index 23fe07185c..9c519a5a70 100644 --- a/tests/StreamRequestPayloadMiddlewareTest.php +++ b/tests/StreamRequestPayloadMiddlewareTest.php @@ -23,17 +23,23 @@ class StreamRequestPayloadMiddlewareTest extends TestCase use ArraySubsetAsserts; /** - * @dataProvider generateTestCases + * @dataProvider addsProperHeadersDataProvider * - * @param CommandInterface $command + * @param array $commandDef * @param array $expectedHeaders * @param array $expectedNonHeaders */ public function testAddsProperHeaders( - CommandInterface $command, + array $commandDef, array $expectedHeaders, array $expectedNonHeaders ) { + $service = $this->generateTestService(); + $client = $this->generateTestClient($service); + $command = $client->getCommand( + $commandDef['command_name'], + $commandDef['command_args'] + ); $list = $this->generateTestHandlerList(); $list->setHandler(function ( @@ -54,50 +60,48 @@ public function testAddsProperHeaders( $handler($command, new Request('POST', 'https://foo.com')); } - public static function generateTestCases() + public static function addsProperHeadersDataProvider(): array { - $service = $this->generateTestService(); - $client = $this->generateTestClient($service); $inputStream = Psr7\Utils::streamFor('test'); return [ [ - $client->getCommand( - 'NonStreamingOp', - [ + [ + 'command_name' => 'NonStreamingOp', + 'command_args' => [ 'InputString' => 'teststring', ] - ), + ], [], [ 'transfer-encoding'], ], [ - $client->getCommand( - 'StreamingOp', - [ + [ + 'command_name' => 'StreamingOp', + 'command_args' => [ 'InputStream' => $inputStream, ] - ), + ], [ 'Content-Length' => [26] ], [ 'transfer-encoding' ], ], [ - $client->getCommand( - 'StreamingLengthOp', - [ + [ + 'command_name' => 'StreamingLengthOp', + 'command_args' => [ 'InputStream' => $inputStream, ] - ), + ], [ 'Content-Length' => [26] ], [ 'transfer-encoding' ], ], [ - $client->getCommand( - 'StreamingLengthUnsignedOp', - [ + [ + 'command_name' => 'StreamingLengthUnsignedOp', + 'command_args' => [ 'InputStream' => $inputStream, ] - ), + ], [ 'Content-Length' => [26] ], [ 'transfer-encoding' ], ], diff --git a/tests/Token/TokenProviderTest.php b/tests/Token/TokenProviderTest.php index 08a57623d6..458935c1b4 100644 --- a/tests/Token/TokenProviderTest.php +++ b/tests/Token/TokenProviderTest.php @@ -124,7 +124,8 @@ public function testCreatesFromCache() $this->assertEquals($token->getExpiration(), $found->getExpiration()); } - public static function tokenProviderSuccessCases() { + public static function tokenProviderSuccessCases(): array + { return [ "Valid token with all fields" => [ @@ -187,7 +188,8 @@ public function testTokenProviderCachedSuccess($cachedToken, $expectedToken) $this->assertEquals(strtotime($expectedToken['expiration']), $found->getExpiration()); } - public static function tokenProviderSuccessCasesWithRefresh() { + public static function tokenProviderSuccessCasesWithRefresh(): array + { return [ "Expired token refresh with refresh token" => [ @@ -350,7 +352,8 @@ public function testTokenProviderCachedSuccessWithRefresh( } } - public static function tokenProviderFailureCases() { + public static function tokenProviderFailureCases(): array + { return [ "Minimal expired cached token" => [ diff --git a/tests/UserAgentMiddlewareTest.php b/tests/UserAgentMiddlewareTest.php index ec1580d5c4..4e150fd5d5 100644 --- a/tests/UserAgentMiddlewareTest.php +++ b/tests/UserAgentMiddlewareTest.php @@ -173,11 +173,11 @@ public static function userAgentCasesDataProvider(): \Generator yield 'hhvmVersion' => [[], defined('HHVM_VERSION') ? 'HHVM/' . HHVM_VERSION : ""]; - yield 'osName' => [[], $this->getOsNameForUserAgent()]; + yield 'osName' => [[], self::getOsNameForUserAgent()]; yield 'langVersion' => [[], 'lang/php#' . phpversion()]; - yield 'execEnv' => [[], $this->getExecEnvForUserAgent()]; + yield 'execEnv' => [[], self::getExecEnvForUserAgent()]; yield 'appId' => [['app_id' => 'FooAppId'], 'app/FooAppId']; @@ -227,7 +227,7 @@ public static function userAgentCasesDataProvider(): \Generator ]; } - private function getOsNameForUserAgent(): string + private static function getOsNameForUserAgent(): string { $disabledFunctions = explode(',', ini_get('disable_functions')); if (function_exists('php_uname') @@ -243,7 +243,7 @@ private function getOsNameForUserAgent(): string return ""; } - private function getExecEnvForUserAgent(): string + private static function getExecEnvForUserAgent(): string { $expectedEnv = "LambdaFooEnvironment"; putenv("AWS_EXECUTION_ENV={$expectedEnv}"); diff --git a/tests/WaiterTest.php b/tests/WaiterTest.php index 8c960da971..55b2b63743 100644 --- a/tests/WaiterTest.php +++ b/tests/WaiterTest.php @@ -147,10 +147,21 @@ public function testCanWait() } /** - * @dataProvider getWaiterWorkflowTestCases + * @dataProvider waiterWorkflowDataProvider */ public function testWaiterWorkflow($results, $expectedException) { + // Normalize results + foreach ($results as &$result) { + if (is_array($result)) { + $result = $this->createMockAwsException( + $result['code'], + $result['type'], + $result['message'] + ); + } + } + // Prepare a client $client = $this->getTestClient('DynamoDb', [ 'api_provider' => $this->getApiProvider() @@ -178,12 +189,16 @@ public function testWaiterWorkflow($results, $expectedException) $this->assertEquals($expectedException, $actualException); } - public static function getWaiterWorkflowTestCases() + public static function waiterWorkflowDataProvider(): array { return [ [ [ - $this->createMockAwsException('ResourceNotFoundException'), + [ + 'code' => 'ResourceNotFoundException', + 'type' => null, + 'message' => null + ], new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'CREATING']]), new Result(['Table' => ['TableStatus' => 'ACTIVE']]), @@ -209,7 +224,11 @@ public static function getWaiterWorkflowTestCases() ], [ [ - $this->createMockAwsException(null, null, 'foo'), + [ + 'code' => null, + 'type' => null, + 'message' => 'foo' + ], ], 'The TableExists waiter entered a failure state. Reason: foo' ], @@ -261,21 +280,26 @@ private function getApiProvider() } /** - * @dataProvider getMatchersTestCases + * @dataProvider matcherDataProvider */ public function testMatchers($matcher, $result, $acceptor, $expected) { + $waiter = new \ReflectionClass(Waiter::class); $matcher = $waiter->getMethod($matcher); $waiter = $waiter->newInstanceWithoutConstructor(); - $this->assertEquals($expected, $matcher->invoke($waiter, $result, $acceptor)); + $this->assertEquals($expected, $matcher->invoke( + $waiter, + $result === null ? null : $this->getMockResult($result), + $acceptor + )); } /** * @return array */ - public static function getMatchersTestCases(): array + public static function matcherDataProvider(): array { return [ 'matches_path_1' => [ @@ -286,31 +310,31 @@ public static function getMatchersTestCases(): array ], 'matches_path_2' => [ 'matcher' => 'matchesPath', - 'result' => $this->getMockResult(['a' => ['b' => 'c']]), + 'result' => ['a' => ['b' => 'c']], 'acceptor' => ['argument' => 'a.b', 'expected' => 'c'], 'expected' => true ], 'matches_path_3' => [ 'matcher' => 'matchesPath', - 'result' => $this->getMockResult(['a' => ['b' => 'c']]), + 'result' => ['a' => ['b' => 'c']], 'acceptor' => ['argument' => 'a', 'expected' => 'z'], 'expected' => false ], 'matches_path_4_same_value_different_type' => [ 'matcher' => 'matchesPath', - 'result' => $this->getMockResult(['a' => ['b' => 'false']]), + 'result' => ['a' => ['b' => 'false']], 'acceptor' => ['argument' => 'a.b', 'expected' => false], 'expected' => false ], 'matches_path_5_same_value_same_type' => [ 'matcher' => 'matchesPath', - 'result' => $this->getMockResult(['a' => ['b' => false]]), + 'result' => ['a' => ['b' => false]], 'acceptor' => ['argument' => 'a.b', 'expected' => false], 'expected' => true ], 'matches_path_6_same_value_same_type' => [ 'matcher' => 'matchesPath', - 'result' => $this->getMockResult(['a' => ['b' => 'false']]), + 'result' => ['a' => ['b' => 'false']], 'acceptor' => ['argument' => 'a.b', 'expected' => 'false'], 'expected' => true ], @@ -322,35 +346,35 @@ public static function getMatchersTestCases(): array ], 'matches_path_all_2' => [ 'matcher' => 'matchesPathAll', - 'result' => $this->getMockResult([ + 'result' => [ 'a' => [ ['b' => 'c'], ['b' => 'c'], ['b' => 'c'] ] - ]), + ], 'acceptor' => ['argument' => 'a[].b', 'expected' => 'c'], 'expected' => true, ], 'matches_path_all_3' => [ 'matcher' => 'matchesPathAll', - 'result' => $this->getMockResult(['a' => [ + 'result' => ['a' => [ ['b' => 'c'], ['b' => 'z'], ['b' => 'c'] - ]]), + ]], 'acceptor' => ['argument' => 'a[].b', 'expected' => 'c'], 'expected' => false, ], 'matches_path_all_4_empty_array_as_result' => [ 'matcher' => 'matchesPathAll', - 'result' => $this->getMockResult(), + 'result' => [], 'acceptor' => ['argument' => 'a', 'expected' => 'c'], 'expected' => false, ], 'matches_path_all_4_non_array_value_as_result' => [ 'matcher' => 'matchesPathAll', - 'result' => $this->getMockResult(['a' => 'FooValue']), + 'result' => ['a' => 'FooValue'], 'acceptor' => ['argument' => 'a[].b', 'expected' => 'c'], 'expected' => false, ], @@ -362,37 +386,37 @@ public static function getMatchersTestCases(): array ], 'matches_path_any_2' => [ 'matcher' => 'matchesPathAny', - 'result' => $this->getMockResult([ + 'result' => [ 'a' => [ ['b' => 'c'], ['b' => 'd'], ['b' => 'e'] ] - ]), + ], 'acceptor' => ['argument' => 'a[].b', 'expected' => 'c'], 'expected' => true, ], 'matches_path_any_3' => [ 'matcher' => 'matchesPathAny', - 'result' => $this->getMockResult([ + 'result' => [ 'a' => [ ['b' => 'x'], ['b' => 'y'], ['b' => 'z'] ] - ]), + ], 'acceptor' => ['argument' => 'a[].b', 'expected' => 'c'], 'expected' => false, ], 'matches_path_any_4_empty_array_as_result' => [ 'matcher' => 'matchesPathAny', - 'result' => $this->getMockResult(), + 'result' => [], 'acceptor' => ['argument' => 'a', 'expected' => 'c'], 'expected' => false, ], 'matches_path_any_5_non_array_value_as_result' => [ 'matcher' => 'matchesPathAll', - 'result' => $this->getMockResult(['a' => 'FooValue']), + 'result' => ['a' => 'FooValue'], 'acceptor' => ['argument' => 'a[].b', 'expected' => 'c'], 'expected' => false, ], @@ -404,13 +428,13 @@ public static function getMatchersTestCases(): array ], 'matches_status_2' => [ 'matcher' => 'matchesStatus', - 'result' => $this->getMockResult(), + 'result' => [], 'acceptor' => ['expected' => 200], 'expected' => true, ], 'matches_status_3' => [ 'matcher' => 'matchesStatus', - 'result' => $this->getMockResult(), + 'result' => [], 'acceptor' => ['expected' => 400], 'expected' => false, ], @@ -422,13 +446,13 @@ public static function getMatchersTestCases(): array ], 'matches_error_2' => [ 'matcher' => 'matchesError', - 'result' => $this->getMockResult('InvalidData'), + 'result' => 'InvalidData', 'acceptor' => ['expected' => 'InvalidData'], 'expected' => true, ], 'matches_error_3' => [ 'matcher' => 'matchesError', - 'result' => $this->getMockResult('InvalidData'), + 'result' => 'InvalidData', 'acceptor' => ['expected' => 'Foo'], 'expected' => false, ], diff --git a/tests/WrappedHttpHandlerTest.php b/tests/WrappedHttpHandlerTest.php index 7ebfa5e7f7..1288ae701c 100644 --- a/tests/WrappedHttpHandlerTest.php +++ b/tests/WrappedHttpHandlerTest.php @@ -95,20 +95,23 @@ public function testCanRejectWithoutResponse() * @dataProvider responseAndParserProvider * * @param Response $res - * @param $errorParser - * @param $expectedCode - * @param $expectedId - * @param $expectedArray + * @param string $serviceName + * @param string $errorParserClass + * @param string|null $expectedCode + * @param string|null $expectedId + * @param array $expectedArray */ public function testCanRejectWithAndParseResponse( Response $res, - Service $service, - $errorParser, - $expectedCode, - $expectedId, - $expectedArray + string $serviceName, + string $errorParserClass, + ?string $expectedCode, + ?string $expectedId, + array $expectedArray ) { + $service = $this->generateTestService($serviceName); + $errorParser = new $errorParserClass($service); $client = $this->generateTestClient($service, []); $cmd = $client->getCommand('TestOperation', []); $e = new \Exception('a'); @@ -133,69 +136,59 @@ public function testCanRejectWithAndParseResponse( } } - public static function responseAndParserProvider() + public static function responseAndParserProvider(): \Generator { - $services = [ - 'ec2' => $this->generateTestService('ec2'), - 'json' => $this->generateTestService('json'), - 'query' => $this->generateTestService('query'), - 'rest-json' => $this->generateTestService('rest-json'), - 'rest-xml' => $this->generateTestService('rest-xml'), - ]; - - - yield [ - new Response( + $cases = [ + 'json_rpc_error_parser' => [ + 'response' => new Response( 400, ['X-Amzn-RequestId' => '123'], json_encode(['__type' => 'foo#bar']) ), - $services['json'], - new JsonRpcErrorParser($services['json']), - 'bar', - '123', - [], - ]; - yield [ - new Response( + 'service_name' => 'json', + 'error_parser' => JsonRpcErrorParser::class, + 'expected_code' => 'bar', + 'expected_id' => '123', + 'expected_array' => [] + ], + 'rest_json' => [ + 'response' => new Response( 400, - [ - 'X-Amzn-RequestId' => '123', - ], + ['X-Amzn-RequestId' => '123'], json_encode(['message' => 'sorry!']) ), - $services['rest-json'], - new RestJsonErrorParser($services['rest-json']), - null, - '123', - [], - ]; - yield [ - new Response( + 'service_name' => 'rest-json', + 'error_parser' => RestJsonErrorParser::class, + 'expected_code' => null, + 'expected_id' => '123', + 'expected_array' => [] + ], + 'rest_xml' => [ + 'response' => new Response( 400, [], 'InternalError656c76696e6727732072657175657374' ), - $services['rest-xml'], - new XmlErrorParser($services['rest-xml']), - 'InternalError', - '656c76696e6727732072657175657374', - [], - ]; - [ - new Response( + 'service_name' => 'rest-xml', + 'error_parser' => XmlErrorParser::class, + 'expected_code' => 'InternalError', + 'expected_id' => '656c76696e6727732072657175657374', + 'expected_array' => [] + ], + 'query' => [ + 'response' => new Response( 400, ['X-Amzn-RequestId' => '123'], openssl_random_pseudo_bytes(1024) ), - $services['query'], - new XmlErrorParser($services['query']), - null, - null, - [], - ]; - yield 'Rest-json with modeled exception from header error type' => [ - new Response( + 'service_name' => 'query', + 'error_parser' => XmlErrorParser::class, + 'expected_code' => null, + 'expected_id' => null, + 'expected_array' => [] + ], + 'rest_json_with_modeled_exception_from_header_error_type' => [ + 'response' => new Response( 400, [ 'X-Amzn-RequestId' => '123', @@ -207,19 +200,19 @@ public static function responseAndParserProvider() 'NotModeled' => 'bar' ]) ), - $services['rest-json'], - new RestJsonErrorParser($services['rest-json']), - 'TestException', - '123', - [ + 'service_name' => 'rest-json', + 'error_parser' => RestJsonErrorParser::class, + 'expected_code' => 'TestException', + 'expected_id' => '123', + 'expected_array' => [ 'TestString' => 'foo-string', 'TestInt' => 456, 'TestHeaders' => [], 'TestStatus' => 400 - ], - ]; - yield 'Rest-json with modeled exception from body error code' => [ - new Response( + ] + ], + 'rest_json_with_modeled_exception_from_body_error_code' => [ + 'response' => new Response( 400, [ 'X-Amzn-RequestId' => '123' @@ -231,19 +224,19 @@ public static function responseAndParserProvider() 'code' => 'TestException' ]) ), - $services['rest-json'], - new RestJsonErrorParser($services['rest-json']), - 'TestException', - '123', - [ + 'service_name' => 'rest-json', + 'error_parser' => RestJsonErrorParser::class, + 'expected_code' => 'TestException', + 'expected_id' => '123', + 'expected_array' => [ 'TestString' => 'foo-string', 'TestInt' => 456, 'TestHeaders' => [], 'TestStatus' => 400 - ], - ]; - yield 'Ec2 with modeled exception' => [ - new Response( + ] + ], + 'ec2_with_modeled_exception' => [ + 'response' => new Response( 400, [], '' . "\n" . @@ -259,19 +252,19 @@ public static function responseAndParserProvider() ' xyz' . '' ), - $services['ec2'], - new XmlErrorParser($services['ec2']), - 'TestException', - 'xyz', - [ + 'service_name' => 'ec2', + 'error_parser' => XmlErrorParser::class, + 'expected_code' => 'TestException', + 'expected_id' => 'xyz', + 'expected_array' => [ 'TestString' => 'SomeString', 'TestInt' => 456, 'TestHeaders' => [], 'TestStatus' => 400, - ], - ]; - yield 'Query with modeled exception' => [ - new Response( + ] + ], + 'query_with_modeled_exception' => [ + 'response' => new Response( 400, [], '' . @@ -285,19 +278,19 @@ public static function responseAndParserProvider() ' xyz' . '' ), - $services['query'], - new XmlErrorParser($services['query']), - 'TestException', - 'xyz', - [ + 'service_name' => 'query', + 'error_parser' => XmlErrorParser::class, + 'expected_code' => 'TestException', + 'expected_id' => 'xyz', + 'expected_array' => [ 'TestString' => 'SomeString', 'TestInt' => 456, 'TestHeaders' => [], 'TestStatus' => 400, - ], - ]; - yield 'Rest-xml with modeled exception' => [ - new Response( + ] + ], + 'rest_xml_with_modeled_exception' => [ + 'response' => new Response( 400, [], '' . @@ -311,17 +304,22 @@ public static function responseAndParserProvider() ' xyz' . '' ), - $services['rest-xml'], - new XmlErrorParser($services['rest-xml']), - 'TestException', - 'xyz', - [ + 'service_name' => 'rest-xml', + 'error_parser' => XmlErrorParser::class, + 'expected_code' => 'TestException', + 'expected_id' => 'xyz', + 'expected_array' => [ 'TestString' => 'SomeString', 'TestInt' => 456, 'TestHeaders' => [], 'TestStatus' => 400, - ], - ]; + ] + ] + ]; + + foreach ($cases as $key => $case) { + yield $key => $case; + } } public function testCanRejectWithException() From 8b52ce7f3f38e0cd06891ac06fe3f1e2d1d48de9 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Mon, 26 Jan 2026 09:25:44 -0800 Subject: [PATCH 04/19] chore: replace deprecated expect methods - expectWarning, expectError, expectError, etc. were removed in PHPUnit 10, and a workaround was used in order to replace the usage of those APIs. The replacement is to use set_error_handler to catch the alert, throw a RuntimeException, and then expect this thrown exception. --- tests/AbstractConfigurationProviderTest.php | 4 +- tests/Api/ApiProviderTest.php | 4 +- tests/Api/DateTimeResultTest.php | 10 +- .../ErrorParser/JsonRpcErrorParserTest.php | 12 +- .../ErrorParser/RestJsonErrorParserTest.php | 12 +- tests/Api/ErrorParser/XmlErrorParserTest.php | 10 +- tests/Api/ListShapeTest.php | 4 +- tests/Api/MapShapeTest.php | 4 +- tests/Api/OperationTest.php | 4 +- tests/Api/Parser/ComplianceTest.php | 24 +- .../Api/Parser/Crc32ValidatingParserTest.php | 4 +- .../DecodingEventStreamIteratorTest.php | 10 +- tests/Api/Parser/EventParsingIteratorTest.php | 20 +- .../Parser/Exception/ParserExceptionTest.php | 4 +- tests/Api/Parser/JsonParserTest.php | 17 +- ...eStreamDecodingEventStreamIteratorTest.php | 6 +- tests/Api/Parser/RestJsonParserTest.php | 10 +- tests/Api/Parser/RestXmlParserTest.php | 4 +- tests/Api/Parser/XmlParserTest.php | 17 +- tests/Api/Serializer/ComplianceTest.php | 26 +- tests/Api/Serializer/JsonBodyTest.php | 20 +- .../Api/Serializer/JsonRpcSerializerTest.php | 4 +- tests/Api/Serializer/QuerySerializerTest.php | 4 +- .../Api/Serializer/RestJsonSerializerTest.php | 55 +-- .../Api/Serializer/RestXmlSerializerTest.php | 50 ++- tests/Api/ServiceTest.php | 25 +- tests/Api/ShapeMapTest.php | 4 +- tests/Api/ShapeTest.php | 6 +- tests/Api/StructureShapeTest.php | 4 +- tests/Api/SupportedProtocolsTest.php | 11 +- tests/Api/TimestampShapeTest.php | 10 +- tests/Api/ValidatorTest.php | 10 +- tests/Arn/AccessPointArnTest.php | 15 +- tests/Arn/ArnParserTest.php | 15 +- tests/Arn/ArnTest.php | 15 +- tests/Arn/S3/AccessPointArnTest.php | 10 +- tests/Arn/S3/OutpostsAccessPointArnTest.php | 15 +- tests/Arn/S3/OutpostsBucketArnTest.php | 15 +- tests/Auth/AuthSchemeResolverTest.php | 11 +- tests/Auth/AuthSelectionMiddlewareTest.php | 21 +- tests/AwsClientTest.php | 15 +- .../Build/Changelog/ChangelogBuilderTest.php | 4 +- tests/Build/Docs/CodeSnippetGeneratorTest.php | 6 +- tests/ClientResolverTest.php | 60 +-- ...ApiCallAttemptMonitoringMiddlewareTest.php | 6 +- .../ApiCallMonitoringMiddlewareTest.php | 6 +- .../ConfigurationProviderTest.php | 10 +- .../ConfigurationTest.php | 4 +- tests/CloudFront/CloudFrontClientTest.php | 4 +- tests/CloudFront/SignerTest.php | 11 +- tests/CloudFront/UrlSignerTest.php | 10 +- .../CloudSearchDomainTest.php | 4 +- tests/CloudTrail/LogFileIteratorTest.php | 4 +- tests/CloudTrail/LogFileReaderTest.php | 10 +- tests/CloudTrail/LogRecordIteratorTest.php | 4 +- tests/CommandPoolTest.php | 4 +- tests/CommandTest.php | 37 +- tests/ConfigurationResolverTest.php | 26 +- .../AssumeRoleCredentialProviderTest.php | 15 +- ...eWithWebIdentityCredentialProviderTest.php | 27 +- tests/Credentials/CredentialProviderTest.php | 57 ++- tests/Credentials/CredentialsTest.php | 4 +- tests/Credentials/CredentialsUtilsTest.php | 10 +- .../Credentials/EcsCredentialProviderTest.php | 20 +- .../InstanceProfileProviderTest.php | 156 ++++---- .../LoginCredentialProviderTest.php | 20 +- tests/Crypto/AesDecryptingStreamTest.php | 26 +- tests/Crypto/AesEncryptingStreamTest.php | 46 ++- tests/Crypto/AesGcmDecryptingStreamTest.php | 11 +- tests/Crypto/AesGcmEncryptingStreamTest.php | 11 +- tests/Crypto/AlgorithmSuiteTest.php | 30 +- .../EncryptionDecryptionTraitV3Test.php | 22 +- tests/Crypto/KmsMaterialsProviderTest.php | 4 +- tests/Crypto/KmsMaterialsProviderV2Test.php | 4 +- tests/Crypto/KmsMaterialsProviderV3Test.php | 4 +- tests/Crypto/MetadataEnvelopeTest.php | 20 +- tests/DSQL/AuthTokenGeneratorTest.php | 25 +- .../ConfigurationProviderTest.php | 10 +- tests/DefaultsMode/ConfigurationTest.php | 4 +- tests/DocDb/DocDbClientTest.php | 10 +- tests/DynamoDb/DynamoDbClientTest.php | 15 +- .../DynamoDb/LockingSessionConnectionTest.php | 4 +- tests/DynamoDb/MarshalerTest.php | 25 +- .../SessionConnectionConfigTraitTest.php | 4 +- tests/DynamoDb/SessionHandlerTest.php | 4 +- .../StandardSessionConnectionTest.php | 70 ++-- tests/DynamoDb/WriteRequestBatchTest.php | 10 +- tests/Ec2/Ec2ClientTest.php | 4 +- .../ElasticLoadBalancingV2ClientTest.php | 4 +- tests/Endpoint/EndpointProviderTest.php | 4 +- .../PartitionEndpointProviderTest.php | 20 +- tests/Endpoint/PartitionTest.php | 85 +++-- .../Endpoint/PatternEndpointProviderTest.php | 10 +- .../ConfigurationProviderTest.php | 4 +- .../ConfigurationTest.php | 10 +- .../ConfigurationProviderTest.php | 4 +- .../UseFipsEndpoint/ConfigurationTest.php | 10 +- .../ConfigurationProviderTest.php | 15 +- tests/EndpointDiscovery/ConfigurationTest.php | 4 +- .../EndpointDiscoveryMiddlewareTest.php | 35 +- tests/EndpointDiscovery/EndpointListTest.php | 4 +- tests/EndpointParameterMiddlewareTest.php | 10 +- .../EndpointDefinitionProviderTest.php | 6 +- tests/EndpointV2/EndpointProviderV2Test.php | 25 +- tests/EndpointV2/EndpointV2MiddlewareTest.php | 16 +- .../EndpointV2SerializerTraitTest.php | 4 +- tests/EndpointV2/RuleCreatorTest.php | 15 +- tests/EndpointV2/RulesetEndpointTest.php | 4 +- tests/EndpointV2/RulesetParameterTest.php | 45 ++- .../EndpointV2/RulesetStandardLibraryTest.php | 45 ++- tests/EventBridge/EventBridgeClientTest.php | 11 +- tests/Exception/AwsExceptionTest.php | 10 +- .../CouldNotCreateChecksumExceptionTest.php | 4 +- .../EventStreamDataExceptionTest.php | 4 +- .../MultipartUploadExceptionTest.php | 10 +- tests/FunctionsTest.php | 145 +++++--- tests/Glacier/GlacierClientTest.php | 4 +- tests/Glacier/MultipartUploaderTest.php | 10 +- tests/Glacier/TreeHashTest.php | 37 +- tests/Handler/Guzzle/HandlerTest.php | 4 +- tests/Handler/GuzzleV6/HandlerTest.php | 1 + tests/HandlerListTest.php | 4 +- tests/HasMonitoringEventsTraitTest.php | 4 +- tests/HashingStreamTest.php | 4 +- tests/HistoryTest.php | 4 +- tests/IdempotencyTokenMiddlewareTest.php | 4 +- .../S3ExpressIdentityProviderTest.php | 4 +- tests/InputValidationMiddlewareTest.php | 20 +- tests/JsonCompilerTest.php | 4 +- tests/LexModelsV2/LexModelsV2ClientTest.php | 4 +- tests/LruArrayCacheTest.php | 4 +- .../MachineLearningClientTest.php | 4 +- tests/MetricsBuilderTest.php | 13 +- tests/MiddlewareTest.php | 9 +- tests/MockHandlerTest.php | 4 +- tests/MultiRegionClientTest.php | 6 +- tests/Multipart/AbstractUploaderTest.php | 10 +- tests/Multipart/UploadStateTest.php | 25 +- tests/Neptune/NeptuneClientTest.php | 10 +- tests/PhpHashTest.php | 4 +- tests/Polly/PollyClientTest.php | 4 +- tests/PresignUrlMiddlewareTest.php | 10 +- tests/Psr16CacheAdapterTest.php | 16 +- tests/PsrCacheAdapterTest.php | 16 +- tests/QueryCompatibleInputMiddlewareTest.php | 42 ++- tests/Rds/AuthTokenGeneratorTest.php | 15 +- tests/Rds/RdsClientTest.php | 10 +- .../RequestCompressionMiddlewareTest.php | 76 ++-- tests/ResultPaginatorTest.php | 15 +- tests/ResultTest.php | 4 +- tests/Retry/ConfigurationProviderTest.php | 10 +- tests/Retry/ConfigurationTest.php | 4 +- tests/Retry/QuotaManagerTest.php | 4 +- tests/Retry/RateLimiterTest.php | 10 +- tests/RetryMiddlewareTest.php | 10 +- tests/RetryMiddlewareV2Test.php | 15 +- tests/Route53/RouteClient53Test.php | 4 +- tests/S3/AmbiguousSuccessParserTest.php | 16 +- tests/S3/ApplyChecksumMiddlewareTest.php | 37 +- tests/S3/BatchDeleteTest.php | 4 +- tests/S3/BucketEndpointArnMiddlewareTest.php | 15 +- tests/S3/BucketEndpointMiddlewareTest.php | 10 +- .../S3/Crypto/HeadersMetadataStrategyTest.php | 15 +- .../InstructionFileMetadataStrategyTest.php | 40 +- tests/S3/Crypto/S3EncryptionClientTest.php | 84 +++-- tests/S3/Crypto/S3EncryptionClientV2Test.php | 145 ++++---- tests/S3/Crypto/S3EncryptionClientV3Test.php | 172 +++++---- .../S3EncryptionMultipartUploaderTest.php | 31 +- .../S3EncryptionMultipartUploaderV2Test.php | 31 +- .../DeleteMultipleObjectsExceptionTest.php | 4 +- .../S3MultipartUploadExceptionTest.php | 4 +- tests/S3/ExpiresParsingMiddlewareTest.php | 34 +- tests/S3/GetBucketLocationParserTest.php | 10 +- tests/S3/MultipartCopyTest.php | 6 +- tests/S3/MultipartUploaderTest.php | 59 +-- tests/S3/ObjectCopierTest.php | 31 +- tests/S3/ObjectUploaderTest.php | 57 +-- .../GetBucketLocationResultMutatorTest.php | 6 +- tests/S3/Parser/S3ParserTest.php | 11 +- ...idateResponseChecksumResultMutatorTest.php | 6 +- tests/S3/PermanentRedirectMiddlewareTest.php | 4 +- tests/S3/PostObjectTest.php | 10 +- tests/S3/PostObjectV4Test.php | 15 +- tests/S3/PutObjectUrlMiddlewareTest.php | 4 +- .../ConfigurationProviderTest.php | 10 +- .../S3/RegionalEndpoint/ConfigurationTest.php | 4 +- tests/S3/S3ClientTest.php | 185 ++++++---- tests/S3/S3EndpointMiddlewareTest.php | 46 ++- tests/S3/S3MultiRegionClientTest.php | 6 +- tests/S3/S3Transfer/MultipartUploaderTest.php | 31 +- .../PartGetMultipartDownloaderTest.php | 11 +- .../AbstractProgressBarFormatTest.php | 6 +- .../Progress/ConsoleProgressBarTest.php | 6 +- .../Progress/MultiProgressTrackerTest.php | 11 +- .../Progress/SingleProgressTrackerTest.php | 11 +- .../Progress/TransferProgressSnapshotTest.php | 6 +- .../RangeGetMultipartDownloaderTest.php | 11 +- tests/S3/S3Transfer/S3TransferManagerTest.php | 81 ++-- tests/S3/S3UriParserTest.php | 10 +- tests/S3/SSECMiddlewareTest.php | 10 +- tests/S3/StreamWrapperPathStyleTest.php | 74 ++-- tests/S3/StreamWrapperTest.php | 348 +++++++++++++----- tests/S3/StreamWrapperV2ExistenceTest.php | 295 ++++++++++----- tests/S3/TransferTest.php | 15 +- .../ConfigurationProviderTest.php | 4 +- tests/S3/UseArnRegion/ConfigurationTest.php | 10 +- .../S3/ValidateResponseChecksumParserTest.php | 10 +- tests/S3Control/EndpointArnMiddlewareTest.php | 15 +- tests/S3Control/S3ControlClientTest.php | 4 +- tests/Script/ComposerTest.php | 16 +- tests/SdkTest.php | 4 +- tests/Signature/AnonymousSignatureTest.php | 4 +- tests/Signature/DpopSignatureTest.php | 4 +- tests/Signature/S3ExpressSignatureTest.php | 4 +- tests/Signature/S3SignatureV4Test.php | 4 +- tests/Signature/SignatureProviderTest.php | 10 +- tests/Signature/SignatureV4Test.php | 25 +- tests/Sqs/SqsClientTest.php | 4 +- tests/Ssm/SsmClientTest.php | 4 +- tests/StreamRequestPayloadMiddlewareTest.php | 10 +- .../ConfigurationProviderTest.php | 6 +- .../RegionalEndpoints/ConfigurationTest.php | 4 +- tests/Sts/StsClientTest.php | 25 +- tests/Token/BearerTokenAuthorizationTest.php | 10 +- tests/Token/BedrockTokenProviderTest.php | 11 +- tests/Token/SsoTokenProviderTest.php | 4 +- tests/Token/TokenProviderTest.php | 20 +- tests/Token/TokenTest.php | 4 +- tests/TraceMiddlewareTest.php | 10 +- tests/UserAgentMiddlewareTest.php | 20 +- tests/UsesServiceTrait.php | 2 +- tests/WaiterTest.php | 15 +- tests/WrappedHttpHandlerTest.php | 10 +- tests/bootstrap.php | 12 - 234 files changed, 3064 insertions(+), 1707 deletions(-) diff --git a/tests/AbstractConfigurationProviderTest.php b/tests/AbstractConfigurationProviderTest.php index 80a4fbbc4b..6094ad3ec1 100644 --- a/tests/AbstractConfigurationProviderTest.php +++ b/tests/AbstractConfigurationProviderTest.php @@ -7,10 +7,12 @@ use Aws\ResultInterface; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\AbstractConfigurationProvider + */ +#[CoversClass(\Aws\AbstractConfigurationProvider::class)] class AbstractConfigurationProviderTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ diff --git a/tests/Api/ApiProviderTest.php b/tests/Api/ApiProviderTest.php index 350daa7f6c..f0efa27c64 100644 --- a/tests/Api/ApiProviderTest.php +++ b/tests/Api/ApiProviderTest.php @@ -4,10 +4,12 @@ use Aws\Api\ApiProvider; use Aws\Exception\UnresolvedApiException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\ApiProvider + */ +#[CoversClass(ApiProvider::class)] class ApiProviderTest extends TestCase { /** diff --git a/tests/Api/DateTimeResultTest.php b/tests/Api/DateTimeResultTest.php index 7f79a557d9..9d59661944 100644 --- a/tests/Api/DateTimeResultTest.php +++ b/tests/Api/DateTimeResultTest.php @@ -3,10 +3,13 @@ use Aws\Api\DateTimeResult; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\DateTimeResult + */ +#[CoversClass(\Aws\Api\DateTimeResult::class)] class DateTimeResultTest extends TestCase { public function testCreatesFromEpoch() @@ -53,8 +56,9 @@ public function testJsonSerialzesAsIso8601() /** * @return void * - * @dataProvider nanosecondPrecisionProvider - */ + + */ + #[DataProvider('nanosecondPrecisionProvider')] public function testIso8601NanosecondPrecision($timestamp, $expected) { $parsed = DateTimeResult::fromISO8601($timestamp); diff --git a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php index 1125bc6d3a..4815d16462 100644 --- a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php +++ b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php @@ -5,23 +5,27 @@ use Aws\Test\TestServiceTrait; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\ErrorParser\JsonRpcErrorParser - * @covers \Aws\Api\ErrorParser\JsonParserTrait + */ +#[CoversClass(\Aws\Api\ErrorParser\JsonRpcErrorParser::class)] +#[CoversClass(\Aws\Api\ErrorParser\JsonParserTrait::class)] class JsonRpcErrorParserTest extends TestCase { use TestServiceTrait; /** - * @dataProvider errorResponsesProvider * * @param string $response * @param string|null $commandName * @param bool $parserWithService * @param array $expected - */ + + */ + #[DataProvider('errorResponsesProvider')] public function testParsesClientErrorResponses( string $response, ?string $commandName, diff --git a/tests/Api/ErrorParser/RestJsonErrorParserTest.php b/tests/Api/ErrorParser/RestJsonErrorParserTest.php index 85600c28a2..86c8d41361 100644 --- a/tests/Api/ErrorParser/RestJsonErrorParserTest.php +++ b/tests/Api/ErrorParser/RestJsonErrorParserTest.php @@ -5,23 +5,27 @@ use Aws\Test\TestServiceTrait; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\ErrorParser\RestJsonErrorParser - * @covers \Aws\Api\ErrorParser\JsonParserTrait + */ +#[CoversClass(\Aws\Api\ErrorParser\RestJsonErrorParser::class)] +#[CoversClass(\Aws\Api\ErrorParser\JsonParserTrait::class)] class RestJsonErrorParserTest extends TestCase { use TestServiceTrait; /** - * @dataProvider errorResponsesProvider * * @param string $response * @param string|null $commandName * @param bool $parserWithService * @param array $expected - */ + + */ + #[DataProvider('errorResponsesProvider')] public function testParsesClientErrorResponses( string $response, ?string $commandName, diff --git a/tests/Api/ErrorParser/XmlErrorParserTest.php b/tests/Api/ErrorParser/XmlErrorParserTest.php index a5c7b33a08..b6f679e7ce 100644 --- a/tests/Api/ErrorParser/XmlErrorParserTest.php +++ b/tests/Api/ErrorParser/XmlErrorParserTest.php @@ -6,17 +6,19 @@ use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\ErrorParser\XmlErrorParser + */ +#[CoversClass(XmlErrorParser::class)] class XmlErrorParserTest extends TestCase { use ArraySubsetAsserts; use TestServiceTrait; /** - * @dataProvider errorResponsesProvider * * @param string $response * @param string $protocol @@ -25,7 +27,9 @@ class XmlErrorParserTest extends TestCase * @param string|null $expectedParsedType * * @throws \Exception - */ + + */ + #[DataProvider('errorResponsesProvider')] public function testParsesClientErrorResponses( string $response, string $protocol, diff --git a/tests/Api/ListShapeTest.php b/tests/Api/ListShapeTest.php index 9b42c50aef..2e1f0e4269 100644 --- a/tests/Api/ListShapeTest.php +++ b/tests/Api/ListShapeTest.php @@ -5,10 +5,12 @@ use Aws\Api\ShapeMap; use Aws\Api\ListShape; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\ListShape + */ +#[CoversClass(\Aws\Api\ListShape::class)] class ListShapeTest extends TestCase { public function testReturnsMember() diff --git a/tests/Api/MapShapeTest.php b/tests/Api/MapShapeTest.php index d1e0df7707..18274fba9d 100644 --- a/tests/Api/MapShapeTest.php +++ b/tests/Api/MapShapeTest.php @@ -5,10 +5,12 @@ use Aws\Api\ShapeMap; use Aws\Api\MapShape; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\MapShape + */ +#[CoversClass(\Aws\Api\MapShape::class)] class MapShapeTest extends TestCase { public function testReturnsValue() diff --git a/tests/Api/OperationTest.php b/tests/Api/OperationTest.php index 76c393779e..8d6720a4d7 100644 --- a/tests/Api/OperationTest.php +++ b/tests/Api/OperationTest.php @@ -5,10 +5,12 @@ use Aws\Api\ShapeMap; use Aws\Api\Operation; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\Operation + */ +#[CoversClass(\Aws\Api\Operation::class)] class OperationTest extends TestCase { public function testCreatesDefaultMethodAndUri() diff --git a/tests/Api/Parser/ComplianceTest.php b/tests/Api/Parser/ComplianceTest.php index b1f679f123..7d51c7ab0f 100644 --- a/tests/Api/Parser/ComplianceTest.php +++ b/tests/Api/Parser/ComplianceTest.php @@ -11,17 +11,20 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\Parser\AbstractParser - * @covers \Aws\Api\Parser\AbstractRestParser - * @covers \Aws\Api\Parser\JsonRpcParser - * @covers \Aws\Api\Parser\JsonParser - * @covers \Aws\Api\Parser\RestJsonParser - * @covers \Aws\Api\Parser\RestXmlParser - * @covers \Aws\Api\Parser\QueryParser - * @covers \Aws\Api\Parser\XmlParser + */ +#[CoversClass(\Aws\Api\Parser\AbstractParser::class)] +#[CoversClass(\Aws\Api\Parser\AbstractRestParser::class)] +#[CoversClass(\Aws\Api\Parser\JsonRpcParser::class)] +#[CoversClass(\Aws\Api\Parser\JsonParser::class)] +#[CoversClass(\Aws\Api\Parser\RestJsonParser::class)] +#[CoversClass(\Aws\Api\Parser\RestXmlParser::class)] +#[CoversClass(\Aws\Api\Parser\QueryParser::class)] +#[CoversClass(\Aws\Api\Parser\XmlParser::class)] class ComplianceTest extends TestCase { use UsesServiceTrait; @@ -106,7 +109,6 @@ public static function testCaseProvider(): \Generator } /** - * @dataProvider testCaseProvider * * @param $about * @param Service $service @@ -115,7 +117,9 @@ public static function testCaseProvider(): \Generator * @param $res * @param string|null $errorCode * @param string|null $errorMessage - */ + + */ + #[DataProvider('testCaseProvider')] public function testPassesComplianceTest( string $about, Service $service, diff --git a/tests/Api/Parser/Crc32ValidatingParserTest.php b/tests/Api/Parser/Crc32ValidatingParserTest.php index 1aa3300198..f40321c75f 100644 --- a/tests/Api/Parser/Crc32ValidatingParserTest.php +++ b/tests/Api/Parser/Crc32ValidatingParserTest.php @@ -10,10 +10,12 @@ use Aws\ResultInterface; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Parser\Crc32ValidatingParser + */ +#[CoversClass(Crc32ValidatingParser::class)] class Crc32ValidatingParserTest extends TestCase { private function getWrapped() diff --git a/tests/Api/Parser/DecodingEventStreamIteratorTest.php b/tests/Api/Parser/DecodingEventStreamIteratorTest.php index a451a7875b..e7fae0ff09 100644 --- a/tests/Api/Parser/DecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/DecodingEventStreamIteratorTest.php @@ -7,10 +7,13 @@ use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\Stream; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Parser\DecodingEventStreamIterator + */ +#[CoversClass(DecodingEventStreamIterator::class)] class DecodingEventStreamIteratorTest extends TestCase { public static function complianceTests(): \Generator @@ -38,8 +41,9 @@ public static function complianceTests(): \Generator } /** - * @dataProvider complianceTests - */ + + */ + #[DataProvider('complianceTests')] public function testPassesComplianceTest( Stream $encodedData, Stream $decodedData, diff --git a/tests/Api/Parser/EventParsingIteratorTest.php b/tests/Api/Parser/EventParsingIteratorTest.php index a2400c1876..e5f3065fbf 100644 --- a/tests/Api/Parser/EventParsingIteratorTest.php +++ b/tests/Api/Parser/EventParsingIteratorTest.php @@ -15,10 +15,13 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Parser\EventParsingIterator + */ +#[CoversClass(EventParsingIterator::class)] class EventParsingIteratorTest extends TestCase { const PROTOCOL_XML = 'XML'; @@ -96,8 +99,9 @@ public static function iteratorDataProvider() * against the expected output. The reason for this is to test parsing either single or multiple * events. * - * @dataProvider iteratorDataProvider - */ + + */ + #[DataProvider('iteratorDataProvider')] public function testParsedEventsMatchExpectedOutput($iterator, $expectedOutput) { $parsedMessage = []; @@ -116,8 +120,9 @@ public function testParsedEventsMatchExpectedOutput($iterator, $expectedOutput) * This method tests for whether the deserialized event members match the equivalent * shape member types. * - * @dataProvider iteratorDataProvider - */ + + */ + #[DataProvider('iteratorDataProvider')] public function testParsedEventsMatchExpectedType($iterator) { $reflectedIteratorClass = new \ReflectionClass(get_class($iterator)); @@ -376,9 +381,10 @@ public function testHandleInitialResponse() * * @return void * - * @dataProvider handleEventWithExceptionsProvider * - */ + + */ + #[DataProvider('handleEventWithExceptionsProvider')] public function testHandleEventWithExceptions( array $eventStreams, string $expectedExceptionMessage, diff --git a/tests/Api/Parser/Exception/ParserExceptionTest.php b/tests/Api/Parser/Exception/ParserExceptionTest.php index 5c588d8042..7270bbe53e 100644 --- a/tests/Api/Parser/Exception/ParserExceptionTest.php +++ b/tests/Api/Parser/Exception/ParserExceptionTest.php @@ -3,10 +3,12 @@ use Aws\Api\Parser\Exception\ParserException; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\Parser\Exception\ParserException + */ +#[CoversClass(\Aws\Api\Parser\Exception\ParserException::class)] class ParserExceptionTest extends TestCase { public function testExtractsContext() diff --git a/tests/Api/Parser/JsonParserTest.php b/tests/Api/Parser/JsonParserTest.php index 2cc2a14156..ee3987b79d 100644 --- a/tests/Api/Parser/JsonParserTest.php +++ b/tests/Api/Parser/JsonParserTest.php @@ -3,13 +3,16 @@ use Aws\Api\Parser\Exception\ParserException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** * This class tests the custom functionality of the JsonParser; * generic testing is done in ComplianceTest.php - * @covers \Aws\Api\Parser\JsonRpcParser - * @covers \Aws\Api\Parser\JsonParser + */ +#[CoversClass(\Aws\Api\Parser\JsonRpcParser::class)] +#[CoversClass(\Aws\Api\Parser\JsonParser::class)] class JsonParserTest extends TestCase { use ParserTestServiceTrait; @@ -93,8 +96,9 @@ public static function timeStampExceptionModelProvider() } /** - * @dataProvider timeStampModelProvider - */ + + */ + #[DataProvider('timeStampModelProvider')] public function testHandlesTimeStamps( $timestamp, $commandName, @@ -114,8 +118,9 @@ public function testHandlesTimeStamps( } /** - * @dataProvider timeStampExceptionModelProvider - */ + + */ + #[DataProvider('timeStampExceptionModelProvider')] public function testTimeStampExceptions( $timestamp, $commandName, diff --git a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php index af65a127ea..3bdc02b953 100644 --- a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php @@ -8,6 +8,7 @@ use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class NonSeekableStreamDecodingEventStreamIteratorTest extends TestCase { @@ -77,10 +78,11 @@ public function testValidReturnsTrueOnEOF() * @param string $eventName * @param array $expected * - * @dataProvider readAndHashBytesHandlesPartialReadsProvider * * @return void - */ + + */ + #[DataProvider('readAndHashBytesHandlesPartialReadsProvider')] public function testReadAndHashBytesHandlesPartialReads( string $eventName, array $expected diff --git a/tests/Api/Parser/RestJsonParserTest.php b/tests/Api/Parser/RestJsonParserTest.php index 519d4ff547..9661847523 100644 --- a/tests/Api/Parser/RestJsonParserTest.php +++ b/tests/Api/Parser/RestJsonParserTest.php @@ -8,10 +8,13 @@ use Aws\Test\Api\Parser\ParserTestServiceTrait; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Parser\RestJsonParser + */ +#[CoversClass(RestJsonParser::class)] class RestJsonParserTest extends TestCase { use ParserTestServiceTrait; @@ -21,8 +24,9 @@ class RestJsonParserTest extends TestCase * @param array $expected * * @return void - * @dataProvider parsesDocumentTypePayloadProvider - */ + + */ + #[DataProvider('parsesDocumentTypePayloadProvider')] public function testParsesDocumentTypePayload( string $value, string|array $expected diff --git a/tests/Api/Parser/RestXmlParserTest.php b/tests/Api/Parser/RestXmlParserTest.php index 3a968373ab..6789109ae4 100644 --- a/tests/Api/Parser/RestXmlParserTest.php +++ b/tests/Api/Parser/RestXmlParserTest.php @@ -7,10 +7,12 @@ use Aws\CommandInterface; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Parser\RestXmlParser + */ +#[CoversClass(RestXmlParser::class)] class RestXmlParserTest extends TestCase { public function testParsesFalsyHeaderValues(): void diff --git a/tests/Api/Parser/XmlParserTest.php b/tests/Api/Parser/XmlParserTest.php index 9736fb1567..9899d7b86d 100644 --- a/tests/Api/Parser/XmlParserTest.php +++ b/tests/Api/Parser/XmlParserTest.php @@ -3,13 +3,16 @@ use Aws\Api\Parser\Exception\ParserException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** * This class tests the custom functionality of the XmlParser; * generic testing is done in ComplianceTest.php - * @covers \Aws\Api\Parser\RestXmlParser - * @covers \Aws\Api\Parser\XmlParser + */ +#[CoversClass(\Aws\Api\Parser\RestXmlParser::class)] +#[CoversClass(\Aws\Api\Parser\XmlParser::class)] class XmlParserTest extends TestCase { use ParserTestServiceTrait; @@ -90,8 +93,9 @@ public static function timeStampExceptionModelProvider() } /** - * @dataProvider timeStampModelProvider - */ + + */ + #[DataProvider('timeStampModelProvider')] public function testTimeStamps($timestamp, $commandName, $expectedValue) { $service = $this->generateTestService('rest-xml'); @@ -109,8 +113,9 @@ public function testTimeStamps($timestamp, $commandName, $expectedValue) /** - * @dataProvider timeStampExceptionModelProvider - */ + + */ + #[DataProvider('timeStampExceptionModelProvider')] public function testExceptionTimeStamps( $timestamp, $commandName, diff --git a/tests/Api/Serializer/ComplianceTest.php b/tests/Api/Serializer/ComplianceTest.php index b4096dd38b..e666423730 100644 --- a/tests/Api/Serializer/ComplianceTest.php +++ b/tests/Api/Serializer/ComplianceTest.php @@ -6,18 +6,21 @@ use Aws\Signature\SignatureInterface; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\Serializer\QuerySerializer - * @covers \Aws\Api\Serializer\JsonRpcSerializer - * @covers \Aws\Api\Serializer\RestSerializer - * @covers \Aws\Api\Serializer\RestJsonSerializer - * @covers \Aws\Api\Serializer\RestXmlSerializer - * @covers \Aws\Api\Serializer\JsonBody - * @covers \Aws\Api\Serializer\XmlBody - * @covers \Aws\Api\Serializer\Ec2ParamBuilder - * @covers \Aws\Api\Serializer\QueryParamBuilder + */ +#[CoversClass(\Aws\Api\Serializer\QuerySerializer::class)] +#[CoversClass(\Aws\Api\Serializer\JsonRpcSerializer::class)] +#[CoversClass(\Aws\Api\Serializer\RestSerializer::class)] +#[CoversClass(\Aws\Api\Serializer\RestJsonSerializer::class)] +#[CoversClass(\Aws\Api\Serializer\RestXmlSerializer::class)] +#[CoversClass(\Aws\Api\Serializer\JsonBody::class)] +#[CoversClass(\Aws\Api\Serializer\XmlBody::class)] +#[CoversClass(\Aws\Api\Serializer\Ec2ParamBuilder::class)] +#[CoversClass(\Aws\Api\Serializer\QueryParamBuilder::class)] class ComplianceTest extends TestCase { use UsesServiceTrait; @@ -82,8 +85,9 @@ function () { return []; } } /** - * @dataProvider testCaseProvider - */ + + */ + #[DataProvider('testCaseProvider')] public function testPassesComplianceTest( Service $service, $name, diff --git a/tests/Api/Serializer/JsonBodyTest.php b/tests/Api/Serializer/JsonBodyTest.php index e8d397b30f..f2c6adf6d3 100644 --- a/tests/Api/Serializer/JsonBodyTest.php +++ b/tests/Api/Serializer/JsonBodyTest.php @@ -7,10 +7,13 @@ use Aws\Api\ShapeMap; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Serializer\JsonBody + */ +#[CoversClass(JsonBody::class)] class JsonBodyTest extends TestCase { use UsesServiceTrait; @@ -145,8 +148,9 @@ public static function formatProvider() } /** - * @dataProvider formatProvider - */ + + */ + #[DataProvider('formatProvider')] public function testFormatsJson(array $def, array $args, string $result): void { $j = new JsonBody(new Service([], function() { return []; })); @@ -193,8 +197,9 @@ public static function formatNoReferencesProvider(): iterable } /** - * @dataProvider formatNoReferencesProvider - */ + + */ + #[DataProvider('formatNoReferencesProvider')] public function testFormatsJsonDoesNotCreateReferences( array $def, array $args, @@ -216,8 +221,9 @@ public function testFormatsJsonDoesNotCreateReferences( * @param string $expected * * @return void - * @dataProvider buildsDocTypesProvider - */ + + */ + #[DataProvider('buildsDocTypesProvider')] public function testBuildsDocTypes(string|array $args, string $expected): void { $j = new JsonBody(new Service([], function() { return []; })); diff --git a/tests/Api/Serializer/JsonRpcSerializerTest.php b/tests/Api/Serializer/JsonRpcSerializerTest.php index ecc0bd0852..f2a593b571 100644 --- a/tests/Api/Serializer/JsonRpcSerializerTest.php +++ b/tests/Api/Serializer/JsonRpcSerializerTest.php @@ -9,10 +9,12 @@ use Aws\EndpointV2\Ruleset\RulesetEndpoint; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Serializer\JsonRpcSerializer + */ +#[CoversClass(JsonRpcSerializer::class)] class JsonRpcSerializerTest extends TestCase { use UsesServiceTrait; diff --git a/tests/Api/Serializer/QuerySerializerTest.php b/tests/Api/Serializer/QuerySerializerTest.php index f5619a5894..3fe4de91c6 100644 --- a/tests/Api/Serializer/QuerySerializerTest.php +++ b/tests/Api/Serializer/QuerySerializerTest.php @@ -9,10 +9,12 @@ use Aws\EndpointV2\Ruleset\RulesetEndpoint; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Serializer\QuerySerializer + */ +#[CoversClass(QuerySerializer::class)] class QuerySerializerTest extends TestCase { use UsesServiceTrait; diff --git a/tests/Api/Serializer/RestJsonSerializerTest.php b/tests/Api/Serializer/RestJsonSerializerTest.php index b808d3b8f2..faf2bc38d5 100644 --- a/tests/Api/Serializer/RestJsonSerializerTest.php +++ b/tests/Api/Serializer/RestJsonSerializerTest.php @@ -12,10 +12,13 @@ use Aws\Test\UsesServiceTrait; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Serializer\RestJsonSerializer + */ +#[CoversClass(RestJsonSerializer::class)] class RestJsonSerializerTest extends TestCase { use UsesServiceTrait; @@ -305,10 +308,11 @@ public function testPreparesRequestsWithStructPayload(): void } /** - * @dataProvider doctypeTestProvider * @param $input * @param $expectedOutput - */ + + */ + #[DataProvider('doctypeTestProvider')] public function testHandlesDoctype($input, $expectedOutput): void { $request = $this->getRequest('doctype', $input); @@ -358,10 +362,11 @@ public static function doctypeTestProvider(): iterable /** - * @dataProvider restJsonContentTypeProvider * @param string $operation * @param array $input - */ + + */ + #[DataProvider('restJsonContentTypeProvider')] public function testRestJsonContentTypeNoPayload( string $operation, array $input @@ -391,10 +396,11 @@ public static function restJsonContentTypeProvider(): iterable } /** - * @dataProvider boolProvider * @param bool $arg * @param string $expected - */ + + */ + #[DataProvider('boolProvider')] public function testSerializesHeaderValueToBoolString( bool $arg, string $expected @@ -426,8 +432,9 @@ public function testDoesNotOverrideScheme(): void * @param string $expectedOutput * * @return void - * @dataProvider handlesDocTypeAsPayloadProvider - */ + + */ + #[DataProvider('handlesDocTypeAsPayloadProvider')] public function testHandlesDocTypeAsPayload( string|array $input, string $expectedOutput @@ -488,8 +495,9 @@ public static function handlesDocTypeAsPayloadProvider(): \Generator * @param array|string $input * * @return void - * @dataProvider rejectsInvalidJsonAsPayloadProvider - */ + + */ + #[DataProvider('rejectsInvalidJsonAsPayloadProvider')] public function testRejectsInvalidJsonAsPayload(array|string $input): void { $this->expectException(InvalidJsonException::class); @@ -521,8 +529,9 @@ public static function rejectsInvalidJsonAsPayloadProvider(): iterable * @param string $description * * @return void - * @dataProvider endpointResolutionProvider - */ + + */ + #[DataProvider('endpointResolutionProvider')] public function testEndpointResolution( string $endpoint, string $requestUri, @@ -546,8 +555,9 @@ public function testEndpointResolution( } /** - * @dataProvider endpointResolutionProvider - */ + + */ + #[DataProvider('endpointResolutionProvider')] public function testEndpointV2Resolution( string $endpoint, string $requestUri, @@ -572,8 +582,9 @@ public function testEndpointV2Resolution( } /** - * @dataProvider geoServiceEndpointResolutionProvider - */ + + */ + #[DataProvider('geoServiceEndpointResolutionProvider')] public function testGeoServiceEndpointResolution( string $endpoint, string $requestUri, @@ -596,8 +607,9 @@ public function testGeoServiceEndpointResolution( } /** - * @dataProvider geoServiceEndpointResolutionProvider - */ + + */ + #[DataProvider('geoServiceEndpointResolutionProvider')] public function testGeoServiceEndpointV2Resolution( string $endpoint, string $requestUri, @@ -857,8 +869,9 @@ public static function geoServiceEndpointResolutionProvider(): \Generator } /** - * @dataProvider geoServiceE2EProvider - */ + + */ + #[DataProvider('geoServiceE2EProvider')] public function testGeoServiceEndpointResolutionE2E( string $service, string $region, diff --git a/tests/Api/Serializer/RestXmlSerializerTest.php b/tests/Api/Serializer/RestXmlSerializerTest.php index bbf5edfc02..c01c9478bf 100644 --- a/tests/Api/Serializer/RestXmlSerializerTest.php +++ b/tests/Api/Serializer/RestXmlSerializerTest.php @@ -10,10 +10,13 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Serializer\RestXmlSerializer + */ +#[CoversClass(RestXmlSerializer::class)] class RestXmlSerializerTest extends TestCase { use UsesServiceTrait; @@ -83,10 +86,11 @@ public function testPreparesRequestsWithStructurePayloadXmlContentType() } /** - * @dataProvider boolProvider * @param bool $arg * @param string $expected - */ + + */ + #[DataProvider('boolProvider')] public function testSerializesHeaderValueToBoolString($arg, $expected) { $request = $this->getRequest('PutObject', [ @@ -119,8 +123,9 @@ public function testDoesNotOverrideScheme() } /** - * @dataProvider s3EndpointResolutionProvider - */ + + */ + #[DataProvider('s3EndpointResolutionProvider')] public function testS3EndpointResolution( string $endpoint, string $bucket, @@ -143,8 +148,9 @@ public function testS3EndpointResolution( } /** - * @dataProvider s3EndpointResolutionProvider - */ + + */ + #[DataProvider('s3EndpointResolutionProvider')] public function testS3EndpointV2Resolution( string $endpoint, string $bucket, @@ -168,8 +174,9 @@ public function testS3EndpointV2Resolution( } /** - * @dataProvider s3DotSegmentProvider - */ + + */ + #[DataProvider('s3DotSegmentProvider')] public function testS3DotSegmentPreservation( string $endpoint, string $bucket, @@ -192,8 +199,9 @@ public function testS3DotSegmentPreservation( } /** - * @dataProvider s3DotSegmentProvider - */ + + */ + #[DataProvider('s3DotSegmentProvider')] public function testS3DotSegmentV2Preservation( string $endpoint, string $bucket, @@ -217,8 +225,9 @@ public function testS3DotSegmentV2Preservation( } /** - * @dataProvider restXmlEndpointResolutionProvider - */ + + */ + #[DataProvider('restXmlEndpointResolutionProvider')] public function testRestXmlEndpointResolution( string $endpoint, string $requestUri, @@ -242,8 +251,9 @@ public function testRestXmlEndpointResolution( } /** - * @dataProvider restXmlEndpointResolutionProvider - */ + + */ + #[DataProvider('restXmlEndpointResolutionProvider')] public function testRestXmlEndpointV2Resolution( string $endpoint, string $requestUri, @@ -490,8 +500,9 @@ public static function restXmlEndpointResolutionProvider(): \Generator } /** - * @dataProvider s3E2EProvider - */ + + */ + #[DataProvider('s3E2EProvider')] public function testS3EndpointResolutionE2E( string $region, string $bucket, @@ -526,8 +537,9 @@ public function testS3EndpointResolutionE2E( } /** - * @dataProvider s3E2EProvider - */ + + */ + #[DataProvider('s3E2EProvider')] public function testS3EndpointResolutionE2ELegacyProvider( string $region, string $bucket, diff --git a/tests/Api/ServiceTest.php b/tests/Api/ServiceTest.php index b1fe47dab6..11642c28a9 100644 --- a/tests/Api/ServiceTest.php +++ b/tests/Api/ServiceTest.php @@ -12,10 +12,13 @@ use Aws\Test\TestServiceTrait; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\Service + */ +#[CoversClass(\Aws\Api\Service::class)] class ServiceTest extends TestCase { use UsesServiceTrait; @@ -155,8 +158,9 @@ public static function errorParserProvider() } /** - * @dataProvider errorParserProvider - */ + + */ + #[DataProvider('errorParserProvider')] public function testCreatesRelevantErrorParsers($p, $cl) { $this->assertInstanceOf($cl, Service::createErrorParser($p)); @@ -180,8 +184,9 @@ public static function serializerDataProvider() } /** - * @dataProvider serializerDataProvider - */ + + */ + #[DataProvider('serializerDataProvider')] public function testCreatesSerializer($type, $cl) { $data = ['metadata' => ['protocol' => $type]]; @@ -208,8 +213,9 @@ public static function parserDataProvider() } /** - * @dataProvider parserDataProvider - */ + + */ + #[DataProvider('parserDataProvider')] public function testCreatesParsers($type, $cl) { $service = new Service( @@ -307,8 +313,9 @@ function () { return []; } } /** - * @dataProvider selectsProtocolProvider - */ + + */ + #[DataProvider('selectsProtocolProvider')] public function testSelectsProtocol($protocols, $expected) { $s = new Service( diff --git a/tests/Api/ShapeMapTest.php b/tests/Api/ShapeMapTest.php index bafa2a4ebf..74d9e94428 100644 --- a/tests/Api/ShapeMapTest.php +++ b/tests/Api/ShapeMapTest.php @@ -4,10 +4,12 @@ use Aws\Api\Shape; use Aws\Api\ShapeMap; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\ShapeMap + */ +#[CoversClass(\Aws\Api\ShapeMap::class)] class ShapeMapTest extends TestCase { private $shapeDefinitions; diff --git a/tests/Api/ShapeTest.php b/tests/Api/ShapeTest.php index a0fe589a3c..cc08469bb3 100644 --- a/tests/Api/ShapeTest.php +++ b/tests/Api/ShapeTest.php @@ -4,11 +4,13 @@ use Aws\Api\Shape; use Aws\Api\ShapeMap; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Shape - * @covers Aws\Api\AbstractModel + */ +#[CoversClass(Shape::class)] +#[CoversClass(Shape::class)] class ShapeTest extends TestCase { public function testImplementsArray() diff --git a/tests/Api/StructureShapeTest.php b/tests/Api/StructureShapeTest.php index 3bd0c8b772..e446897e82 100644 --- a/tests/Api/StructureShapeTest.php +++ b/tests/Api/StructureShapeTest.php @@ -5,10 +5,12 @@ use Aws\Api\ShapeMap; use Aws\Api\StructureShape; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\StructureShape + */ +#[CoversClass(\Aws\Api\StructureShape::class)] class StructureShapeTest extends TestCase { public function testReturnsWhenMembersAreEmpty() diff --git a/tests/Api/SupportedProtocolsTest.php b/tests/Api/SupportedProtocolsTest.php index c62f81fc28..57e0bb77aa 100644 --- a/tests/Api/SupportedProtocolsTest.php +++ b/tests/Api/SupportedProtocolsTest.php @@ -4,20 +4,23 @@ use Aws\Api\SupportedProtocols; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class SupportedProtocolsTest extends TestCase { /** - * @dataProvider validProtocolsProvider - */ + + */ + #[DataProvider('validProtocolsProvider')] public function testIsSupportedReturnsTrueForValidProtocols(string $protocol) { $this->assertTrue(SupportedProtocols::isSupported($protocol)); } /** - * @dataProvider invalidProtocolsProvider - */ + + */ + #[DataProvider('invalidProtocolsProvider')] public function testIsSupportedReturnsFalseForInvalidProtocols(string $protocol) { $this->assertFalse(SupportedProtocols::isSupported($protocol)); diff --git a/tests/Api/TimestampShapeTest.php b/tests/Api/TimestampShapeTest.php index 44f8c2930c..34a4ac1239 100644 --- a/tests/Api/TimestampShapeTest.php +++ b/tests/Api/TimestampShapeTest.php @@ -4,10 +4,13 @@ use Aws\Api\TimestampShape; use Aws\Api\ShapeMap; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Api\TimestampShape + */ +#[CoversClass(\Aws\Api\TimestampShape::class)] class TimestampShapeTest extends TestCase { public static function formatProvider() @@ -30,8 +33,9 @@ public static function formatProvider() } /** - * @dataProvider formatProvider - */ + + */ + #[DataProvider('formatProvider')] public function testFormatsData($value, $format, $result) { $s = new TimestampShape([], new ShapeMap([])); diff --git a/tests/Api/ValidatorTest.php b/tests/Api/ValidatorTest.php index 82ca0822b7..a114460d65 100644 --- a/tests/Api/ValidatorTest.php +++ b/tests/Api/ValidatorTest.php @@ -6,10 +6,13 @@ use Aws\Api\Validator; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use GuzzleHttp\Psr7; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Api\Validator + */ +#[CoversClass(Validator::class)] class ValidatorTest extends TestCase { public static function validationProvider() @@ -639,8 +642,9 @@ public static function validationProvider() } /** - * @dataProvider validationProvider - */ + + */ + #[DataProvider('validationProvider')] public function testValidatesInput($shape, $input, $result) { $shape = Shape::create($shape, new ShapeMap([])); diff --git a/tests/Arn/AccessPointArnTest.php b/tests/Arn/AccessPointArnTest.php index 6484bcdef4..8af180fd2e 100644 --- a/tests/Arn/AccessPointArnTest.php +++ b/tests/Arn/AccessPointArnTest.php @@ -4,19 +4,23 @@ use Aws\Arn\AccessPointArn; use Aws\Arn\Exception\InvalidArnException; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Arn\AccessPointArn + */ +#[CoversClass(\Aws\Arn\AccessPointArn::class)] class AccessPointArnTest extends TestCase { /** - * @dataProvider parsedArnProvider * * @param $string * @param $expected * @param $expectedString - */ + + */ + #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { $arn = new AccessPointArn($string); @@ -86,11 +90,12 @@ public static function parsedArnProvider() } /** - * @dataProvider invalidArnCases * * @param $string * @param $message - */ + + */ + #[DataProvider('invalidArnCases')] public function testThrowsOnInvalidArn($string, $message) { try { diff --git a/tests/Arn/ArnParserTest.php b/tests/Arn/ArnParserTest.php index c0e26d52da..6f5cf127d0 100644 --- a/tests/Arn/ArnParserTest.php +++ b/tests/Arn/ArnParserTest.php @@ -9,19 +9,23 @@ use Aws\Arn\S3\OutpostsBucketArn; use Aws\Arn\S3\RegionalBucketArn; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Arn\ArnParser + */ +#[CoversClass(\Aws\Arn\ArnParser::class)] class ArnParserTest extends TestCase { /** - * @dataProvider isArnCases * * @param $string * @param $expected - */ + + */ + #[DataProvider('isArnCases')] public function testDeterminesShouldAttemptToParseAsArn($string, $expected) { $this->assertEquals($expected, ArnParser::isArn($string)); @@ -58,11 +62,12 @@ public static function isArnCases() } /** - * @dataProvider parsedArnCases * * @param $string * @param $expected - */ + + */ + #[DataProvider('parsedArnCases')] public function testCorrectlyChoosesArnClass($string, $expected) { $this->assertTrue(ArnParser::parse($string) instanceof $expected); diff --git a/tests/Arn/ArnTest.php b/tests/Arn/ArnTest.php index c45b9e5571..c7c9fd2368 100644 --- a/tests/Arn/ArnTest.php +++ b/tests/Arn/ArnTest.php @@ -5,20 +5,24 @@ use Aws\Arn\Exception\InvalidArnException; use GuzzleHttp\Promise\Promise; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Arn\Arn + */ +#[CoversClass(\Aws\Arn\Arn::class)] class ArnTest extends TestCase { /** - * @dataProvider parsedArnProvider * * @param $string * @param $expected * @param $expectedString - */ + + */ + #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { $arn = new Arn($string); @@ -117,11 +121,12 @@ public static function parsedArnProvider() } /** - * @dataProvider invalidArnCases * * @param $string * @param $message - */ + + */ + #[DataProvider('invalidArnCases')] public function testThrowsOnInvalidArn($string, $message) { try { diff --git a/tests/Arn/S3/AccessPointArnTest.php b/tests/Arn/S3/AccessPointArnTest.php index 65042568b5..666594eee6 100644 --- a/tests/Arn/S3/AccessPointArnTest.php +++ b/tests/Arn/S3/AccessPointArnTest.php @@ -4,18 +4,22 @@ use Aws\Arn\S3\AccessPointArn; use Aws\Arn\Exception\InvalidArnException; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Arn\S3\AccessPointArn + */ +#[CoversClass(\Aws\Arn\S3\AccessPointArn::class)] class AccessPointArnTest extends TestCase { /** - * @dataProvider invalidArnCases * * @param $string * @param $message - */ + + */ + #[DataProvider('invalidArnCases')] public function testThrowsOnInvalidArn($string, $message) { try { diff --git a/tests/Arn/S3/OutpostsAccessPointArnTest.php b/tests/Arn/S3/OutpostsAccessPointArnTest.php index 3763dcfb6e..0aa2d80d16 100644 --- a/tests/Arn/S3/OutpostsAccessPointArnTest.php +++ b/tests/Arn/S3/OutpostsAccessPointArnTest.php @@ -5,19 +5,23 @@ use Aws\Arn\Exception\InvalidArnException; use Aws\Arn\S3\OutpostsAccessPointArn; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Arn\S3\OutpostsAccessPointArn + */ +#[CoversClass(\Aws\Arn\S3\OutpostsAccessPointArn::class)] class OutpostsAccessPointArnTest extends TestCase { /** - * @dataProvider parsedArnProvider * * @param $string * @param $expected * @param $expectedString - */ + + */ + #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { $arn = new OutpostsAccessPointArn($string); @@ -114,11 +118,12 @@ public static function parsedArnProvider() } /** - * @dataProvider badArnProvider * * @param $string * @param \Exception $expected - */ + + */ + #[DataProvider('badArnProvider')] public function testThrowsForBadArn($string, \Exception $expected) { try { diff --git a/tests/Arn/S3/OutpostsBucketArnTest.php b/tests/Arn/S3/OutpostsBucketArnTest.php index af2d855edb..bbba2980d5 100644 --- a/tests/Arn/S3/OutpostsBucketArnTest.php +++ b/tests/Arn/S3/OutpostsBucketArnTest.php @@ -6,19 +6,23 @@ use Aws\Arn\S3\OutpostsAccessPointArn; use Aws\Arn\S3\OutpostsBucketArn; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Arn\S3\OutpostsBucketArn + */ +#[CoversClass(\Aws\Arn\S3\OutpostsBucketArn::class)] class OutpostsBucketArnTest extends TestCase { /** - * @dataProvider parsedArnProvider * * @param $string * @param $expected * @param $expectedString - */ + + */ + #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { $arn = new OutpostsBucketArn($string); @@ -115,11 +119,12 @@ public static function parsedArnProvider() } /** - * @dataProvider badArnProvider * * @param $string * @param \Exception $expected - */ + + */ + #[DataProvider('badArnProvider')] public function testThrowsForBadArn($string, \Exception $expected) { try { diff --git a/tests/Auth/AuthSchemeResolverTest.php b/tests/Auth/AuthSchemeResolverTest.php index db3f114b12..ee279a0c12 100644 --- a/tests/Auth/AuthSchemeResolverTest.php +++ b/tests/Auth/AuthSchemeResolverTest.php @@ -8,6 +8,7 @@ use Aws\Identity\BearerTokenIdentity; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AuthSchemeResolverTest extends TestCase { @@ -35,8 +36,9 @@ public function testAcceptsCustomSchemeMap() } /** - * @dataProvider schemeForIdentityProvider - */ + + */ + #[DataProvider('schemeForIdentityProvider')] public function testSelectAuthSchemeReturnsCorrectSchemeForIdentity( $authScheme, $expectedSignatureVersion, @@ -190,8 +192,9 @@ public function testUnmetV4aRequirementsThrows() } /** - * @dataProvider fallsBackWhenIdentityNotAvailableProvider - */ + + */ + #[DataProvider('fallsBackWhenIdentityNotAvailableProvider')] public function testFallsBackWhenIdentityNotAvailable( string $credentialIdentityClass, string $tokenIdentityClass, diff --git a/tests/Auth/AuthSelectionMiddlewareTest.php b/tests/Auth/AuthSelectionMiddlewareTest.php index 4c22934231..616bc91d08 100644 --- a/tests/Auth/AuthSelectionMiddlewareTest.php +++ b/tests/Auth/AuthSelectionMiddlewareTest.php @@ -14,6 +14,7 @@ use Aws\Result; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AuthSelectionMiddlewareTest extends TestCase { @@ -22,8 +23,9 @@ class AuthSelectionMiddlewareTest extends TestCase * @param $operationAuth * @param $expected * - * @dataProvider resolvesAuthSchemeWithoutCRTProvider - */ + + */ + #[DataProvider('resolvesAuthSchemeWithoutCRTProvider')] public function testResolvesAuthSchemeWithoutCRT( $serviceAuth, $operationAuth, @@ -96,8 +98,9 @@ public function ResolvesAuthSchemeWithoutCRTProvider() * @param $operationAuth * @param $expected * - * @dataProvider ResolvesAuthSchemeWithCRTprovider - */ + + */ + #[DataProvider('ResolvesAuthSchemeWithCRTprovider')] public function testResolvesAuthSchemeWithCRT( $serviceAuth, $operationAuth, @@ -165,8 +168,9 @@ public static function ResolvesAuthSchemeWithCRTprovider() * @param $identity * @param $expected * - * @dataProvider resolvesBearerAuthSchemeProvider - */ + + */ + #[DataProvider('resolvesBearerAuthSchemeProvider')] public function testResolvesBearerAuthScheme( $serviceAuth, $operationAuth, @@ -313,7 +317,6 @@ function () { return []; } /** * Test auth select is done based on user's provided auth schemes. * - * @dataProvider authSelectionBasedOnUserPreferenceProvider * * @param array $supportedAuthSchemes * @param array|null $serviceAuthSchemes @@ -322,7 +325,9 @@ function () { return []; } * @param string $expected * * @return void - */ + + */ + #[DataProvider('authSelectionBasedOnUserPreferenceProvider')] public function testAuthSelectionBasedOnUserPreference( array $supportedAuthSchemes, ?array $serviceAuthSchemes, diff --git a/tests/AwsClientTest.php b/tests/AwsClientTest.php index 54708b7de2..9076eed1ee 100644 --- a/tests/AwsClientTest.php +++ b/tests/AwsClientTest.php @@ -27,10 +27,13 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\AwsClient + */ +#[CoversClass(AwsClient::class)] class AwsClientTest extends TestCase { use UsesServiceTrait; @@ -359,8 +362,9 @@ public function testDoesNotSignOperationsWithAnAuthTypeOfNone() * @param array $expectedHeaders * @param array $expectedHeaderValues * - * @dataProvider signOperationsWithAnAuthTypeProvider - */ + + */ + #[DataProvider('signOperationsWithAnAuthTypeProvider')] public function testSignOperationsWithAnAuthType( array $serviceDefinition, array $clientArguments, @@ -788,9 +792,10 @@ public function testAppliesConfiguredSignatureVersionViaClientConfig() { } /** - * @dataProvider signingRegionSetProvider * @runInSeparateProcess - */ + + */ + #[DataProvider('signingRegionSetProvider')] public function testSigningRegionSetResolution( $command, $env, diff --git a/tests/Build/Changelog/ChangelogBuilderTest.php b/tests/Build/Changelog/ChangelogBuilderTest.php index 1ca3b5de42..79b3dc0778 100644 --- a/tests/Build/Changelog/ChangelogBuilderTest.php +++ b/tests/Build/Changelog/ChangelogBuilderTest.php @@ -3,10 +3,12 @@ use Aws\Build\Changelog\ChangelogBuilder; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Build\Changelog\ChangelogBuilder + */ +#[CoversClass(ChangelogBuilder::class)] class ChangelogBuilderTest extends TestCase { private static $resourceDir = 'tests/Build/Changelog/resources/'; diff --git a/tests/Build/Docs/CodeSnippetGeneratorTest.php b/tests/Build/Docs/CodeSnippetGeneratorTest.php index 8026aa081c..0531fb611d 100644 --- a/tests/Build/Docs/CodeSnippetGeneratorTest.php +++ b/tests/Build/Docs/CodeSnippetGeneratorTest.php @@ -6,18 +6,20 @@ use Aws\Api\Service; use Aws\Build\Docs\CodeSnippetGenerator; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class CodeSnippetGeneratorTest extends TestCase { /** - * @dataProvider exampleProvider * * @param Service $service * @param string $operation * @param array $input * @param string $expected * @param bool $isInput - */ + + */ + #[DataProvider('exampleProvider')] public function testCanBuildCodeExamples( Service $service, $operation, diff --git a/tests/ClientResolverTest.php b/tests/ClientResolverTest.php index 3c0174b882..51f2db1c43 100644 --- a/tests/ClientResolverTest.php +++ b/tests/ClientResolverTest.php @@ -22,10 +22,13 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\ClientResolver + */ +#[CoversClass(ClientResolver::class)] class ClientResolverTest extends TestCase { use UsesServiceTrait; @@ -579,14 +582,15 @@ public function testCanPassStsRegionalEndpointsToEndpointProvider() } /** - * @dataProvider dualStackEndpointCases * * @param $service * @param $useDualstackEndpoint * @param $useFipsEndpoint * @param $region * @param $expectedEndpoint - */ + + */ + #[DataProvider('dualStackEndpointCases')] public function testDualstackEndpoints( $service, $useDualstackEndpoint, @@ -665,11 +669,12 @@ public function testDualstackEndpointFailureOnDualstackNotSupported() } /** - * @dataProvider s3EndpointCases * * @param $config * @param $endpoint - */ + + */ + #[DataProvider('s3EndpointCases')] public function testCanPassS3RegionalEndpointToEndpointProvider($config, $endpoint) { $data = json_decode( @@ -848,10 +853,11 @@ public function testAppliesUserAgent() } /** - * @dataProvider statValueProvider * @param bool|array $userValue * @param array $resolvedValue - */ + + */ + #[DataProvider('statValueProvider')] public function testAcceptsBooleansAndArraysForSelectiveStatCollection($userValue, array $resolvedValue) { $list = new HandlerList; @@ -890,13 +896,14 @@ public static function statValueProvider() } /** - * @dataProvider endpointProviderReturnProvider * * @param array $args * @param string $argName * @param string $expected * @param string $override - */ + + */ + #[DataProvider('endpointProviderReturnProvider')] public function testResolvesValuesReturnedByEndpointProvider( array $args, $argName, @@ -955,12 +962,13 @@ public static function endpointProviderReturnProvider() /** - * @dataProvider partitionReturnProvider * * @param array $args * @param string $argName * @param string $expected - */ + + */ + #[DataProvider('partitionReturnProvider')] public function testSigningValuesAreFetchedFromPartition( array $args, $argName, @@ -1004,11 +1012,12 @@ public static function partitionReturnProvider() } /** - * @dataProvider idempotencyAutoFillProvider * * @param mixed $value * @param bool $shouldAddIdempotencyMiddleware - */ + + */ + #[DataProvider('idempotencyAutoFillProvider')] public function testIdempotencyTokenMiddlewareAddedAsAppropriate( $value, $shouldAddIdempotencyMiddleware @@ -1040,11 +1049,12 @@ public static function idempotencyAutoFillProvider() } /** - * @dataProvider validateRegionProvider * * @param $region * @param $expected - */ + + */ + #[DataProvider('validateRegionProvider')] public function testValidatesRegion($region, $expected) { $resolver = new ClientResolver(ClientResolver::getDefaultArguments()); @@ -1096,8 +1106,9 @@ public static function invalidDisableRequestCompressionValues() } /** - * @dataProvider invalidDisableRequestCompressionValues - */ + + */ + #[DataProvider('invalidDisableRequestCompressionValues')] public function testInvalidDisableRequestCompressionTypeThrowsException($invalidType) { $this->expectException(\InvalidArgumentException::class); @@ -1141,8 +1152,9 @@ public static function invalidMinCompressionSizeValues() } /** - * @dataProvider invalidMinCompressionSizeValues - */ + + */ + #[DataProvider('invalidMinCompressionSizeValues')] public function testInvalidMinCompressionSizeValues($invalidType) { $this->expectException(\InvalidArgumentException::class); @@ -1173,14 +1185,15 @@ public function testMinCompressionSizeDefault() } /** - * @dataProvider configResolutionProvider * * @param $ini * @param $env * @param $expected * @param $configKey * @param $configType - */ + + */ + #[DataProvider('configResolutionProvider')] public function testConfigResolutionOrder($ini, $env, $expected, $configKey, $configType) { $dir = sys_get_temp_dir() . '/.aws'; @@ -1526,8 +1539,9 @@ public function testResolveFromEnvIniUseAwsSharedFiles(): void * @param string|null $env * @return void * - * @dataProvider resolvesAuthSchemePreferenceProvider - */ + + */ + #[DataProvider('resolvesAuthSchemePreferenceProvider')] public function testResolvesAuthSchemePreference( bool $isExpected, array $expectedValue, diff --git a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php index 291878432d..23395435b5 100644 --- a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php +++ b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php @@ -13,11 +13,13 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\ClientSideMonitoring\ApiCallAttemptMonitoringMiddleware - * @covers Aws\ClientSideMonitoring\AbstractMonitoringMiddleware + */ +#[CoversClass(ApiCallAttemptMonitoringMiddleware::class)] +#[CoversClass(ApiCallAttemptMonitoringMiddleware::class)] class ApiCallAttemptMonitoringMiddlewareTest extends TestCase { use MonitoringMiddlewareTestingTrait; diff --git a/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php b/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php index aba2473439..d9cf9363c7 100644 --- a/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php +++ b/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php @@ -10,11 +10,13 @@ use Aws\Exception\AwsException; use GuzzleHttp\Psr7\Request; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\ClientSideMonitoring\ApiCallMonitoringMiddleware - * @covers Aws\ClientSideMonitoring\AbstractMonitoringMiddleware + */ +#[CoversClass(ApiCallMonitoringMiddleware::class)] +#[CoversClass(ApiCallMonitoringMiddleware::class)] class ApiCallMonitoringMiddlewareTest extends TestCase { use MonitoringMiddlewareTestingTrait; diff --git a/tests/ClientSideMonitoring/ConfigurationProviderTest.php b/tests/ClientSideMonitoring/ConfigurationProviderTest.php index 1c8a5d9526..4356bad747 100644 --- a/tests/ClientSideMonitoring/ConfigurationProviderTest.php +++ b/tests/ClientSideMonitoring/ConfigurationProviderTest.php @@ -10,11 +10,14 @@ use Aws\LruArrayCache; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\ClientSideMonitoring\ConfigurationProvider + */ +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -470,10 +473,11 @@ function() use ($expected) { } /** - * @dataProvider getSuccessfulUnwrapData * @param $toUnwrap * @param ConfigurationInterface $expected - */ + + */ + #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { $this->assertSame( diff --git a/tests/ClientSideMonitoring/ConfigurationTest.php b/tests/ClientSideMonitoring/ConfigurationTest.php index 6add824ee4..2dc3736318 100644 --- a/tests/ClientSideMonitoring/ConfigurationTest.php +++ b/tests/ClientSideMonitoring/ConfigurationTest.php @@ -5,11 +5,13 @@ use Aws\ClientSideMonitoring\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Log\InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\ClientSideMonitoring\Configuration + */ +#[CoversClass(\Aws\ClientSideMonitoring\Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/CloudFront/CloudFrontClientTest.php b/tests/CloudFront/CloudFrontClientTest.php index 04d2cd12c7..5c8e74298a 100644 --- a/tests/CloudFront/CloudFrontClientTest.php +++ b/tests/CloudFront/CloudFrontClientTest.php @@ -4,10 +4,12 @@ use Aws\CloudFront\CloudFrontClient; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\CloudFront\CloudFrontClient + */ +#[CoversClass(CloudFrontClient::class)] class CloudFrontClientTest extends TestCase { protected $key; diff --git a/tests/CloudFront/SignerTest.php b/tests/CloudFront/SignerTest.php index b14d22acaf..a20565ca10 100644 --- a/tests/CloudFront/SignerTest.php +++ b/tests/CloudFront/SignerTest.php @@ -3,6 +3,7 @@ use Aws\CloudFront\Signer; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class SignerTest extends TestCase { @@ -88,8 +89,9 @@ public static function getExpiresCases() } /** - * @dataProvider getExpiresCases - */ + + */ + #[DataProvider('getExpiresCases')] public function testReturnsExpiresForCannedPolicies($expires) { $signature = $this->instance->getSignature('test.mp4', $expires); @@ -138,11 +140,12 @@ public function testPolicyContainsNoForbiddenCharacters() } /** - * @dataProvider cannedPolicyParameterProvider * * @param string $resource * @param int $ts - */ + + */ + #[DataProvider('cannedPolicyParameterProvider')] public function testCreatesCannedPolicies($resource, $ts) { $m = new \ReflectionMethod(Signer::class, 'createCannedPolicy'); diff --git a/tests/CloudFront/UrlSignerTest.php b/tests/CloudFront/UrlSignerTest.php index 1532ea907f..c8783378c2 100644 --- a/tests/CloudFront/UrlSignerTest.php +++ b/tests/CloudFront/UrlSignerTest.php @@ -6,10 +6,13 @@ use Aws\CloudFront\UrlSigner; use GuzzleHttp\Psr7\Uri; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\CloudFront\UrlSigner + */ +#[CoversClass(UrlSigner::class)] class UrlSignerTest extends TestCase { protected $key; @@ -132,11 +135,12 @@ public function testEnsuresUriSchemeIsPresent() } /** - * @dataProvider urlAndResourceProvider * * @param string $url * @param string $resource - */ + + */ + #[DataProvider('urlAndResourceProvider')] public function testIsolatesResourceIUrls($url, $resource) { $s = new UrlSigner('a', $this->key); diff --git a/tests/CloudSearchDomain/CloudSearchDomainTest.php b/tests/CloudSearchDomain/CloudSearchDomainTest.php index 6ba8816612..1051a6de3f 100644 --- a/tests/CloudSearchDomain/CloudSearchDomainTest.php +++ b/tests/CloudSearchDomain/CloudSearchDomainTest.php @@ -4,10 +4,12 @@ use Aws\CloudSearchDomain\CloudSearchDomainClient; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\CloudSearchDomain\CloudSearchDomainClient + */ +#[CoversClass(CloudSearchDomainClient::class)] class CloudSearchDomainTest extends TestCase { public function testRequiresEndpoint() diff --git a/tests/CloudTrail/LogFileIteratorTest.php b/tests/CloudTrail/LogFileIteratorTest.php index c040424817..f9612321f0 100644 --- a/tests/CloudTrail/LogFileIteratorTest.php +++ b/tests/CloudTrail/LogFileIteratorTest.php @@ -9,10 +9,12 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\CloudTrail\LogFileIterator + */ +#[CoversClass(LogFileIterator::class)] class LogFileIteratorTest extends TestCase { use UsesServiceTrait; diff --git a/tests/CloudTrail/LogFileReaderTest.php b/tests/CloudTrail/LogFileReaderTest.php index 2e4ea17e49..43ad3d4185 100644 --- a/tests/CloudTrail/LogFileReaderTest.php +++ b/tests/CloudTrail/LogFileReaderTest.php @@ -5,17 +5,21 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\CloudTrail\LogFileReader + */ +#[CoversClass(LogFileReader::class)] class LogFileReaderTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider dataForLogReadingTest - */ + + */ + #[DataProvider('dataForLogReadingTest')] public function testCorrectlyReadsLogFiles($responseBody, $recordCount) { $s3Client = $this->getTestClient('s3', [ diff --git a/tests/CloudTrail/LogRecordIteratorTest.php b/tests/CloudTrail/LogRecordIteratorTest.php index b7fd009355..8ca9ecd6d7 100644 --- a/tests/CloudTrail/LogRecordIteratorTest.php +++ b/tests/CloudTrail/LogRecordIteratorTest.php @@ -9,10 +9,12 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\CloudTrail\LogRecordIterator + */ +#[CoversClass(LogRecordIterator::class)] class LogRecordIteratorTest extends TestCase { use UsesServiceTrait; diff --git a/tests/CommandPoolTest.php b/tests/CommandPoolTest.php index 97925fa9d9..fee7724dc7 100644 --- a/tests/CommandPoolTest.php +++ b/tests/CommandPoolTest.php @@ -6,10 +6,12 @@ use Aws\Exception\AwsException; use Aws\Result; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\CommandPool + */ +#[CoversClass(CommandPool::class)] class CommandPoolTest extends TestCase { use UsesServiceTrait; diff --git a/tests/CommandTest.php b/tests/CommandTest.php index df2bcb444e..2ac169d445 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -5,11 +5,13 @@ use Aws\HandlerList; use Aws\MetricsBuilder; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Command - * @covers Aws\HasDataTrait + */ +#[CoversClass(Command::class)] +#[CoversClass(Command::class)] class CommandTest extends TestCase { public function testHasName() @@ -97,26 +99,39 @@ public function testCanAccessLikeArray() public function testGetAuthSchemesEmitsWarning() { - $this->expectWarning(); - $this->expectWarningMessage( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( 'Aws\Command::getAuthSchemes is deprecated. Auth schemes resolved using the service' .' `auth` trait or via endpoint resolution can now be found in the command `@context` property.' ); - - $c = new Command('foo', ['bar' => 'baz', 'qux' => 'boo']); - $c->getAuthSchemes(); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); + try { + $c = new Command('foo', ['bar' => 'baz', 'qux' => 'boo']); + $c->getAuthSchemes(); + } finally { + restore_error_handler(); + } } public function testSetAuthSchemesEmitsWarning() { - $this->expectWarning(); - $this->expectWarningMessage( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( 'Aws\Command::setAuthSchemes is deprecated. Auth schemes resolved using the service' .' `auth` trait or via endpoint resolution are now set in the command `@context` property.' ); - $c = new Command('foo', ['bar' => 'baz', 'qux' => 'boo']); - $c->setAuthSchemes([]); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); + try { + $c = new Command('foo', ['bar' => 'baz', 'qux' => 'boo']); + $c->setAuthSchemes([]); + } finally { + restore_error_handler(); + } } public function testInitializeMetricsBuilderObject() diff --git a/tests/ConfigurationResolverTest.php b/tests/ConfigurationResolverTest.php index 4f758c9c20..8471344e31 100644 --- a/tests/ConfigurationResolverTest.php +++ b/tests/ConfigurationResolverTest.php @@ -3,6 +3,7 @@ use Aws\Configuration\ConfigurationResolver; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ConfigurationResolverTest extends TestCase { @@ -91,8 +92,9 @@ public static function getEnvValues() } /** - * @dataProvider getEnvValues - */ + + */ + #[DataProvider('getEnvValues')] public function testRetrievesAndConvertsEnvironmentVariables($envValue, $type, $expected) { $this->clearEnv(); @@ -135,8 +137,9 @@ public function iniFileProvider() } /** - * @dataProvider IniFileProvider - */ + + */ + #[DataProvider('IniFileProvider')] public function testResolvesFromIniFileWithDefaultProfile($iniFile, $type, $expected) { $dir = $this->clearEnv(); @@ -148,8 +151,9 @@ public function testResolvesFromIniFileWithDefaultProfile($iniFile, $type, $expe } /** - * @dataProvider IniFileProvider - */ + + */ + #[DataProvider('IniFileProvider')] public function testCreatesFromIniFileWithDifferentDefaultFilename($iniFile, $type, $expected) { $dir = $this->clearEnv(); @@ -174,8 +178,9 @@ public function iniFileWithAltProfileProvider() } /** - * @dataProvider IniFileWIthAltProfileProvider - */ + + */ + #[DataProvider('IniFileWIthAltProfileProvider')] public function testCreatesFromIniFileWithSpecifiedProfile($iniFile, $type, $expected) { $dir = $this->clearEnv(); @@ -345,8 +350,9 @@ public function testResolvesServiceIni() } /** - * @dataProvider duplicateIniFileProvider - */ + + */ + #[DataProvider('duplicateIniFileProvider')] public function testResolvesServiceIniWithDuplicateSections($ini) { $dir = $this->clearEnv(); diff --git a/tests/Credentials/AssumeRoleCredentialProviderTest.php b/tests/Credentials/AssumeRoleCredentialProviderTest.php index 1d9c63169a..580c5261fc 100644 --- a/tests/Credentials/AssumeRoleCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleCredentialProviderTest.php @@ -12,10 +12,13 @@ use GuzzleHttp\Promise\RejectedPromise; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Credentials\AssumeRoleCredentialProvider + */ +#[CoversClass(\Aws\Credentials\AssumeRoleCredentialProvider::class)] class AssumeRoleCredentialProviderTest extends TestCase { const SAMPLE_ROLE_ARN = 'arn:aws:iam::012345678910:role/role_name'; @@ -23,10 +26,11 @@ class AssumeRoleCredentialProviderTest extends TestCase use UsesServiceTrait; /** - * @dataProvider insufficientArguments * * @param array $config - */ + + */ + #[DataProvider('insufficientArguments')] public function testEnsureSourceProfileProvidedForAssumeRole($config) { $this->expectExceptionMessage("Missing required 'AssumeRoleCredentialProvider' configuration option:"); @@ -35,8 +39,9 @@ public function testEnsureSourceProfileProvidedForAssumeRole($config) } /** - * @dataProvider insufficientArguments - */ + + */ + #[DataProvider('insufficientArguments')] public static function insufficientArguments() { $client = [ diff --git a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php index 1e99253bc0..0a179a3c1e 100644 --- a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php @@ -4,7 +4,6 @@ use Aws\Arn\ArnParser; use Aws\Command; use Aws\Credentials\AssumeRoleWithWebIdentityCredentialProvider; -use Aws\Credentials\Credentials; use Aws\Exception\AwsException; use Aws\Middleware; use Aws\Result; @@ -15,10 +14,13 @@ use GuzzleHttp\Promise\RejectedPromise; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Credentials\AssumeRoleWithWebIdentityCredentialProvider + */ +#[CoversClass(AssumeRoleWithWebIdentityCredentialProvider::class)] class AssumeRoleWithWebIdentityCredentialProviderTest extends TestCase { const SAMPLE_ROLE_ARN = 'arn:aws:iam::123456789012:role/role_name'; @@ -402,8 +404,9 @@ public function testCanDisableInvalidIdentityTokenRetries() /** * Tests region precedence: config > env var > fallback - * @dataProvider regionPrecedenceProvider - */ + + */ + #[DataProvider('regionPrecedenceProvider')] public function testRegionPrecedence( ?string $configRegion, ?string $envRegion, @@ -433,8 +436,11 @@ public function testRegionPrecedence( } if ($expectNotice) { - $this->expectNotice(); - $this->expectNoticeMessage( + set_error_handler(function ($errno, $errstr) use ($config) { + throw new \RuntimeException($errstr, $errno); + }); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( 'NOTICE: STS client created without explicit `region` configuration.' ); } @@ -457,6 +463,10 @@ public function testRegionPrecedence( } else { putenv("AWS_REGION"); } + + if ($expectNotice) { + restore_error_handler(); + } } } @@ -472,8 +482,9 @@ public static function regionPrecedenceProvider(): array /** * Tests that correct endpoints are called - * @dataProvider endpointProvider - */ + + */ + #[DataProvider('endpointProvider')] public function testEndpointSelection( string $region, string $expectedEndpoint diff --git a/tests/Credentials/CredentialProviderTest.php b/tests/Credentials/CredentialProviderTest.php index 9cb5a36342..89f8495ad0 100644 --- a/tests/Credentials/CredentialProviderTest.php +++ b/tests/Credentials/CredentialProviderTest.php @@ -21,10 +21,13 @@ use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Credentials\CredentialProvider + */ +#[CoversClass(CredentialProvider::class)] class CredentialProviderTest extends TestCase { use UsesServiceTrait; @@ -281,8 +284,9 @@ public function testCreatesFromEnvironmentVariablesNullToken(): void } /** - * @dataProvider iniFileProvider - */ + + */ + #[DataProvider('iniFileProvider')] public function testCreatesFromIniFile( string $iniFile, Credentials $expectedCreds @@ -768,10 +772,13 @@ public function testCreatesFromRoleArn(): void public function testCreatesFromRoleArnWithSourceProfileEmitsNoticeOnFallbackRegion(): void { - $this->expectNotice(); - $this->expectNoticeMessage( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( 'NOTICE: STS client created without explicit `region` configuration' ); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); $awsDir = $this->createAwsHome(); $ini = <<wait(); + try { + file_put_contents($awsDir . '/credentials', $ini); + call_user_func(CredentialProvider::ini('assume', null))->wait(); + } finally { + restore_error_handler(); + } } public function testCreatesFromRoleArnWithCredentialSourceEmitsNoticeOnFallbackRegion(): void { - $this->expectNotice(); - $this->expectNoticeMessage( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( 'NOTICE: STS client created without explicit `region` configuration' ); - + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); $awsDir = $this->createAwsHome(); $ini = <<wait(); + call_user_func(CredentialProvider::ini('assume-with-credential-source', null))->wait(); + } finally { + restore_error_handler(); + } } public function testCreatesFromRoleArnCatchesCircular(): void @@ -1929,8 +1946,9 @@ public function testProcessCredentialConfigDefaultChain(): void } /** - * @dataProvider shouldUseEcsProvider - */ + + */ + #[DataProvider('shouldUseEcsProvider')] public function testShouldUseEcs( string $relative, string $serverRelative, @@ -2722,8 +2740,9 @@ public function testLoginUsedFromCacheInDefaultChain(): void } /** - * @dataProvider loginInvalidCacheProvider - */ + + */ + #[DataProvider('loginInvalidCacheProvider')] public function testLoginWithInvalidCache( string $cacheContent, string $expectedMessage, diff --git a/tests/Credentials/CredentialsTest.php b/tests/Credentials/CredentialsTest.php index eea715e5d8..43fc2bab12 100644 --- a/tests/Credentials/CredentialsTest.php +++ b/tests/Credentials/CredentialsTest.php @@ -7,10 +7,12 @@ use Aws\Identity\AwsCredentialIdentityInterface; use Aws\Identity\IdentityInterface; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Credentials\Credentials + */ +#[CoversClass(\Aws\Credentials\Credentials::class)] class CredentialsTest extends TestCase { public function testHasGetters() diff --git a/tests/Credentials/CredentialsUtilsTest.php b/tests/Credentials/CredentialsUtilsTest.php index 03c9b7a18c..5653a10ec9 100644 --- a/tests/Credentials/CredentialsUtilsTest.php +++ b/tests/Credentials/CredentialsUtilsTest.php @@ -3,10 +3,13 @@ use Aws\Credentials\CredentialsUtils; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Credentials\CredentialsUtils + */ +#[CoversClass(\Aws\Credentials\CredentialsUtils::class)] class CredentialsUtilsTest extends TestCase { @@ -14,8 +17,9 @@ class CredentialsUtilsTest extends TestCase * @param string $host * @param bool $expectedResult * - * @dataProvider loopBackAddressCasesProvider - */ + + */ + #[DataProvider('loopBackAddressCasesProvider')] public function testLoopBackAddressCases(string $host, bool $expectedResult) { $isLoopBack = CredentialsUtils::isLoopBackAddress($host); diff --git a/tests/Credentials/EcsCredentialProviderTest.php b/tests/Credentials/EcsCredentialProviderTest.php index e65b8aee75..5647704e2c 100644 --- a/tests/Credentials/EcsCredentialProviderTest.php +++ b/tests/Credentials/EcsCredentialProviderTest.php @@ -17,10 +17,13 @@ use GuzzleHttp\Ring\Future\CompletedFutureArray; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Credentials\EcsCredentialProvider + */ +#[CoversClass(\Aws\Credentials\EcsCredentialProvider::class)] class EcsCredentialProviderTest extends TestCase { private $uripath; @@ -145,8 +148,9 @@ public function testNoProxying() } /** - * @dataProvider uriAndTokenResolutionProvider - */ + + */ + #[DataProvider('uriAndTokenResolutionProvider')] public function testUriAndTokenResolution($case) { $dir = $this->clearEnv(); @@ -364,12 +368,13 @@ public function testResolveCredentialsWithAccountIdFromArn() } /** - * @dataProvider successDataProvider * * @param array $clientDef * @param CredentialsInterface $expected * @throws GuzzleException - */ + + */ + #[DataProvider('successDataProvider')] public function testHandlesSuccessScenarios( array $clientDef, CredentialsInterface $expected @@ -459,13 +464,14 @@ public static function successDataProvider(): array } /** - * @dataProvider failureDataProvider * * @param $client * @param \Exception $expected * * @throws GuzzleException - */ + + */ + #[DataProvider('failureDataProvider')] public function testHandlesFailureScenarios( array $responses, \Exception $expected diff --git a/tests/Credentials/InstanceProfileProviderTest.php b/tests/Credentials/InstanceProfileProviderTest.php index fff0796620..4f7575e47d 100644 --- a/tests/Credentials/InstanceProfileProviderTest.php +++ b/tests/Credentials/InstanceProfileProviderTest.php @@ -17,10 +17,13 @@ use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Credentials\InstanceProfileProvider + */ +#[CoversClass(InstanceProfileProvider::class)] class InstanceProfileProviderTest extends TestCase { private $originalEnv = []; @@ -310,12 +313,13 @@ private static function getInsecureTestClient( } /** - * @dataProvider successDataProvider * * @param array $clientDefinition * @param CredentialsInterface $expected * @param int|null $expectedAttempts - */ + + */ + #[DataProvider('successDataProvider')] public function testHandlesSuccessScenarios( array $clientDefinition, CredentialsInterface $expected, @@ -554,11 +558,12 @@ public static function successDataProvider(): \Generator } /** - * @dataProvider failureDataProvider * * @param array $clientDefinition * @param \Exception $expected - */ + + */ + #[DataProvider('failureDataProvider')] public function testHandlesFailureScenarios( array $clientDefinition, \Exception $expected @@ -1003,48 +1008,56 @@ public function testRetriesEnvVarIsUsed() } /** - * @dataProvider returnsExpiredCredsProvider * * @param $client - */ + + */ + #[DataProvider('returnsExpiredCredsProvider')] public function testExtendsExpirationAndSendsRequestIfImdsYieldsExpiredCreds($client) { //expect warning emitted from extension - $this->expectWarning(); - $this->expectWarningMessageMatches( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessageMatches( '/Attempting credential expiration extension/' ); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }, E_USER_WARNING); - $provider = new InstanceProfileProvider([ - 'client' => $client - ]); - $creds = $provider()->wait(); + try { + $provider = new InstanceProfileProvider([ + 'client' => $client + ]); + $creds = $provider()->wait(); - $this->assertSame('foo', $creds->getAccessKeyId()); - $this->assertSame('baz', $creds->getSecretKey()); - $this->assertFalse($creds->isExpired()); + $this->assertSame('foo', $creds->getAccessKeyId()); + $this->assertSame('baz', $creds->getSecretKey()); + $this->assertFalse($creds->isExpired()); - $requestHandler = new MockHandler([ - new Result(['message' => 'Request sent']), - new Result(['message' => 'Request sent']), - new Result(['message' => 'Request sent']) - ]); + $requestHandler = new MockHandler([ + new Result(['message' => 'Request sent']), + new Result(['message' => 'Request sent']), + new Result(['message' => 'Request sent']) + ]); - $s3Client = new S3Client([ - 'region' => 'us-west-2', - 'version' => 'latest', - 'credentials' => $creds, - 'handler' => $requestHandler - ]); - $s3Client->listBuckets(); - $s3Client->listBuckets(); - $result = $s3Client->listBuckets(); + $s3Client = new S3Client([ + 'region' => 'us-west-2', + 'version' => 'latest', + 'credentials' => $creds, + 'handler' => $requestHandler + ]); + $s3Client->listBuckets(); + $s3Client->listBuckets(); + $result = $s3Client->listBuckets(); - $this->assertEquals('Request sent', $result['message']); - $this->assertLessThanOrEqual(3,$this->getPropertyValue($provider,'attempts')); + $this->assertEquals('Request sent', $result['message']); + $this->assertLessThanOrEqual(3,$this->getPropertyValue($provider,'attempts')); + } finally { + restore_error_handler(); + } } - public static function returnsExpiredCredsProvider() + public static function returnsExpiredCredsProvider(): array { $expiredTime = time() - 1000; $expiredCreds = ['foo', 'baz', null, "@{$expiredTime}"]; @@ -1085,48 +1098,55 @@ public static function returnsExpiredCredsProvider() } /** - * @dataProvider imdsUnavailableProvider * * @param $client - */ + + */ + #[DataProvider('imdsUnavailableProvider')] public function testExtendsExpirationAndSendsRequestIfImdsUnavailable($client) { //expect warning emitted from extension - $this->expectWarning(); - $this->expectWarningMessageMatches( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessageMatches( '/Attempting credential expiration extension/' ); - + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); $expiredTime = time() - 1000; $expiredCreds = new Credentials('foo', 'baz', null, $expiredTime); - $this->assertTrue($expiredCreds->isExpired()); + try { + $this->assertTrue($expiredCreds->isExpired()); - $provider = new InstanceProfileProvider([ - 'client' => $client - ]); - $creds = $provider($expiredCreds)->wait(); - $this->assertSame('foo', $creds->getAccessKeyId()); - $this->assertSame('baz', $creds->getSecretKey()); - $this->assertFalse($expiredCreds->isExpired()); - - $requestHandler = new MockHandler([ - new Result(['message' => 'Request sent']), - new Result(['message' => 'Request sent']), - new Result(['message' => 'Request sent']) - ]); + $provider = new InstanceProfileProvider([ + 'client' => $client + ]); + $creds = $provider($expiredCreds)->wait(); + $this->assertSame('foo', $creds->getAccessKeyId()); + $this->assertSame('baz', $creds->getSecretKey()); + $this->assertFalse($expiredCreds->isExpired()); + + $requestHandler = new MockHandler([ + new Result(['message' => 'Request sent']), + new Result(['message' => 'Request sent']), + new Result(['message' => 'Request sent']) + ]); - $s3Client = new S3Client([ - 'region' => 'us-west-2', - 'version' => 'latest', - 'credentials' => $creds, - 'handler' => $requestHandler - ]); - $s3Client -> listBuckets(); - $s3Client -> listBuckets(); - $result = $s3Client->listBuckets(); + $s3Client = new S3Client([ + 'region' => 'us-west-2', + 'version' => 'latest', + 'credentials' => $creds, + 'handler' => $requestHandler + ]); + $s3Client -> listBuckets(); + $s3Client -> listBuckets(); + $result = $s3Client->listBuckets(); - $this->assertEquals('Request sent', $result['message']); - $this->assertLessThanOrEqual(3,$this->getPropertyValue($provider,'attempts')); + $this->assertEquals('Request sent', $result['message']); + $this->assertLessThanOrEqual(3,$this->getPropertyValue($provider,'attempts')); + } finally { + restore_error_handler(); + } } public static function imdsUnavailableProvider() @@ -1390,8 +1410,9 @@ private function fetchMockedCredentialsAndAlwaysExpectAToken($config=[]) { * @param string $expectedEndpointMode this parameter is the endpoint mode that is expected to be resolved by * the credential provider. * - * @dataProvider endpointModeCasesProvider - */ + + */ + #[DataProvider('endpointModeCasesProvider')] public function testEndpointModeResolution( ?string $endpointModeClientConfig, ?string $endpointModeEnv, @@ -1515,8 +1536,9 @@ public static function endpointModeCasesProvider() : array * @param string $expectedEndpoint this parameter is the endpoint that is expected to be resolved * by the credential provider. * - * @dataProvider endpointCasesProvider - */ + + */ + #[DataProvider('endpointCasesProvider')] public function testEndpointResolution( string $endpointMode, ?string $endpointEnv, diff --git a/tests/Credentials/LoginCredentialProviderTest.php b/tests/Credentials/LoginCredentialProviderTest.php index b63440ab21..c0cf4ffbca 100644 --- a/tests/Credentials/LoginCredentialProviderTest.php +++ b/tests/Credentials/LoginCredentialProviderTest.php @@ -11,10 +11,13 @@ use Aws\Signin\Exception\SigninException; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Credentials\LoginCredentialProvider + */ +#[CoversClass(LoginCredentialProvider::class)] class LoginCredentialProviderTest extends TestCase { use UsesServiceTrait; @@ -302,8 +305,9 @@ public function testLoadTokenFailsWithInvalidJson(): void } /** - * @dataProvider missingCacheKeysProvider - */ + + */ + #[DataProvider('missingCacheKeysProvider')] public function testLoadTokenFailsWithMissingOrEmptyCacheKeys( array $tokenData, string $expectedMessage @@ -1250,8 +1254,9 @@ public function testLoadCredentialsWithSpecifiedCurveKey(): void } /** - * @dataProvider loginTestCasesProvider - */ + + */ + #[DataProvider('loginTestCasesProvider')] public function testLoginCredentialProviderFromTestCases( string $documentation, string $configContents, @@ -1408,8 +1413,9 @@ public static function loginTestCasesProvider(): \Generator } /** - * @dataProvider externalRefreshProvider - */ + + */ + #[DataProvider('externalRefreshProvider')] public function testExternalRefreshBehavior( string $scenario, int $currentExpiryMinutes, diff --git a/tests/Crypto/AesDecryptingStreamTest.php b/tests/Crypto/AesDecryptingStreamTest.php index da2d03cf22..90e2762a97 100644 --- a/tests/Crypto/AesDecryptingStreamTest.php +++ b/tests/Crypto/AesDecryptingStreamTest.php @@ -7,6 +7,7 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AesDecryptingStreamTest extends TestCase { @@ -16,11 +17,12 @@ class AesDecryptingStreamTest extends TestCase use AesEncryptionStreamTestTrait; /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, CipherMethod $iv @@ -58,11 +60,12 @@ public function testStreamOutputSameAsOpenSSL( } /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testReportsSizeOfPlaintextWherePossible( StreamInterface $plainText, CipherMethod $iv @@ -89,11 +92,12 @@ public function testReportsSizeOfPlaintextWherePossible( } /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testSupportsRewinding( StreamInterface $plainText, CipherMethod $iv @@ -113,10 +117,11 @@ public function testSupportsRewinding( } /** - * @dataProvider cipherMethodProvider * * @param CipherMethod $iv - */ + + */ + #[DataProvider('cipherMethodProvider')] public function testMemoryUsageRemainsConstant(CipherMethod $iv) { $memory = memory_get_usage(); @@ -155,10 +160,11 @@ public function testDoesNotSupportArbitrarySeeking() } /** - * @dataProvider cipherMethodProvider * * @param CipherMethod $cipherMethod - */ + + */ + #[DataProvider('cipherMethodProvider')] public function testReturnsEmptyStringWhenSourceStreamEmpty( CipherMethod $cipherMethod ) { diff --git a/tests/Crypto/AesEncryptingStreamTest.php b/tests/Crypto/AesEncryptingStreamTest.php index 086e52c146..9bf4471326 100644 --- a/tests/Crypto/AesEncryptingStreamTest.php +++ b/tests/Crypto/AesEncryptingStreamTest.php @@ -8,6 +8,7 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AesEncryptingStreamTest extends TestCase { @@ -17,11 +18,12 @@ class AesEncryptingStreamTest extends TestCase use AesEncryptionStreamTestTrait; /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, CipherMethod $iv @@ -43,11 +45,12 @@ public function testStreamOutputSameAsOpenSSL( } /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testGetOpenSslName( StreamInterface $plainText, CipherMethod $iv @@ -63,11 +66,12 @@ public function testGetOpenSslName( } /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testGetCurrentIv( StreamInterface $plainText, CipherMethod $iv @@ -83,11 +87,12 @@ public function testGetCurrentIv( } /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testSupportsRewinding( StreamInterface $plainText, CipherMethod $iv @@ -100,11 +105,12 @@ public function testSupportsRewinding( } /** - * @dataProvider cartesianJoinInputCipherMethodProvider * * @param StreamInterface $plainText * @param CipherMethod $iv - */ + + */ + #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testAccuratelyReportsSizeOfCipherText( StreamInterface $plainText, CipherMethod $iv @@ -115,10 +121,11 @@ public function testAccuratelyReportsSizeOfCipherText( } /** - * @dataProvider cipherMethodProvider * * @param CipherMethod $cipherMethod - */ + + */ + #[DataProvider('cipherMethodProvider')] public function testMemoryUsageRemainsConstant(CipherMethod $cipherMethod) { $memory = memory_get_usage(); @@ -149,10 +156,11 @@ public function testIsNotWritable() } /** - * @dataProvider cipherMethodProvider * * @param CipherMethod $cipherMethod - */ + + */ + #[DataProvider('cipherMethodProvider')] public function testReturnsPaddedOrEmptyStringWhenSourceStreamEmpty( CipherMethod $cipherMethod ) { @@ -169,10 +177,11 @@ public function testReturnsPaddedOrEmptyStringWhenSourceStreamEmpty( } /** - * @dataProvider cipherMethodProvider * * @param CipherMethod $cipherMethod - */ + + */ + #[DataProvider('cipherMethodProvider')] public function testDoesNotSupportSeekingFromEnd(CipherMethod $cipherMethod) { $this->expectException(\LogicException::class); @@ -182,10 +191,11 @@ public function testDoesNotSupportSeekingFromEnd(CipherMethod $cipherMethod) } /** - * @dataProvider seekableCipherMethodProvider * * @param CipherMethod $cipherMethod - */ + + */ + #[DataProvider('seekableCipherMethodProvider')] public function testSupportsSeekingFromCurrentPosition( CipherMethod $cipherMethod ) { diff --git a/tests/Crypto/AesGcmDecryptingStreamTest.php b/tests/Crypto/AesGcmDecryptingStreamTest.php index 6e9ffc57c0..cca92e233d 100644 --- a/tests/Crypto/AesGcmDecryptingStreamTest.php +++ b/tests/Crypto/AesGcmDecryptingStreamTest.php @@ -5,17 +5,19 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AesGcmDecryptingStreamTest extends TestCase { use AesEncryptionStreamTestTrait; /** - * @dataProvider cartesianJoinInputKeySizeProvider * * @param StreamInterface $plainText * @param int $keySize - */ + + */ + #[DataProvider('cartesianJoinInputKeySizeProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, $keySize @@ -55,11 +57,12 @@ public function testStreamOutputSameAsOpenSSL( } /** - * @dataProvider cartesianJoinInputKeySizeProvider * * @param StreamInterface $plainText * @param int $keySize - */ + + */ + #[DataProvider('cartesianJoinInputKeySizeProvider')] public function testThrowsForInvalidTag( StreamInterface $plainText, $keySize diff --git a/tests/Crypto/AesGcmEncryptingStreamTest.php b/tests/Crypto/AesGcmEncryptingStreamTest.php index e02934f53f..d729201c0b 100644 --- a/tests/Crypto/AesGcmEncryptingStreamTest.php +++ b/tests/Crypto/AesGcmEncryptingStreamTest.php @@ -5,17 +5,19 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AesGcmEncryptingStreamTest extends TestCase { use AesEncryptionStreamTestTrait; /** - * @dataProvider cartesianJoinInputKeySizeProvider * * @param StreamInterface $plainText * @param int $keySize - */ + + */ + #[DataProvider('cartesianJoinInputKeySizeProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, $keySize @@ -52,8 +54,9 @@ public function testStreamOutputSameAsOpenSSL( } /** - * @dataProvider encryptDataProvider - */ + + */ + #[DataProvider('encryptDataProvider')] public function testCorrectlyEncryptsData( $plaintext, $key, diff --git a/tests/Crypto/AlgorithmSuiteTest.php b/tests/Crypto/AlgorithmSuiteTest.php index 11a5e490d4..93848d26e5 100644 --- a/tests/Crypto/AlgorithmSuiteTest.php +++ b/tests/Crypto/AlgorithmSuiteTest.php @@ -6,10 +6,13 @@ use Aws\Crypto\MaterialsProviderV3; use Aws\S3\Crypto\S3EncryptionClientV3; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Crypto\AlgorithmSuite + */ +#[CoversClass(\Aws\Crypto\AlgorithmSuite::class)] class AlgorithmSuiteTest extends TestCase { /** @@ -95,8 +98,9 @@ public static function cipherNameProvider(): array /** * Test getCipherName() method - * @dataProvider cipherNameProvider - */ + + */ + #[DataProvider('cipherNameProvider')] public function testGetCipherName(AlgorithmSuite $suite, string $expectedCipher): void { $this->assertSame($expectedCipher, $suite->getCipherName()); @@ -148,8 +152,9 @@ public static function ivLengthProvider(): array /** * Test getIvLengthBits() and getIvLengthBytes() methods - * @dataProvider ivLengthProvider - */ + + */ + #[DataProvider('ivLengthProvider')] public function testGetIvLength(AlgorithmSuite $suite, int $expectedBits, int $expectedBytes): void { $this->assertSame($expectedBits, $suite->getIvLengthBits()); @@ -182,8 +187,9 @@ public static function cipherTagLengthProvider(): array /** * Test getCipherTagLengthBits() and getCipherTagLengthInBytes() methods - * @dataProvider cipherTagLengthProvider - */ + + */ + #[DataProvider('cipherTagLengthProvider')] public function testGetCipherTagLength(AlgorithmSuite $suite, int $expectedBits, int $expectedBytes): void { $this->assertSame($expectedBits, $suite->getCipherTagLengthBits()); @@ -232,8 +238,9 @@ public static function keyDerivationProvider(): array /** * Test key derivation length methods - * @dataProvider keyDerivationProvider - */ + + */ + #[DataProvider('keyDerivationProvider')] public function testGetDerivationKeyLengths( AlgorithmSuite $suite, int $expectedInputBits, @@ -279,8 +286,9 @@ public static function commitmentKeyLengthProvider(): array /** * Test commitment key length methods - * @dataProvider commitmentKeyLengthProvider - */ + + */ + #[DataProvider('commitmentKeyLengthProvider')] public function testGetCommitmentKeyLengths( AlgorithmSuite $suite, int $expectedInputBits, diff --git a/tests/Crypto/EncryptionDecryptionTraitV3Test.php b/tests/Crypto/EncryptionDecryptionTraitV3Test.php index 23d4581cab..61ba00dbe4 100644 --- a/tests/Crypto/EncryptionDecryptionTraitV3Test.php +++ b/tests/Crypto/EncryptionDecryptionTraitV3Test.php @@ -16,11 +16,14 @@ use GuzzleHttp\Psr7\AppendStream; use PHPUnit\Framework\MockObject\MockObject; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Crypto\EncryptionTraitV3 - * @covers \Aws\Crypto\DecryptionTraitV3 + */ +#[CoversClass(\Aws\Crypto\EncryptionTraitV3::class)] +#[CoversClass(\Aws\Crypto\DecryptionTraitV3::class)] class EncryptionDecryptionTraitV3Test extends TestCase { use UsesCryptoParamsTraitV3; @@ -383,9 +386,10 @@ public function testV3EnvelopeECValidSetCorrectly(): void /** * Summary of testDiffAlgorithmSuitesProduceDiffObjectVersions - * @dataProvider getAlgorithmSuites * @return void - */ + + */ + #[DataProvider('getAlgorithmSuites')] public function testDiffAlgorithmSuitesProduceDiffObjectVersions(AlgorithmSuite $algorithmSuite): void { $plaintext = new Stream(fopen('data://text/plain,Hello World', 'r')); @@ -483,8 +487,9 @@ public function testCbcAlgSuiteProducesV2Envelope(): void /** * Given a CommitmentPolicy assert error gets appropriately thrown if the key commitment policy * does not support decryption of the object. - * @dataProvider getCommitmentPolicies - */ + + */ + #[DataProvider('getCommitmentPolicies')] public function testThrowsOnInvalidKCPolicyAndNoKeyCommitmentAlgSuite($commitmentPolicy): void { $plaintext = new Stream(fopen('data://text/plain,Hello World', 'r')); @@ -562,8 +567,9 @@ public function testThrowsOnInvalidKCPolicyAndNoKeyCommitmentAlgSuite($commitmen /** * Given a CommitmentPolicy assert error gets appropriately thrown if the key commitment policy * does not support decryption of the object. - * @dataProvider getCommitmentPolicies - */ + + */ + #[DataProvider('getCommitmentPolicies')] public function testThrowsOnInvalidKCPolicyAndKeyCommitmentAlgSuite($commitmentPolicy): void { $plaintext = new Stream(fopen('data://text/plain,Hello World', 'r')); diff --git a/tests/Crypto/KmsMaterialsProviderTest.php b/tests/Crypto/KmsMaterialsProviderTest.php index 8e961eb1d9..58355e058b 100644 --- a/tests/Crypto/KmsMaterialsProviderTest.php +++ b/tests/Crypto/KmsMaterialsProviderTest.php @@ -6,10 +6,12 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Crypto\KmsMaterialsProvider + */ +#[CoversClass(KmsMaterialsProvider::class)] class KmsMaterialsProviderTest extends TestCase { use UsesServiceTrait; diff --git a/tests/Crypto/KmsMaterialsProviderV2Test.php b/tests/Crypto/KmsMaterialsProviderV2Test.php index 007278f83b..704bfe2dea 100644 --- a/tests/Crypto/KmsMaterialsProviderV2Test.php +++ b/tests/Crypto/KmsMaterialsProviderV2Test.php @@ -7,10 +7,12 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Crypto\KmsMaterialsProviderV2 + */ +#[CoversClass(\Aws\Crypto\KmsMaterialsProviderV2::class)] class KmsMaterialsProviderV2Test extends TestCase { use UsesServiceTrait; diff --git a/tests/Crypto/KmsMaterialsProviderV3Test.php b/tests/Crypto/KmsMaterialsProviderV3Test.php index d0064cbae7..cf25dc06e4 100644 --- a/tests/Crypto/KmsMaterialsProviderV3Test.php +++ b/tests/Crypto/KmsMaterialsProviderV3Test.php @@ -7,10 +7,12 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Crypto\KmsMaterialsProviderV3 + */ +#[CoversClass(\Aws\Crypto\KmsMaterialsProviderV3::class)] class KmsMaterialsProviderV3Test extends TestCase { use UsesServiceTrait; diff --git a/tests/Crypto/MetadataEnvelopeTest.php b/tests/Crypto/MetadataEnvelopeTest.php index 8bd271ae13..50e7846512 100644 --- a/tests/Crypto/MetadataEnvelopeTest.php +++ b/tests/Crypto/MetadataEnvelopeTest.php @@ -3,17 +3,21 @@ use Aws\Crypto\MetadataEnvelope; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Crypto\MetadataEnvelope + */ +#[CoversClass(MetadataEnvelope::class)] class MetadataEnvelopeTest extends TestCase { use UsesMetadataEnvelopeTrait; /** - * @dataProvider getIndividualMetadataFields - */ + + */ + #[DataProvider('getIndividualMetadataFields')] public function testSetsValidFields($field, $value) { $envelope = new MetadataEnvelope(); @@ -23,8 +27,9 @@ public function testSetsValidFields($field, $value) } /** - * @dataProvider getMetadataFields - */ + + */ + #[DataProvider('getMetadataFields')] public function testSetsAllFields($allValidFields) { $envelope = new MetadataEnvelope(); @@ -39,8 +44,9 @@ public function testSetsAllFields($allValidFields) } /** - * @dataProvider getIndividualInvalidMetadataFields - */ + + */ + #[DataProvider('getIndividualInvalidMetadataFields')] public function testThrowsOnInvalidMetadataField($field, $value) { //= ../specification/s3-encryption/data-format/content-metadata.md#determining-s3ec-object-status diff --git a/tests/DSQL/AuthTokenGeneratorTest.php b/tests/DSQL/AuthTokenGeneratorTest.php index 2c49012204..b8353d15c7 100644 --- a/tests/DSQL/AuthTokenGeneratorTest.php +++ b/tests/DSQL/AuthTokenGeneratorTest.php @@ -7,10 +7,13 @@ use GuzzleHttp\Promise; use TypeError; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\DSQL\AuthTokenGenerator + */ +#[CoversClass(AuthTokenGenerator::class)] class AuthTokenGeneratorTest extends TestCase { /** @@ -19,8 +22,9 @@ class AuthTokenGeneratorTest extends TestCase * @param $action * @return void * - * @dataProvider generateAuthTokenProvider - */ + + */ + #[DataProvider('generateAuthTokenProvider')] public function testGeneratesAuthToken($credentials, $action) { $tokenGenerator = new AuthTokenGenerator($credentials); @@ -62,8 +66,9 @@ public static function generateAuthTokenProvider() * @param $region * @return void * - * @dataProvider missingInputProvider - */ + + */ + #[DataProvider('missingInputProvider')] public function testThrowsOnMissingInput($action, $endpoint, $region) { $this->expectException(TypeError::class); @@ -92,8 +97,9 @@ public static function missingInputProvider() * * @return void * - * @dataProvider emptyInputProvider - */ + + */ + #[DataProvider('emptyInputProvider')] public function testThrowsOnEmptyInput($action, $endpoint, $region) { $this->expectException(\InvalidArgumentException::class); @@ -127,10 +133,11 @@ public static function lifetimeFailureProvider() } /** - * @dataProvider lifetimeFailureProvider * * @param $lifetime - */ + + */ + #[DataProvider('lifetimeFailureProvider')] public function testThrowsExceptionWithInvalidLifetime($expiration, $action) { $this->expectExceptionMessage("Lifetime must be a positive number, was"); diff --git a/tests/DefaultsMode/ConfigurationProviderTest.php b/tests/DefaultsMode/ConfigurationProviderTest.php index aa3a9b2b10..fcc3803673 100644 --- a/tests/DefaultsMode/ConfigurationProviderTest.php +++ b/tests/DefaultsMode/ConfigurationProviderTest.php @@ -9,10 +9,13 @@ use Aws\DefaultsMode\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\DefaultsMode\ConfigurationProvider + */ +#[CoversClass(\Aws\DefaultsMode\ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -376,10 +379,11 @@ function () use ($expected) { } /** - * @dataProvider getSuccessfulUnwrapData * @param $toUnwrap * @param ConfigurationInterface $expected - */ + + */ + #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { $this->assertSame( diff --git a/tests/DefaultsMode/ConfigurationTest.php b/tests/DefaultsMode/ConfigurationTest.php index 3460ee8fe9..b0be72488c 100644 --- a/tests/DefaultsMode/ConfigurationTest.php +++ b/tests/DefaultsMode/ConfigurationTest.php @@ -4,10 +4,12 @@ use Aws\DefaultsMode\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\DefaultsMode\Configuration + */ +#[CoversClass(\Aws\DefaultsMode\Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/DocDb/DocDbClientTest.php b/tests/DocDb/DocDbClientTest.php index 202c00a033..64f4743a61 100644 --- a/tests/DocDb/DocDbClientTest.php +++ b/tests/DocDb/DocDbClientTest.php @@ -7,11 +7,14 @@ use Aws\Result; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Signature/sig_hack.php'; /** - * @covers Aws\DocDB\DocDBClient + */ +#[CoversClass(DocDBClient::class)] class DocDbClientTest extends TestCase { public static function set_up_before_class() @@ -36,14 +39,15 @@ public static function DocDbPresignMethodProvider() } /** - * @dataProvider DocDbPresignMethodProvider * * @param string $functionName * @param string $presignedUrl * @param string $sourceRegion * @param string $expectedUrl * @param string $expectedSignature - */ + + */ + #[DataProvider('DocDbPresignMethodProvider')] public function testCorrectPresignDocDbUrls( $functionName, $functionArgs, diff --git a/tests/DynamoDb/DynamoDbClientTest.php b/tests/DynamoDb/DynamoDbClientTest.php index 70cbdabfc1..d1bd925e3e 100644 --- a/tests/DynamoDb/DynamoDbClientTest.php +++ b/tests/DynamoDb/DynamoDbClientTest.php @@ -13,10 +13,13 @@ use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Stream; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\DynamoDb\DynamoDbClient + */ +#[CoversClass(\Aws\DynamoDb\DynamoDbClient::class)] class DynamoDbClientTest extends TestCase { use UsesServiceTrait; @@ -85,8 +88,9 @@ public function dataForFormatValueTest() } /** - * @dataProvider dataProviderRetrySettings - */ + + */ + #[DataProvider('dataProviderRetrySettings')] public function testRetriesOnDynamoSpecificRetryableException($settings) { $params = [ @@ -189,10 +193,11 @@ public function testValidatesAndRetriesCrc32() } /** - * @dataProvider dataProviderRetrySettings * * @param $settings - */ + + */ + #[DataProvider('dataProviderRetrySettings')] public function testAppliesRetryStatsConfig($settings) { $client = new DynamoDbClient([ diff --git a/tests/DynamoDb/LockingSessionConnectionTest.php b/tests/DynamoDb/LockingSessionConnectionTest.php index 1c9993226b..3d711cb2d8 100644 --- a/tests/DynamoDb/LockingSessionConnectionTest.php +++ b/tests/DynamoDb/LockingSessionConnectionTest.php @@ -6,10 +6,12 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\DynamoDb\LockingSessionConnection + */ +#[CoversClass(LockingSessionConnection::class)] class LockingSessionConnectionTest extends TestCase { use UsesServiceTrait; diff --git a/tests/DynamoDb/MarshalerTest.php b/tests/DynamoDb/MarshalerTest.php index 0e1fa1ed02..b4e9dce480 100644 --- a/tests/DynamoDb/MarshalerTest.php +++ b/tests/DynamoDb/MarshalerTest.php @@ -7,17 +7,21 @@ use Aws\DynamoDb\SetValue; use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\DynamoDb\Marshaler + */ +#[CoversClass(Marshaler::class)] class MarshalerTest extends TestCase { const ERROR = 'ERROR'; /** - * @dataProvider getMarshalValueUseCases - */ + + */ + #[DataProvider('getMarshalValueUseCases')] public function testMarshalValueUseCases($value, $expectedResult, $options = []) { $m = new Marshaler($options); @@ -345,8 +349,9 @@ public function testCanWrapLargeNumbersWithOption() } /** - * @covers Aws\DynamoDb\NumberValue - */ + + */ + #[CoversClass(Marshaler::class)] public function testNumberValueCanBeFormattedAndSerialized() { $number = new NumberValue('99999999999999999999'); @@ -355,8 +360,9 @@ public function testNumberValueCanBeFormattedAndSerialized() } /** - * @covers Aws\DynamoDb\BinaryValue - */ + + */ + #[CoversClass(Marshaler::class)] public function testBinaryValueCanBeFormattedAndSerialized() { $resource = fopen('php://temp', 'w+'); @@ -369,8 +375,9 @@ public function testBinaryValueCanBeFormattedAndSerialized() } /** - * @covers Aws\DynamoDb\SetValue - */ + + */ + #[CoversClass(Marshaler::class)] public function testSetValueCanBeFormattedAndSerialized() { $set = new SetValue(['foo', 'bar', 'baz']); diff --git a/tests/DynamoDb/SessionConnectionConfigTraitTest.php b/tests/DynamoDb/SessionConnectionConfigTraitTest.php index a3e91ab5e5..57f6c3e691 100644 --- a/tests/DynamoDb/SessionConnectionConfigTraitTest.php +++ b/tests/DynamoDb/SessionConnectionConfigTraitTest.php @@ -4,10 +4,12 @@ use Aws\DynamoDb\SessionConnectionConfigTrait; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\DynamoDb\SessionConnectionConfigTrait + */ +#[CoversClass(SessionConnectionConfigTrait::class)] class SessionConnectionConfigTraitTest extends TestCase { use UsesServiceTrait; diff --git a/tests/DynamoDb/SessionHandlerTest.php b/tests/DynamoDb/SessionHandlerTest.php index f038eccd9e..5cfd77c0f3 100644 --- a/tests/DynamoDb/SessionHandlerTest.php +++ b/tests/DynamoDb/SessionHandlerTest.php @@ -7,10 +7,12 @@ use Aws\DynamoDb\StandardSessionConnection; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\DynamoDb\SessionHandler + */ +#[CoversClass(SessionHandler::class)] class SessionHandlerTest extends TestCase { use UsesServiceTrait; diff --git a/tests/DynamoDb/StandardSessionConnectionTest.php b/tests/DynamoDb/StandardSessionConnectionTest.php index 54fc3fa6b2..1771c328a1 100644 --- a/tests/DynamoDb/StandardSessionConnectionTest.php +++ b/tests/DynamoDb/StandardSessionConnectionTest.php @@ -8,10 +8,12 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\DynamoDb\StandardSessionConnection + */ +#[CoversClass(StandardSessionConnection::class)] class StandardSessionConnectionTest extends TestCase { use UsesServiceTrait; @@ -157,19 +159,26 @@ public function testWriteReturnsFalseOnFailure() public function testWriteTriggersWarningOnFailure() { - $this->expectWarning(); - $client = $this->getTestSdk()->createDynamoDb(); - $this->addMockResults($client, [ - $this->createMockAwsException('ERROR', DynamoDbException::class) - ]); - $client->getHandlerList()->appendBuild(Middleware::tap(function ($command) { - $this->assertEquals( - ['Action' => 'DELETE'], - $command['AttributeUpdates']['data'] - ); - })); - $connection = new StandardSessionConnection($client); - $connection->write('s1', '', true); + $this->expectException(\RuntimeException::class); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); + try { + $client = $this->getTestSdk()->createDynamoDb(); + $this->addMockResults($client, [ + $this->createMockAwsException('ERROR', DynamoDbException::class) + ]); + $client->getHandlerList()->appendBuild(Middleware::tap(function ($command) { + $this->assertEquals( + ['Action' => 'DELETE'], + $command['AttributeUpdates']['data'] + ); + })); + $connection = new StandardSessionConnection($client); + $connection->write('s1', '', true); + } finally { + restore_error_handler(); + } } public function testDeleteReturnsBoolBasedOnSuccess() @@ -191,19 +200,26 @@ public function testDeleteReturnsBoolBasedOnSuccess() public function testDeleteTriggersWarningOnFailure() { - $this->expectWarning(); - $client = $this->getTestSdk()->createDynamoDb(); - $this->addMockResults($client, [ - new Result([]), - $this->createMockAwsException('ERROR', DynamoDbException::class) - ]); - - $connection = new StandardSessionConnection($client); - - $return = $connection->delete('s1'); - $this->assertTrue($return); - - $connection->delete('s1'); + $this->expectException(\RuntimeException::class); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); + try { + $client = $this->getTestSdk()->createDynamoDb(); + $this->addMockResults($client, [ + new Result([]), + $this->createMockAwsException('ERROR', DynamoDbException::class) + ]); + + $connection = new StandardSessionConnection($client); + + $return = $connection->delete('s1'); + $this->assertTrue($return); + + $connection->delete('s1'); + } finally { + restore_error_handler(); + } } public function testDeleteExpiredReturnsBoolBasedOnSuccess() diff --git a/tests/DynamoDb/WriteRequestBatchTest.php b/tests/DynamoDb/WriteRequestBatchTest.php index 14c47397c4..d9f29d8d88 100644 --- a/tests/DynamoDb/WriteRequestBatchTest.php +++ b/tests/DynamoDb/WriteRequestBatchTest.php @@ -8,10 +8,13 @@ use Aws\DynamoDb\WriteRequestBatch; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\DynamoDb\WriteRequestBatch + */ +#[CoversClass(WriteRequestBatch::class)] class WriteRequestBatchTest extends TestCase { use UsesServiceTrait; @@ -24,8 +27,9 @@ public function testInstantiateWriteRequestBatch() } /** - * @dataProvider getInvalidArgUseCases - */ + + */ + #[DataProvider('getInvalidArgUseCases')] public function testInstantiationFailsOnInvalidArgs($config) { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Ec2/Ec2ClientTest.php b/tests/Ec2/Ec2ClientTest.php index c2a9a80e9d..7659decdc1 100644 --- a/tests/Ec2/Ec2ClientTest.php +++ b/tests/Ec2/Ec2ClientTest.php @@ -9,10 +9,12 @@ use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Ec2\Ec2Client + */ +#[CoversClass(Ec2Client::class)] class Ec2ClientTest extends TestCase { use UsesServiceTrait; diff --git a/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php b/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php index 86a696a17a..c408bb7abd 100644 --- a/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php +++ b/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php @@ -3,10 +3,12 @@ use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\ElasticLoadBalancingV2\ElasticLoadBalancingV2Client + */ +#[CoversClass(ElasticLoadBalancingV2Client::class)] class ElasticLoadBalancingV2ClientTest extends TestCase { use UsesServiceTrait; diff --git a/tests/Endpoint/EndpointProviderTest.php b/tests/Endpoint/EndpointProviderTest.php index 11e5b0c3a8..8b50c6c72d 100644 --- a/tests/Endpoint/EndpointProviderTest.php +++ b/tests/Endpoint/EndpointProviderTest.php @@ -5,10 +5,12 @@ use Aws\Endpoint\PartitionEndpointProvider; use Aws\Endpoint\PatternEndpointProvider; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Endpoint\EndpointProvider + */ +#[CoversClass(EndpointProvider::class)] class EndpointProviderTest extends TestCase { public function testThrowsWhenUnresolved() diff --git a/tests/Endpoint/PartitionEndpointProviderTest.php b/tests/Endpoint/PartitionEndpointProviderTest.php index 31b8f44805..89320efc19 100644 --- a/tests/Endpoint/PartitionEndpointProviderTest.php +++ b/tests/Endpoint/PartitionEndpointProviderTest.php @@ -5,15 +5,19 @@ use Aws\Endpoint\Partition; use Aws\Endpoint\PartitionEndpointProvider; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Endpoint\PartitionEndpointProvider + */ +#[CoversClass(\Aws\Endpoint\PartitionEndpointProvider::class)] class PartitionEndpointProviderTest extends TestCase { /** - * @dataProvider endpointProvider - */ + + */ + #[DataProvider('endpointProvider')] public function testResolvesEndpoints($input, $output) { // Use the default endpoints file @@ -154,12 +158,13 @@ public static function endpointProvider() } /** - * @dataProvider partitionRegionProvider * * @param string $region * @param string $service * @param string $partition - */ + + */ + #[DataProvider('partitionRegionProvider')] public function testResolvesPartitionsByRegion($region, $service, $partition) { // Use the default endpoints file @@ -216,13 +221,14 @@ public function testPassesOptionsToProvider() } /** - * @dataProvider knownEndpointProvider * * @param PartitionEndpointProvider $provider * @param $region * @param $service * @param $endpoint - */ + + */ + #[DataProvider('knownEndpointProvider')] public function testCanGenerateKnownEndpointsKnownToPatternProvider( PartitionEndpointProvider $provider, $region, diff --git a/tests/Endpoint/PartitionTest.php b/tests/Endpoint/PartitionTest.php index bcfd9b0baa..7cff1b7716 100644 --- a/tests/Endpoint/PartitionTest.php +++ b/tests/Endpoint/PartitionTest.php @@ -6,17 +6,21 @@ use Aws\Endpoint\UseDualstackEndpoint; use Aws\Endpoint\UseFipsEndpoint; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Endpoint\Partition + */ +#[CoversClass(\Aws\Endpoint\Partition::class)] class PartitionTest extends TestCase { /** - * @dataProvider partitionDefinitionProvider * * @param array $definition - */ + + */ + #[DataProvider('partitionDefinitionProvider')] public function testAcceptsValidDefinitions(array $definition) { $this->assertInstanceOf( @@ -26,10 +30,11 @@ public function testAcceptsValidDefinitions(array $definition) } /** - * @dataProvider invalidPartitionDefinitionProvider * * @param array $invalidDefinition - */ + + */ + #[DataProvider('invalidPartitionDefinitionProvider')] public function testRejectsInvalidDefinitions(array $invalidDefinition) { $this->expectExceptionMessageMatches("/missing required \w+ field/"); @@ -38,10 +43,11 @@ public function testRejectsInvalidDefinitions(array $invalidDefinition) } /** - * @dataProvider partitionDefinitionProvider * * @param array $definition - */ + + */ + #[DataProvider('partitionDefinitionProvider')] public function testReportsData(array $definition) { $this->assertSame( @@ -54,10 +60,11 @@ public function testReportsData(array $definition) ); } /** - * @dataProvider partitionDefinitionProvider * * @param array $definition - */ + + */ + #[DataProvider('partitionDefinitionProvider')] public function testFipsEndpoint(array $definition) { $partition = new Partition($definition); @@ -105,10 +112,11 @@ public static function invalidPartitionDefinitionProvider(): array } /** - * @dataProvider partitionDefinitionProvider * * @param array $definition - */ + + */ + #[DataProvider('partitionDefinitionProvider')] public function testReportsRegionMatches(array $definition) { $partition = new Partition($definition); @@ -118,10 +126,11 @@ public function testReportsRegionMatches(array $definition) } /** - * @dataProvider partitionDefinitionProvider * * @param array $definition - */ + + */ + #[DataProvider('partitionDefinitionProvider')] public function testReportsRegionMatchesByPattern(array $definition) { $definition['regionRegex'] = '^fo[\w]{1}'; @@ -133,13 +142,14 @@ public function testReportsRegionMatchesByPattern(array $definition) } /** - * @dataProvider serviceRegionsProvider * * @param Partition $partition * @param string $service * @param array $regions * @param bool $allowNonRegionalEndpoints - */ + + */ + #[DataProvider('serviceRegionsProvider')] public function testEnumeratesRegionsForGivenService( Partition $partition, $service, @@ -191,13 +201,14 @@ public static function serviceRegionsProvider() } /** - * @dataProvider signingRegionProvider * * @param Partition $partition * @param $region * @param $service * @param $signingRegion - */ + + */ + #[DataProvider('signingRegionProvider')] public function testDeterminesSigningRegion( Partition $partition, $region, @@ -246,13 +257,14 @@ public static function signingRegionProvider() } /** - * @dataProvider endpointProvider * * @param Partition $partition * @param $region * @param $service * @param $endpoint - */ + + */ + #[DataProvider('endpointProvider')] public function testDeterminesEndpoint( Partition $partition, $region, @@ -331,13 +343,14 @@ public function testIgnoresIsRegionalizedFlagIfPartitionEndpointAbsent() } /** - * @dataProvider signatureVersionProvider * * @param Partition $partition * @param $region * @param $service * @param $signatureVersion - */ + + */ + #[DataProvider('signatureVersionProvider')] public function testDeterminesSignatureVersion( Partition $partition, $region, @@ -411,13 +424,14 @@ public static function signatureVersionProvider() } /** - * @dataProvider signingNameProvider * * @param Partition $partition * @param string $region * @param string $service * @param string $signingName - */ + + */ + #[DataProvider('signingNameProvider')] public function testDeterminesSigningName( Partition $partition, $region, @@ -483,12 +497,13 @@ public static function signingNameProvider() } /** - * @dataProvider stsEndpointTestCases * * @param $region * @param $configOption * @param $expectedEndpoint - */ + + */ + #[DataProvider('stsEndpointTestCases')] public function testResolvesStsRegionalEndpoints( $region, $configOption, @@ -582,12 +597,13 @@ public static function stsEndpointTestCases() } /** - * @dataProvider s3EndpointTestCases * * @param $region * @param $configOption * @param $expectedEndpoint - */ + + */ + #[DataProvider('s3EndpointTestCases')] public function testResolvesS3RegionalEndpoint( $region, $configOption, @@ -666,12 +682,13 @@ public static function s3EndpointTestCases() } /** - * @dataProvider variantTagProvider * * @param array $definition * @param bool $useFipsConfig * @param bool $useDualstackConfig - */ + + */ + #[DataProvider('variantTagProvider')] public function testGetVariantIgnoresVariantTagOrder( array $definition, bool $useFipsConfig, @@ -822,12 +839,13 @@ public static function variantTagProvider(): array } /** - * @dataProvider variantTagEmptyProvider * * @param array $definition * @param @fipsConfig * @param @dualstackConfig - */ + + */ + #[DataProvider('variantTagEmptyProvider')] public function testGetVariantNoVariantSelectedIfTagsAreEmpty( array $definition, bool $useFipsConfig, @@ -978,12 +996,13 @@ public static function variantTagEmptyProvider(): array } /** - * @dataProvider booleanConfigProvider * * @param array $tags * @param @fipsConfig * @param @dualstackConfig - */ + + */ + #[DataProvider('booleanConfigProvider')] public function testGetVariantWithBooleanConfigValues( array $tags, $fipsConfig, diff --git a/tests/Endpoint/PatternEndpointProviderTest.php b/tests/Endpoint/PatternEndpointProviderTest.php index 03ce9310e2..ceda8bd6d7 100644 --- a/tests/Endpoint/PatternEndpointProviderTest.php +++ b/tests/Endpoint/PatternEndpointProviderTest.php @@ -4,10 +4,13 @@ use Aws\Endpoint\EndpointProvider; use Aws\Endpoint\PatternEndpointProvider; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Endpoint\PatternEndpointProvider + */ +#[CoversClass(PatternEndpointProvider::class)] class PatternEndpointProviderTest extends TestCase { public function testReturnsNullWhenUnresolved() @@ -73,8 +76,9 @@ public static function endpointProvider() } /** - * @dataProvider endpointProvider - */ + + */ + #[DataProvider('endpointProvider')] public function testResolvesEndpoints($input, $output) { $p = EndpointProvider::patterns([ diff --git a/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php b/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php index f6d823928c..79125a092a 100644 --- a/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php +++ b/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php @@ -10,10 +10,12 @@ use Aws\Endpoint\UseDualstackEndpoint\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Endpoint\UseDualstackEndpoint\ConfigurationProvider + */ +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; diff --git a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php index 3d0e6d4545..b6508e8c85 100644 --- a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php @@ -3,18 +3,22 @@ use Aws\Endpoint\UseDualstackEndpoint\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Endpoint\UseDualstackEndpoint\Configuration + */ +#[CoversClass(\Aws\Endpoint\UseDualstackEndpoint\Configuration::class)] class ConfigurationTest extends TestCase { /** - * @dataProvider correctValueCases * * @param $param * @param $expected - */ + + */ + #[DataProvider('correctValueCases')] public function testGetsCorrectValues($param, $expected) { $config = new Configuration($param, 'us-east-1'); diff --git a/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php b/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php index b5bda1eb97..e2c7a4112a 100644 --- a/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php +++ b/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php @@ -9,10 +9,12 @@ use Aws\Endpoint\UseFipsEndpoint\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Endpoint\UseFipsEndpoint\ConfigurationProvider + */ +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; diff --git a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php index b5fdbce917..8cfefec8b2 100644 --- a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php @@ -3,18 +3,22 @@ use Aws\Endpoint\UseFipsEndpoint\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Endpoint\UseFipsEndpoint\Configuration + */ +#[CoversClass(\Aws\Endpoint\UseFipsEndpoint\Configuration::class)] class ConfigurationTest extends TestCase { /** - * @dataProvider correctValueCases * * @param $param * @param $expected - */ + + */ + #[DataProvider('correctValueCases')] public function testGetsCorrectValues($param, $expected) { $config = new Configuration($param); diff --git a/tests/EndpointDiscovery/ConfigurationProviderTest.php b/tests/EndpointDiscovery/ConfigurationProviderTest.php index 31a01d8a0d..a160109047 100644 --- a/tests/EndpointDiscovery/ConfigurationProviderTest.php +++ b/tests/EndpointDiscovery/ConfigurationProviderTest.php @@ -11,10 +11,13 @@ use Aws\LruArrayCache; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\EndpointDiscovery\ConfigurationProvider + */ +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -76,9 +79,10 @@ public static function tear_down_after_class() } /** - * @dataProvider getEnvVariableNames * @param $envName - */ + + */ + #[DataProvider('getEnvVariableNames')] public function testCreatesFromEnvironmentVariables($envName) { $this->clearEnv(); @@ -470,10 +474,11 @@ function () use ($expected) { } /** - * @dataProvider getSuccessfulUnwrapData * @param $toUnwrap * @param ConfigurationInterface $expected - */ + + */ + #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { $this->assertSame( diff --git a/tests/EndpointDiscovery/ConfigurationTest.php b/tests/EndpointDiscovery/ConfigurationTest.php index 1d2588eaf9..a856417e0e 100644 --- a/tests/EndpointDiscovery/ConfigurationTest.php +++ b/tests/EndpointDiscovery/ConfigurationTest.php @@ -5,10 +5,12 @@ use Aws\EndpointDiscovery\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Log\InvalidArgumentException; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\EndpointDiscovery\Configuration + */ +#[CoversClass(\Aws\EndpointDiscovery\Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php index 71f73ad62e..b9024ecebb 100644 --- a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php +++ b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php @@ -21,10 +21,13 @@ use GuzzleHttp\Psr7\Uri; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\EndpointDiscovery\EndpointDiscoveryMiddleware + */ +#[CoversClass(EndpointDiscoveryMiddleware::class)] class EndpointDiscoveryMiddlewareTest extends TestCase { use UsesServiceTrait; @@ -71,12 +74,13 @@ public function tear_down() } /** - * @dataProvider getRequestTestCases * @param array $commandArgs * @param array $clientArgs * @param ResultInterface $describeResult * @param RequestInterface $expected - */ + + */ + #[DataProvider('getRequestTestCases')] public function testCorrectlyModifiesRequest( array $commandArgs, array $clientArgs, @@ -297,11 +301,12 @@ public static function getRequestTestCases() } /** - * @dataProvider getDiscoveryRequestTestCases * @param CommandInterface $mainCmd * @param CommandInterface $expectedCmd * @param RequestInterface $expectedReq - */ + + */ + #[DataProvider('getDiscoveryRequestTestCases')] public function testCorrectlyConstructsDiscoveryRequest( CommandInterface $mainCmd, CommandInterface $expectedCmd, @@ -551,9 +556,10 @@ public function testThrowsExceptionOnDescribeFailure() } /** - * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception - */ + + */ + #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testUsesCachedEndpointForInvalidEndpointException($exception) { $callOrder = []; @@ -586,9 +592,10 @@ public function testUsesCachedEndpointForInvalidEndpointException($exception) } /** - * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception - */ + + */ + #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testUseRegionalEndpointForInvalidEndpointException($exception) { $callOrder = []; @@ -629,9 +636,10 @@ public function testUseRegionalEndpointForInvalidEndpointException($exception) } /** - * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception - */ + + */ + #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testThrowsExceptionOnInvalidEndpointException($exception) { $callOrder = []; @@ -670,9 +678,10 @@ public function testThrowsExceptionOnInvalidEndpointException($exception) } /** - * @dataProvider invalidEndpointExceptionsDataProvider * @param $exception - */ + + */ + #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testCallsDiscoveryApiOnInvalidEndpointException($exception) { // Use Reflection to set private static discoveryCooldown variable to 0 diff --git a/tests/EndpointDiscovery/EndpointListTest.php b/tests/EndpointDiscovery/EndpointListTest.php index 1cb608f875..ad81722d2a 100644 --- a/tests/EndpointDiscovery/EndpointListTest.php +++ b/tests/EndpointDiscovery/EndpointListTest.php @@ -4,10 +4,12 @@ use Aws\EndpointDiscovery\EndpointList; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\EndpointDiscovery\EndpointList + */ +#[CoversClass(\Aws\EndpointDiscovery\EndpointList::class)] class EndpointListTest extends TestCase { public function testStoresRetrievesAndCyclesActiveEndpoints() diff --git a/tests/EndpointParameterMiddlewareTest.php b/tests/EndpointParameterMiddlewareTest.php index fd60f2a258..08398e5b47 100644 --- a/tests/EndpointParameterMiddlewareTest.php +++ b/tests/EndpointParameterMiddlewareTest.php @@ -7,10 +7,13 @@ use Aws\Api\Service; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\EndpointParameterMiddleware + */ +#[CoversClass(\Aws\EndpointParameterMiddleware::class)] class EndpointParameterMiddlewareTest extends TestCase { public function testThrowsExceptionForMissingParameter() @@ -67,8 +70,9 @@ public function testThrowsExceptionForInvalidParameter() } /** - * @dataProvider correctlyOutputsHostDataProvider - */ + + */ + #[DataProvider('correctlyOutputsHostDataProvider')] public function testCorrectlyOutputsHost( $clientArgs, $cmdName, diff --git a/tests/EndpointV2/EndpointDefinitionProviderTest.php b/tests/EndpointV2/EndpointDefinitionProviderTest.php index c268d8f1e3..e5d77fe66c 100644 --- a/tests/EndpointV2/EndpointDefinitionProviderTest.php +++ b/tests/EndpointV2/EndpointDefinitionProviderTest.php @@ -4,6 +4,7 @@ use Aws\EndpointV2\EndpointDefinitionProvider; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class EndpointDefinitionProviderTest extends TestCase { @@ -55,10 +56,11 @@ public static function getEndpointFileProvider() } /** - * @dataProvider getEndpointFileProvider * * @param $type - */ + + */ + #[DataProvider('getEndpointFileProvider')] public function testThrowsExceptionOnMissingFiles($type) { $method = 'getEndpoint' . $type; diff --git a/tests/EndpointV2/EndpointProviderV2Test.php b/tests/EndpointV2/EndpointProviderV2Test.php index dd58017958..1bf6e58f3b 100644 --- a/tests/EndpointV2/EndpointProviderV2Test.php +++ b/tests/EndpointV2/EndpointProviderV2Test.php @@ -14,10 +14,13 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7\Uri; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\EndpointV2\EndpointProviderV2 + */ +#[CoversClass(EndpointProviderV2::class)] class EndpointProviderV2Test extends TestCase { use UsesServiceTrait; @@ -68,8 +71,9 @@ public static function basicTestCaseProvider(): \Generator } /** - * @dataProvider basicTestCaseProvider - */ + + */ + #[DataProvider('basicTestCaseProvider')] public function testBasicEndpointAndErrorCases( $ruleset, $isSuccessCase, @@ -130,8 +134,9 @@ public static function serviceTestCaseProvider(): \Generator } /** - * @dataProvider serviceTestCaseProvider - */ + + */ + #[DataProvider('serviceTestCaseProvider')] public function testServiceEndpointAndErrorCases( $service, $isSuccessCase, @@ -225,8 +230,9 @@ public static function rulesetProtocolEndpointAndErrorCaseProvider(): \Generator * before being passed into the endpoint provider and after other * middleware has acted upon the request. * - * @dataProvider rulesetProtocolEndpointAndErrorCaseProvider - */ + + */ + #[DataProvider('rulesetProtocolEndpointAndErrorCaseProvider')] public function testRulesetProtocolEndpointAndErrorCases($service, $clientArgs, $operationInput, $expected, $errorCase) { if ($errorCase) { @@ -378,9 +384,10 @@ public function testCachesEndpointObject() } /** - * @dataProvider stringArrayOperationInputsProvider * @return void - */ + + */ + #[DataProvider('stringArrayOperationInputsProvider')] public function testStringArrayOperationInputs( $params, $expected, diff --git a/tests/EndpointV2/EndpointV2MiddlewareTest.php b/tests/EndpointV2/EndpointV2MiddlewareTest.php index b8c2669a98..64af77483c 100644 --- a/tests/EndpointV2/EndpointV2MiddlewareTest.php +++ b/tests/EndpointV2/EndpointV2MiddlewareTest.php @@ -9,20 +9,22 @@ use Aws\Test\UsesServiceTrait; use ReflectionClass; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class EndpointV2MiddlewareTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider providedSuccessCases * * @param $service * @param $clientArgs * @param $commandName * @param $commandArgs * @param $expectedUri - */ + + */ + #[DataProvider('providedSuccessCases')] public function testSuccessfullyResolvesEndpointAndAuthScheme( $service, $clientArgs, @@ -124,8 +126,9 @@ function ($command, $endpoint) {}, * @param $authSchemes * @param $expected * - * @dataProvider v4aAuthProvider - */ + + */ + #[DataProvider('v4aAuthProvider')] public function testV4aAuthSchemeSelection($authSchemes, $expected) { if ($expected === 'v4a' && (!extension_loaded('awscrt'))) { @@ -197,8 +200,9 @@ function ($command, $endpoint) {}, } /** - * @dataProvider invalidInitializationProvider - */ + + */ + #[DataProvider('invalidInitializationProvider')] public function testInitializationWithInvalidParameters( $nextHandler, bool $validEndpointProvider, diff --git a/tests/EndpointV2/EndpointV2SerializerTraitTest.php b/tests/EndpointV2/EndpointV2SerializerTraitTest.php index c03ba0e684..688523adbc 100644 --- a/tests/EndpointV2/EndpointV2SerializerTraitTest.php +++ b/tests/EndpointV2/EndpointV2SerializerTraitTest.php @@ -7,10 +7,12 @@ use Aws\Middleware; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\EndpointV2\EndpointV2SerializerTrait + */ +#[CoversClass(EndpointV2SerializerTrait::class)] class EndpointV2SerializerTraitTest extends TestCase { use UsesServiceTrait; diff --git a/tests/EndpointV2/RuleCreatorTest.php b/tests/EndpointV2/RuleCreatorTest.php index cb435b61a3..477ae3d024 100644 --- a/tests/EndpointV2/RuleCreatorTest.php +++ b/tests/EndpointV2/RuleCreatorTest.php @@ -4,10 +4,13 @@ use Aws\EndpointV2\Rule; use Aws\Exception\UnresolvedEndpointException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\EndpointV2\Rule\RuleCreator + */ +#[CoversClass(\Aws\EndpointV2\Rule\RuleCreator::class)] class RuleCreatorTest extends TestCase { public function ruleCreationProvider() @@ -45,8 +48,9 @@ public function ruleCreationProvider() } /** - * @dataProvider RuleCreationProvider - */ + + */ + #[DataProvider('RuleCreationProvider')] public function testRuleCreation($spec, $expected) { $result = Rule\RuleCreator::create($spec['type'], $spec); $this->assertInstanceOf($expected, $result); @@ -62,8 +66,9 @@ public static function invalidRuleTypeProvider() } /** - * @dataProvider invalidRuleTypeProvider - */ + + */ + #[DataProvider('invalidRuleTypeProvider')] public function testThrowsExceptionForInvalidRuleType($input) { $this->expectException(UnresolvedEndpointException::class); diff --git a/tests/EndpointV2/RulesetEndpointTest.php b/tests/EndpointV2/RulesetEndpointTest.php index d8b15262ce..ac0676b87a 100644 --- a/tests/EndpointV2/RulesetEndpointTest.php +++ b/tests/EndpointV2/RulesetEndpointTest.php @@ -2,10 +2,12 @@ use Aws\EndpointV2\Ruleset\RulesetEndpoint; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\EndpointV2\Ruleset\RulesetEndpoint + */ +#[CoversClass(RulesetEndpoint::class)] class RulesetEndpointTest extends TestCase { private static $url = 'https://exmaple.com'; diff --git a/tests/EndpointV2/RulesetParameterTest.php b/tests/EndpointV2/RulesetParameterTest.php index 576e22869c..252a725c59 100644 --- a/tests/EndpointV2/RulesetParameterTest.php +++ b/tests/EndpointV2/RulesetParameterTest.php @@ -4,10 +4,13 @@ use Aws\EndpointV2\Ruleset\RulesetParameter; use Aws\Exception\UnresolvedEndpointException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\EndpointV2\Ruleset\RulesetParameter + */ +#[CoversClass(RulesetParameter::class)] class RulesetParameterTest extends TestCase { public static function wrongParameterTypeProvider() @@ -20,10 +23,11 @@ public static function wrongParameterTypeProvider() } /** - * @dataProvider wrongParameterTypeProvider * * @param $inputParameter - */ + + */ + #[DataProvider('wrongParameterTypeProvider')] public function testWrongParameterTypeThrowsException($inputParameter) { $this->expectException(UnresolvedEndpointException::class); @@ -40,19 +44,27 @@ public function testWrongParameterTypeThrowsException($inputParameter) public function testDeprecatedParameterLogsError() { - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage( 'Region has been deprecated since then. There is a new parameter.' ); - $parameter = new RulesetParameter('Region', [ - "type" => "string", - "builtIn" => "AWS::Region", - "deprecated" => [ - "since" => 'then', - "message" => 'There is a new parameter.' - ] - ]); - $parameter->validateInputParam('us-east-1'); + + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); + try { + $parameter = new RulesetParameter('Region', [ + "type" => "string", + "builtIn" => "AWS::Region", + "deprecated" => [ + "since" => 'then', + "message" => 'There is a new parameter.' + ] + ]); + $parameter->validateInputParam('us-east-1'); + } finally { + restore_error_handler(); + } } public function testUnknownTypeThrowsException() @@ -80,15 +92,16 @@ public function testGetDefault() } /** - * @dataProvider validTypesProvider * @doesNotPerformAssertions - */ + * */ + #[DataProvider('validTypesProvider')] public function testRulesetCreationWithValidTypes($spec) { new RulesetParameter('FooParam', $spec); + $this->assertTrue(true); } - public static function validTypesProvider() + public static function validTypesProvider(): array { return [ [ diff --git a/tests/EndpointV2/RulesetStandardLibraryTest.php b/tests/EndpointV2/RulesetStandardLibraryTest.php index 0ac4c78572..ef280fec0a 100644 --- a/tests/EndpointV2/RulesetStandardLibraryTest.php +++ b/tests/EndpointV2/RulesetStandardLibraryTest.php @@ -5,10 +5,13 @@ use Aws\EndpointV2\Ruleset\RulesetStandardLibrary; use Aws\Exception\UnresolvedEndpointException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\EndpointV2\Ruleset\RulesetStandardLibrary + */ +#[CoversClass(\Aws\EndpointV2\Ruleset\RulesetStandardLibrary::class)] class RulesetStandardLibraryTest extends TestCase { private $standardLibrary; @@ -34,11 +37,12 @@ public static function isSetProvider() } /** - * @dataProvider isSetProvider * * @param $input * @param $expected - */ + + */ + #[DataProvider('isSetProvider')] public function testIsSet($input, $expected) { $this->assertSame($expected, $this->standardLibrary->is_set($input)); @@ -56,11 +60,12 @@ public static function notProvider() } /** - * @dataProvider notProvider * * @param $input * @param $expected - */ + + */ + #[DataProvider('notProvider')] public function testNot($input, $expected) { $this->assertSame($expected, $this->standardLibrary->not($input)); @@ -77,11 +82,12 @@ public static function getAttrProvider() } /** - * @dataProvider getAttrProvider * * @param $path * @param $expected - */ + + */ + #[DataProvider('getAttrProvider')] public function testGetAttr($from, $path, $expected) { $from = json_decode($from, true); @@ -104,12 +110,13 @@ public static function stringEqualsProvider() } /** - * @dataProvider stringEqualsProvider * * @param $string1 * @param $string2 * @param $expected - */ + + */ + #[DataProvider('stringEqualsProvider')] public function testStringEquals($string1, $string2, $expected) { $this->assertSame($expected, $this->standardLibrary->stringEquals($string1, $string2)); @@ -134,12 +141,13 @@ public static function booleanEqualsProvider() } /** - * @dataProvider booleanEqualsProvider * * @param $boolean1 * @param $boolean2 * @param $expected - */ + + */ + #[DataProvider('booleanEqualsProvider')] public function testBooleanEquals($boolean1, $boolean2, $expected) { $this->assertSame($expected, $this->standardLibrary->booleanEquals($boolean1, $boolean2)); @@ -163,12 +171,13 @@ public static function isValidHostLabelProvider() } /** - * @dataProvider isValidHostLabelProvider * * @param $hostLabel * @param $allowSubDomains * @param $expected - */ + + */ + #[DataProvider('isValidHostLabelProvider')] public function testIsValidHostLabel($hostLabel, $allowSubDomains, $expected) { $this->assertSame($expected, $this->standardLibrary->isValidHostLabel($hostLabel, $allowSubDomains)); @@ -221,12 +230,13 @@ public static function resolveTemplateStringProvider() } /** - * @dataProvider resolveTemplateStringProvider * * @param $string * @param $inputParams * @param $expected - */ + + */ + #[DataProvider('resolveTemplateStringProvider')] public function testResolveTemplateString($string, $inputParams, $expected) { $result = $this->standardLibrary->resolveTemplateString($string, $inputParams); @@ -255,11 +265,12 @@ public static function NullParamProvider() } /** - * @dataProvider NullParamProvider * * @param $string * @param $inputParams - */ + + */ + #[DataProvider('NullParamProvider')] public function testResolveTemplateStringThrowsExceptionIfNullParam($string, $inputParams) { $this->expectException(UnresolvedEndpointException::class); diff --git a/tests/EventBridge/EventBridgeClientTest.php b/tests/EventBridge/EventBridgeClientTest.php index 7e3f112146..9f8be83752 100644 --- a/tests/EventBridge/EventBridgeClientTest.php +++ b/tests/EventBridge/EventBridgeClientTest.php @@ -8,6 +8,7 @@ use Aws\Test\UsesServiceTrait; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class EventBridgeClientTest extends TestCase { @@ -76,14 +77,15 @@ public static function putEventsEndpointSuccessProvider() } /** - * @dataProvider putEventsEndpointSuccessProvider * * @param $clientRegion * @param $additionalConfig * @param $endpointId * @param $expectedEndpoint * @param $additionalHeaders - */ + + */ + #[DataProvider('putEventsEndpointSuccessProvider')] public function testPutEventsEndpointSuccessCases( $clientRegion, $additionalConfig, @@ -149,13 +151,14 @@ public static function putEventsEndpointFailureProvider() } /** - * @dataProvider putEventsEndpointFailureProvider * * @param $clientRegion * @param $additionalConfig * @param $endpointId * @param $expectedException - */ + + */ + #[DataProvider('putEventsEndpointFailureProvider')] public function testPutEventsEndpointFailureCases( $clientRegion, $additionalConfig, diff --git a/tests/Exception/AwsExceptionTest.php b/tests/Exception/AwsExceptionTest.php index 0a5620acd8..e270a063ef 100644 --- a/tests/Exception/AwsExceptionTest.php +++ b/tests/Exception/AwsExceptionTest.php @@ -12,10 +12,13 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Exception\AwsException + */ +#[CoversClass(AwsException::class)] class AwsExceptionTest extends TestCase { use UsesServiceTrait; @@ -224,8 +227,9 @@ public function testAcceptsNullAsPrevious(): void } /** - * @dataProvider previousThrowableProvider - */ + + */ + #[DataProvider('previousThrowableProvider')] public function testAcceptsVariousThrowableTypes(\Throwable $previous): void { $command = new Command('foo'); diff --git a/tests/Exception/CouldNotCreateChecksumExceptionTest.php b/tests/Exception/CouldNotCreateChecksumExceptionTest.php index 8d23bc27c2..4165868ba2 100644 --- a/tests/Exception/CouldNotCreateChecksumExceptionTest.php +++ b/tests/Exception/CouldNotCreateChecksumExceptionTest.php @@ -3,10 +3,12 @@ use Aws\Exception\CouldNotCreateChecksumException; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Exception\CouldNotCreateChecksumException + */ +#[CoversClass(CouldNotCreateChecksumException::class)] class CouldNotCreateChecksumExceptionTest extends TestCase { public function testUsesCorrectWords() diff --git a/tests/Exception/EventStreamDataExceptionTest.php b/tests/Exception/EventStreamDataExceptionTest.php index 6911d3735e..d9ccdd36ae 100644 --- a/tests/Exception/EventStreamDataExceptionTest.php +++ b/tests/Exception/EventStreamDataExceptionTest.php @@ -4,10 +4,12 @@ use Aws\Exception\EventStreamDataException; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Exception\EventStreamDataException + */ +#[CoversClass(EventStreamDataException::class)] class EventStreamDataExceptionTest extends TestCase { public function testAccessors() diff --git a/tests/Exception/MultipartUploadExceptionTest.php b/tests/Exception/MultipartUploadExceptionTest.php index 3f0405f4c9..46b284cbbe 100644 --- a/tests/Exception/MultipartUploadExceptionTest.php +++ b/tests/Exception/MultipartUploadExceptionTest.php @@ -6,15 +6,19 @@ use Aws\Exception\MultipartUploadException; use Aws\Multipart\UploadState; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Exception\MultipartUploadException + */ +#[CoversClass(MultipartUploadException::class)] class MultipartUploadExceptionTest extends TestCase { /** - * @dataProvider getTestCases - */ + + */ + #[DataProvider('getTestCases')] public function testCanCreateMultipartException($commandName, $status) { $msg = 'Error encountered while reticulating splines.'; diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index aa7d966410..4467a35589 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -6,12 +6,15 @@ use Aws\Result; use Aws\S3\S3Client; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; class FunctionsTest extends TestCase { /** - * @covers Aws\recursive_dir_iterator() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testCreatesRecursiveDirIterator() { $iter = Aws\recursive_dir_iterator(__DIR__); @@ -21,8 +24,9 @@ public function testCreatesRecursiveDirIterator() } /** - * @covers Aws\dir_iterator() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testCreatesNonRecursiveDirIterator() { $iter = Aws\dir_iterator(__DIR__); @@ -32,8 +36,9 @@ public function testCreatesNonRecursiveDirIterator() } /** - * @covers Aws\or_chain() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testComposesOrFunctions() { $a = function ($a, $b) { return null; }; @@ -44,8 +49,9 @@ public function testComposesOrFunctions() } /** - * @covers Aws\or_chain() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testReturnsNullWhenNonResolve() { $called = []; @@ -58,8 +64,9 @@ public function testReturnsNullWhenNonResolve() } /** - * @covers Aws\constantly() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testCreatesConstantlyFunctions() { $fn = Aws\constantly('foo'); @@ -67,8 +74,9 @@ public function testCreatesConstantlyFunctions() } /** - * @covers Aws\load_compiled_json() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testUsesJsonCompiler() { $this->expectException(\InvalidArgumentException::class); @@ -76,8 +84,9 @@ public function testUsesJsonCompiler() } /** - * @covers Aws\load_compiled_json() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testUsesPhpCompilationOfJsonIfPossible() { $soughtData = ['foo' => 'bar']; @@ -99,8 +108,9 @@ public function testUsesPhpCompilationOfJsonIfPossible() } /** - * @covers Aws\load_compiled_json() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testOnlyLoadsCompiledJsonOnce() { $soughtData = ['foo' => 'bar']; @@ -131,8 +141,9 @@ public function testOnlyLoadsCompiledJsonOnce() } /** - * @covers Aws\filter() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testFilter() { $data = [0, 1, 2, 3, 4]; @@ -142,8 +153,9 @@ public function testFilter() } /** - * @covers Aws\map() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testMap() { $data = [0, 1, 2, 3, 4]; @@ -152,8 +164,9 @@ public function testMap() } /** - * @covers Aws\flatmap() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testFlatMap() { $data = ['Hello', 'World']; @@ -166,8 +179,9 @@ public function testFlatMap() } /** - * @covers Aws\partition() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testPartition() { $data = [1, 2, 3, 4, 5]; @@ -176,8 +190,9 @@ public function testPartition() } /** - * @covers Aws\describe_type() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeObject() { $obj = new \stdClass(); @@ -185,8 +200,9 @@ public function testDescribeObject() } /** - * @covers Aws\describe_type() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeArray() { $arr = [0, 1, 2]; @@ -194,8 +210,9 @@ public function testDescribeArray() } /** - * @covers Aws\describe_type() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeDoubleToFloat() { if (PHP_VERSION_ID >= 80500) { @@ -209,8 +226,9 @@ public function testDescribeDoubleToFloat() } /** - * @covers Aws\describe_type() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeType() { $this->assertSame('int(1)', Aws\describe_type(1)); @@ -218,8 +236,9 @@ public function testDescribeType() } /** - * @covers Aws\default_http_handler() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testGuzzleHttpHandler() { if (!class_exists('GuzzleHttp\Handler\StreamHandler')) { @@ -232,8 +251,9 @@ public function testGuzzleHttpHandler() } /** - * @covers Aws\serialize() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testSerializesHttpRequests() { $mock = new MockHandler([new Result([])]); @@ -265,16 +285,18 @@ public function testSerializesHttpRequests() } /** - * @covers Aws\manifest() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testLoadsManifest() { $this->assertNotNull(Aws\manifest()); } /** - * @covers Aws\manifest() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testServiceManifest() { $manifest = Aws\manifest('s3'); @@ -291,8 +313,9 @@ public function testServiceManifest() } /** - * @covers Aws\manifest() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testAliasManifest() { $manifest = Aws\manifest('iotdataplane'); @@ -309,8 +332,9 @@ public function testAliasManifest() } /** - * @covers Aws\manifest() - */ + + */ + #[CoversClass(recursive_dir_iterator()::class)] public function testInvalidManifest() { $this->expectException(\InvalidArgumentException::class); @@ -318,9 +342,10 @@ public function testInvalidManifest() } /** - * @covers Aws\is_valid_hostname() - * @dataProvider getHostnameTestCases - */ + + */ +#[CoversClass(recursive_dir_iterator()::class)] + #[DataProvider('getHostnameTestCases')] public function testValidatesHostnames($hostname, $expected) { $this->assertEquals($expected, Aws\is_valid_hostname($hostname)); @@ -368,11 +393,12 @@ public static function getHostnameTestCases() } /** - * @covers Aws\is_valid_hostlabel() - * @dataProvider getHostlabelTestCases * @param string $label * @param bool $expected - */ + + */ +#[CoversClass(recursive_dir_iterator()::class)] + #[DataProvider('getHostlabelTestCases')] public function testValidatesHostlabels($label, $expected) { $this->assertEquals($expected, Aws\is_valid_hostlabel($label)); @@ -405,9 +431,10 @@ public static function getHostlabelTestCases() } /** - * @covers Aws\parse_ini_file() - * @dataProvider getIniFileTestCases - */ + + */ +#[CoversClass(recursive_dir_iterator()::class)] + #[DataProvider('getIniFileTestCases')] public function testParsesIniFile($ini, $expected) { $tmpFile = sys_get_temp_dir() . '/test.ini'; @@ -465,9 +492,10 @@ public static function getIniFileTestCases() } /** - * @covers Aws\parse_ini_section_with_subsections() - * @dataProvider getIniFileServiceTestCases - */ + + */ +#[CoversClass(recursive_dir_iterator()::class)] + #[DataProvider('getIniFileServiceTestCases')] public function testParsesIniSectionsWithSubsections($ini, $expected) { $tmpFile = sys_get_temp_dir() . '/test.ini'; @@ -513,8 +541,9 @@ public static function getIniFileServiceTestCases() * @param $array * @param $expected * - * @dataProvider isAssociativeProvider - */ + + */ + #[DataProvider('isAssociativeProvider')] public function testIsAssociative($array, $expected) { $result = Aws\is_associative($array); diff --git a/tests/Glacier/GlacierClientTest.php b/tests/Glacier/GlacierClientTest.php index 1e4688e121..9fbd14c16d 100644 --- a/tests/Glacier/GlacierClientTest.php +++ b/tests/Glacier/GlacierClientTest.php @@ -9,10 +9,12 @@ use GuzzleHttp\Psr7\NoSeekStream; use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Glacier\GlacierClient + */ +#[CoversClass(GlacierClient::class)] class GlacierClientTest extends TestCase { use UsesServiceTrait; diff --git a/tests/Glacier/MultipartUploaderTest.php b/tests/Glacier/MultipartUploaderTest.php index 5350138925..fa00ea1dff 100644 --- a/tests/Glacier/MultipartUploaderTest.php +++ b/tests/Glacier/MultipartUploaderTest.php @@ -7,10 +7,13 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Glacier\MultipartUploader + */ +#[CoversClass(MultipartUploader::class)] class MultipartUploaderTest extends TestCase { use UsesServiceTrait; @@ -24,8 +27,9 @@ public static function _tearDownAfterClass() } /** - * @dataProvider getTestCases - */ + + */ + #[DataProvider('getTestCases')] public function testGlacierMultipartUploadWorkflow( array $uploadOptions = [], ?StreamInterface $source = null, diff --git a/tests/Glacier/TreeHashTest.php b/tests/Glacier/TreeHashTest.php index 907faac89e..f8ad86a34a 100644 --- a/tests/Glacier/TreeHashTest.php +++ b/tests/Glacier/TreeHashTest.php @@ -3,15 +3,17 @@ use Aws\Glacier\TreeHash; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; class TreeHashTest extends TestCase { /** - * @covers Aws\Glacier\TreeHash::__construct - * @covers Aws\Glacier\TreeHash::update - * @covers Aws\Glacier\TreeHash::addChecksum - * @covers Aws\Glacier\TreeHash::complete - */ + + */ +#[CoversClass(Aws\Glacier\TreeHash::__construct::class)] +#[CoversClass(Aws\Glacier\TreeHash::update::class)] +#[CoversClass(Aws\Glacier\TreeHash::addChecksum::class)] + #[CoversClass(Aws\Glacier\TreeHash::complete::class)] public function testHashingIsHappeningCorrectly() { $chunks = [ @@ -38,8 +40,9 @@ public function testHashingIsHappeningCorrectly() } /** - * @covers Aws\Glacier\TreeHash::update - */ + + */ + #[CoversClass(Aws\Glacier\TreeHash::update::class)] public function testCannotUpdateAfterHashCalculation() { $this->expectException(\LogicException::class); @@ -51,8 +54,9 @@ public function testCannotUpdateAfterHashCalculation() } /** - * @covers Aws\Glacier\TreeHash::addChecksum - */ + + */ + #[CoversClass(Aws\Glacier\TreeHash::addChecksum::class)] public function testCannotAddChecksumsAfterHashCalculation() { $this->expectException(\LogicException::class); @@ -64,8 +68,9 @@ public function testCannotAddChecksumsAfterHashCalculation() } /** - * @covers Aws\Glacier\TreeHash::reset - */ + + */ + #[CoversClass(Aws\Glacier\TreeHash::reset::class)] public function testCanResetHash() { $hash = new TreeHash('sha256'); @@ -77,8 +82,9 @@ public function testCanResetHash() } /** - * @covers Aws\Glacier\TreeHash::complete - */ + + */ + #[CoversClass(Aws\Glacier\TreeHash::complete::class)] public function testCanCalculateEmptyHash() { $hash = new TreeHash('sha256'); @@ -87,8 +93,9 @@ public function testCanCalculateEmptyHash() } /** - * @covers Aws\Glacier\TreeHash::complete - */ + + */ + #[CoversClass(Aws\Glacier\TreeHash::complete::class)] public function testCanCalculateHashForSingleZero() { $data = "0"; diff --git a/tests/Handler/Guzzle/HandlerTest.php b/tests/Handler/Guzzle/HandlerTest.php index fd047c868d..0db2a1c80e 100644 --- a/tests/Handler/Guzzle/HandlerTest.php +++ b/tests/Handler/Guzzle/HandlerTest.php @@ -11,10 +11,12 @@ use GuzzleHttp\Psr7\Response; use GuzzleHttp\TransferStats; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Handler\Guzzle\GuzzleHandler + */ +#[CoversClass(GuzzleHandler::class)] class HandlerTest extends TestCase { public function testHandlerWorksWithSuccessfulRequest() diff --git a/tests/Handler/GuzzleV6/HandlerTest.php b/tests/Handler/GuzzleV6/HandlerTest.php index 38feebbc23..28e10f38ed 100644 --- a/tests/Handler/GuzzleV6/HandlerTest.php +++ b/tests/Handler/GuzzleV6/HandlerTest.php @@ -15,5 +15,6 @@ public function testV6ClassExists(): void 'Using the "Aws\Handler\GuzzleV6\GuzzleHandler" class is deprecated, use "Aws\Handler\Guzzle\GuzzleHandler" instead.' ); $this->assertTrue(class_exists(\Aws\Handler\GuzzleV6\GuzzleHandler::class)); + restore_error_handler(); } } diff --git a/tests/HandlerListTest.php b/tests/HandlerListTest.php index f167309df3..9e1567c974 100644 --- a/tests/HandlerListTest.php +++ b/tests/HandlerListTest.php @@ -7,10 +7,12 @@ use Aws\Middleware; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\HandlerList + */ +#[CoversClass(HandlerList::class)] class HandlerListTest extends TestCase { public function testEnsuresHandlerIsSet() diff --git a/tests/HasMonitoringEventsTraitTest.php b/tests/HasMonitoringEventsTraitTest.php index b32cf97248..5e27a32b0c 100644 --- a/tests/HasMonitoringEventsTraitTest.php +++ b/tests/HasMonitoringEventsTraitTest.php @@ -3,11 +3,13 @@ use Aws\HasMonitoringEventsTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\HasMonitoringEventsTrait + */ +#[CoversClass(\Aws\HasMonitoringEventsTrait::class)] class HasMonitoringEventsTraitTest extends TestCase { diff --git a/tests/HashingStreamTest.php b/tests/HashingStreamTest.php index ddb4a86844..0af14fec59 100644 --- a/tests/HashingStreamTest.php +++ b/tests/HashingStreamTest.php @@ -5,10 +5,12 @@ use Aws\PhpHash; use Aws\HashingStream; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\HashingStream + */ +#[CoversClass(HashingStream::class)] class HashingStreamTest extends TestCase { public function testCanCreateRollingMd5() diff --git a/tests/HistoryTest.php b/tests/HistoryTest.php index 71e103dfc8..657dc09388 100644 --- a/tests/HistoryTest.php +++ b/tests/HistoryTest.php @@ -7,10 +7,12 @@ use Aws\Exception\AwsException; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\History + */ +#[CoversClass(History::class)] class HistoryTest extends TestCase { public function testIsCountable() diff --git a/tests/IdempotencyTokenMiddlewareTest.php b/tests/IdempotencyTokenMiddlewareTest.php index c26c66dde6..7f8aa5a43f 100644 --- a/tests/IdempotencyTokenMiddlewareTest.php +++ b/tests/IdempotencyTokenMiddlewareTest.php @@ -10,10 +10,12 @@ use Aws\Command; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\IdempotencyTokenMiddleware + */ +#[CoversClass(IdempotencyTokenMiddleware::class)] class IdempotencyTokenMiddlewareTest extends TestCase { public function testAutoFillsMemberWithIdempotencyTrait() diff --git a/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php b/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php index a05a5e3b18..04e119df3d 100644 --- a/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php +++ b/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php @@ -6,10 +6,12 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Identity\S3\S3ExpressIdentityProvider + */ +#[CoversClass(S3ExpressIdentityProvider::class)] class S3ExpressIdentityProviderTest extends TestCase { use UsesServiceTrait; diff --git a/tests/InputValidationMiddlewareTest.php b/tests/InputValidationMiddlewareTest.php index 3d619d8f6a..a2f1f07b71 100644 --- a/tests/InputValidationMiddlewareTest.php +++ b/tests/InputValidationMiddlewareTest.php @@ -10,10 +10,13 @@ use Cassandra\Time; use GuzzleHttp\Psr7\Request; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\InputValidationMiddleware + */ +#[CoversClass(\Aws\InputValidationMiddleware::class)] class InputValidationMiddlewareTest extends TestCase { /** @@ -49,10 +52,11 @@ public static function getValidInputs() } /** - * @dataProvider getInvalidEndpointExceptions * * @param $input - */ + + */ + #[DataProvider('getInvalidEndpointExceptions')] public function testThrowsExceptions($input) { $service = $this->generateTestService(); @@ -81,10 +85,11 @@ public function testThrowsExceptions($input) } /** - * @dataProvider getInvalidEndpointExceptions * * @param $input - */ + + */ + #[DataProvider('getInvalidEndpointExceptions')] public function testNoValidationWithoutInputList($input) { $service = $this->generateTestService(); @@ -104,10 +109,11 @@ public function testNoValidationWithoutInputList($input) } /** - * @dataProvider getValidInputs * * @param $input - */ + + */ + #[DataProvider('getValidInputs')] public function testPassingValidations($input) { $service = $this->generateTestService(); diff --git a/tests/JsonCompilerTest.php b/tests/JsonCompilerTest.php index bca34d2c4f..0d1324132e 100644 --- a/tests/JsonCompilerTest.php +++ b/tests/JsonCompilerTest.php @@ -3,10 +3,12 @@ use Aws\JsonCompiler; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\JsonCompiler + */ +#[CoversClass(JsonCompiler::class)] class JsonCompilerTest extends TestCase { private $models; diff --git a/tests/LexModelsV2/LexModelsV2ClientTest.php b/tests/LexModelsV2/LexModelsV2ClientTest.php index 0eeb5177db..b22abf5755 100644 --- a/tests/LexModelsV2/LexModelsV2ClientTest.php +++ b/tests/LexModelsV2/LexModelsV2ClientTest.php @@ -8,10 +8,12 @@ use GuzzleHttp\Psr7\NoSeekStream; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\LexModelsV2\LexModelsV2Client + */ +#[CoversClass(LexModelsV2Client::class)] class LexModelsV2ClientTest extends TestCase { use UsesServiceTrait; diff --git a/tests/LruArrayCacheTest.php b/tests/LruArrayCacheTest.php index bf50d8d9c9..9d6a0f0298 100644 --- a/tests/LruArrayCacheTest.php +++ b/tests/LruArrayCacheTest.php @@ -3,10 +3,12 @@ use Aws\LruArrayCache; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\LruArrayCache + */ +#[CoversClass(LruArrayCache::class)] class LruArrayCacheTest extends TestCase { public function testSetRemoveAndRetrieve() diff --git a/tests/MachineLearning/MachineLearningClientTest.php b/tests/MachineLearning/MachineLearningClientTest.php index fe6f767af1..94c5f3670c 100644 --- a/tests/MachineLearning/MachineLearningClientTest.php +++ b/tests/MachineLearning/MachineLearningClientTest.php @@ -6,10 +6,12 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7\Uri; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\MachineLearning\MachineLearningClient + */ +#[CoversClass(MachineLearningClient::class)] class MachineLearningClientTest extends TestCase { use UsesServiceTrait; diff --git a/tests/MetricsBuilderTest.php b/tests/MetricsBuilderTest.php index 2880e97f1e..158f45304b 100644 --- a/tests/MetricsBuilderTest.php +++ b/tests/MetricsBuilderTest.php @@ -7,6 +7,7 @@ use Aws\Middleware; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class MetricsBuilderTest extends TestCase { @@ -42,13 +43,8 @@ public function testEncodeMetrics() public function testConstraintsAppendToMetricsSize() { + set_error_handler(static function ( $errno, $errstr ) {}); try { - set_error_handler( - static function ( $errno, $errstr ) { - // Mute warning - }, - E_ALL - ); $metricsBuilder = new MetricsBuilder(); $firstMetric = str_repeat("*", 1024); $metricsBuilder->append($firstMetric); @@ -103,10 +99,11 @@ function ( * @param array $args * @param string $expectedMetrics * - * @dataProvider resolveAndAppendFromArgsProvider * * @return void - */ + + */ + #[DataProvider('resolveAndAppendFromArgsProvider')] public function testResolveAndAppendFromArgs( array $args, string $expectedMetrics, diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index f02829f8d3..8b6c61c014 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -21,10 +21,13 @@ use GuzzleHttp\Promise; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Middleware + */ +#[CoversClass(Middleware::class)] class MiddlewareTest extends TestCase { public function set_up() @@ -395,13 +398,13 @@ function (AwsException $e) { } /** - * @dataProvider recursionDetectionProvider * * @param string|null $functionName * @param string|null $traceId * @param bool $traceHeaderExpected * @param string $traceHeaderExpectedValue - */ + */ + #[DataProvider('recursionDetectionProvider')] public function testRecursionDetection( ?string $functionName, ?string $traceId, diff --git a/tests/MockHandlerTest.php b/tests/MockHandlerTest.php index dd6f04e2de..a438798315 100644 --- a/tests/MockHandlerTest.php +++ b/tests/MockHandlerTest.php @@ -10,10 +10,12 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\MockHandler + */ +#[CoversClass(MockHandler::class)] class MockHandlerTest extends TestCase { public function testValidatesEachResult() diff --git a/tests/MultiRegionClientTest.php b/tests/MultiRegionClientTest.php index a7a39f4414..aadda7da12 100644 --- a/tests/MultiRegionClientTest.php +++ b/tests/MultiRegionClientTest.php @@ -14,6 +14,7 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class MultiRegionClientTest extends TestCase { @@ -110,11 +111,12 @@ public function testProxiesArbitraryCallsToRegionalizedClient() } /** - * @dataProvider clientInterfaceMethodProvider * * @param string $method * @param array $args - */ + + */ + #[DataProvider('clientInterfaceMethodProvider')] public function testProxiesCallsToRegionalizedClient($method, array $args) { $expectation = $this->mockRegionalClient->expects($this->once()) diff --git a/tests/Multipart/AbstractUploaderTest.php b/tests/Multipart/AbstractUploaderTest.php index 784a086e7d..77d73b7e54 100644 --- a/tests/Multipart/AbstractUploaderTest.php +++ b/tests/Multipart/AbstractUploaderTest.php @@ -10,10 +10,13 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Multipart\AbstractUploader + */ +#[CoversClass(AbstractUploader::class)] class AbstractUploaderTest extends TestCase { use UsesServiceTrait; @@ -192,8 +195,9 @@ public function testCanSetSourceFromFilenameIfExists() * @param UploadState $state * @param array $expectedBodies * - * @dataProvider getPartGeneratorTestCases - */ + + */ + #[DataProvider('getPartGeneratorTestCases')] public function testCommandGeneratorYieldsExpectedUploadCommands( $seekable, UploadState $state, diff --git a/tests/Multipart/UploadStateTest.php b/tests/Multipart/UploadStateTest.php index 17081d7d94..88d665a6f0 100644 --- a/tests/Multipart/UploadStateTest.php +++ b/tests/Multipart/UploadStateTest.php @@ -3,10 +3,13 @@ use Aws\Multipart\UploadState; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Multipart\UploadState + */ +#[CoversClass(UploadState::class)] class UploadStateTest extends TestCase { public function testCanManageStatusAndUploadId() @@ -79,8 +82,9 @@ public function testEmptyUploadStateOutputWithConfigFalse() } /** - * @dataProvider getDisplayProgressCases - */ + + */ + #[DataProvider('getDisplayProgressCases')] public function testGetDisplayProgressPrintsProgress( $totalSize, $totalUploaded, @@ -174,8 +178,9 @@ public static function getDisplayProgressCases() } /** - * @dataProvider getThresholdCases - */ + + */ + #[DataProvider('getThresholdCases')] public function testUploadThresholds($totalSize) { $state = new UploadState([]); @@ -195,8 +200,9 @@ public static function getThresholdCases() } /** - * @dataProvider getInvalidIntCases - */ + + */ + #[DataProvider('getInvalidIntCases')] public function testSetProgressThresholdsThrowsException($totalSize) { $state = new UploadState([]); @@ -207,8 +213,9 @@ public function testSetProgressThresholdsThrowsException($totalSize) } /** - * @dataProvider getInvalidIntCases - */ + + */ + #[DataProvider('getInvalidIntCases')] public function testDisplayProgressThrowsException($totalUploaded) { $state = new UploadState([]); diff --git a/tests/Neptune/NeptuneClientTest.php b/tests/Neptune/NeptuneClientTest.php index 8eb152faa1..4e8b093e30 100644 --- a/tests/Neptune/NeptuneClientTest.php +++ b/tests/Neptune/NeptuneClientTest.php @@ -7,11 +7,14 @@ use Aws\Result; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Signature/sig_hack.php'; /** - * @covers Aws\Neptune\NeptuneClient + */ +#[CoversClass(NeptuneClient::class)] class NeptuneClientTest extends TestCase { public static function set_up_before_class() @@ -39,14 +42,15 @@ public static function neptunePresignMethodProvider() } /** - * @dataProvider neptunePresignMethodProvider * * @param string $functionName * @param string $presignedUrl * @param string $sourceRegion * @param string $expectedUrl * @param string $expectedSignature - */ + + */ + #[DataProvider('neptunePresignMethodProvider')] public function testCorrectPresignNeptuneUrls( $functionName, $functionArgs, diff --git a/tests/PhpHashTest.php b/tests/PhpHashTest.php index 461a455bd2..5cefe9d8b9 100644 --- a/tests/PhpHashTest.php +++ b/tests/PhpHashTest.php @@ -3,10 +3,12 @@ use Aws\PhpHash; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\PhpHash + */ +#[CoversClass(PhpHash::class)] class PhpHashTest extends TestCase { public function testHashesData() diff --git a/tests/Polly/PollyClientTest.php b/tests/Polly/PollyClientTest.php index 24ee4883f4..182782d769 100644 --- a/tests/Polly/PollyClientTest.php +++ b/tests/Polly/PollyClientTest.php @@ -4,10 +4,12 @@ use Aws\Credentials\Credentials; use Aws\Polly\PollyClient; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Polly\PollyClient + */ +#[CoversClass(PollyClient::class)] class PollyClientTest extends TestCase { public function testCanGeneratePreSignedUrlForSynthesizeSpeech() diff --git a/tests/PresignUrlMiddlewareTest.php b/tests/PresignUrlMiddlewareTest.php index 71e52410be..611f9d2891 100644 --- a/tests/PresignUrlMiddlewareTest.php +++ b/tests/PresignUrlMiddlewareTest.php @@ -8,10 +8,13 @@ use Aws\Result; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\PresignUrlMiddleware + */ +#[CoversClass(PresignUrlMiddleware::class)] class PresignUrlMiddlewareTest extends TestCase { use UsesServiceTrait; @@ -107,10 +110,11 @@ public function testNoPreSignedUrlWhenDifferentSourceRegionRequired() * @param string $value * @param string $expected * - * @dataProvider extraQueryParamsProvider * * @return void - */ + + */ + #[DataProvider('extraQueryParamsProvider')] public function testExtraQueryParametersAreURLEncoded( string $parameter, string $value, diff --git a/tests/Psr16CacheAdapterTest.php b/tests/Psr16CacheAdapterTest.php index f8512aa0ab..0457a3fc1d 100644 --- a/tests/Psr16CacheAdapterTest.php +++ b/tests/Psr16CacheAdapterTest.php @@ -4,6 +4,7 @@ use Aws\Psr16CacheAdapter; use Psr\SimpleCache\CacheInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class Psr16CacheAdapterTest extends TestCase { @@ -19,11 +20,12 @@ public function set_up() } /** - * @dataProvider cacheDataProvider * * @param string $key * @param mixed $value - */ + + */ + #[DataProvider('cacheDataProvider')] public function testProxiesGetCallsToPsrCache($key, $value) { $this->wrapped->expects($this->once()) @@ -35,12 +37,13 @@ public function testProxiesGetCallsToPsrCache($key, $value) } /** - * @dataProvider cacheDataProvider * * @param string $key * @param mixed $value * @param int|\DateInterval $ttl - */ + + */ + #[DataProvider('cacheDataProvider')] public function testProxiesSetCallsToPsrCache($key, $value, $ttl) { $this->wrapped->expects($this->once()) @@ -52,10 +55,11 @@ public function testProxiesSetCallsToPsrCache($key, $value, $ttl) } /** - * @dataProvider cacheDataProvider * * @param string $key - */ + + */ + #[DataProvider('cacheDataProvider')] public function testProxiesRemoveCallsToPsrCache($key) { $this->wrapped->expects($this->once()) diff --git a/tests/PsrCacheAdapterTest.php b/tests/PsrCacheAdapterTest.php index 91a6743748..bb83c66527 100644 --- a/tests/PsrCacheAdapterTest.php +++ b/tests/PsrCacheAdapterTest.php @@ -5,6 +5,7 @@ use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class PsrCacheAdapterTest extends TestCase { @@ -21,11 +22,12 @@ public function set_up() } /** - * @dataProvider cacheDataProvider * * @param string $key * @param mixed $value - */ + + */ + #[DataProvider('cacheDataProvider')] public function testProxiesGetCallsToPsrCache($key, $value) { $item = $this->getMockBuilder(CacheItemInterface::class)->getMock(); @@ -45,12 +47,13 @@ public function testProxiesGetCallsToPsrCache($key, $value) } /** - * @dataProvider cacheDataProvider * * @param string $key * @param mixed $value * @param int|\DateInterval $ttl - */ + + */ + #[DataProvider('cacheDataProvider')] public function testProxiesSetCallsToPsrCache($key, $value, $ttl) { $item = $this->getMockBuilder(CacheItemInterface::class)->getMock(); @@ -76,10 +79,11 @@ public function testProxiesSetCallsToPsrCache($key, $value, $ttl) } /** - * @dataProvider cacheDataProvider * * @param string $key - */ + + */ + #[DataProvider('cacheDataProvider')] public function testProxiesRemoveCallsToPsrCache($key) { $this->wrapped->expects($this->once()) diff --git a/tests/QueryCompatibleInputMiddlewareTest.php b/tests/QueryCompatibleInputMiddlewareTest.php index d6460a2b90..18d1d22328 100644 --- a/tests/QueryCompatibleInputMiddlewareTest.php +++ b/tests/QueryCompatibleInputMiddlewareTest.php @@ -8,44 +8,56 @@ use Aws\MockHandler; use Aws\Result; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\QueryCompatibleInputMiddleware + */ +#[CoversClass(\Aws\QueryCompatibleInputMiddleware::class)] class QueryCompatibleInputMiddlewareTest extends TestCase { /** - * @dataProvider getInputs() * * @param $inputParam * @param $inputValue * @param $expected * @param $type - */ + + */ + #[DataProvider('getInputsDataProvider')] public function testEmitsWarning($inputParam, $inputValue, $expected, $type) { - $this->expectWarning(); - $this->expectWarningMessage( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( "The provided type for `{$inputParam}` value was `" . (gettype($inputValue) === 'double' ? 'float' : gettype($inputValue)) . "`. The modeled type is `{$type}`." ); - $service = $this->generateTestService(); - $client = $this->generateTestClient($service); - $command = $client->getCommand( - 'FooOperation', - [$inputParam => $inputValue] - ); - $client->execute($command); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); + try { + $service = $this->generateTestService(); + $client = $this->generateTestClient($service); + $command = $client->getCommand( + 'FooOperation', + [$inputParam => $inputValue] + ); + $client->execute($command); + } finally { + restore_error_handler(); + } } /** - * @dataProvider getInputs() * * @param $inputParam * @param $inputValue * @param $expected - */ + + */ + #[DataProvider('getInputsDataProvider')] public function testAppliesMiddlewareAndCastsValues($inputParam, $inputValue, $expected) { $service = $this->generateTestService(); @@ -68,7 +80,7 @@ function (Command $command) use ($inputParam, $expected) { * * @return array */ - public static function getInputs() + public static function getInputsDataProvider(): array { return [ ['IntParam', '10', 10, 'integer'], diff --git a/tests/Rds/AuthTokenGeneratorTest.php b/tests/Rds/AuthTokenGeneratorTest.php index bcb02fd1f0..7a587c594e 100644 --- a/tests/Rds/AuthTokenGeneratorTest.php +++ b/tests/Rds/AuthTokenGeneratorTest.php @@ -5,10 +5,13 @@ use Aws\Rds\AuthTokenGenerator; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Rds\AuthTokenGenerator + */ +#[CoversClass(AuthTokenGenerator::class)] class AuthTokenGeneratorTest extends TestCase { public function testCanCreateAuthTokenWthCredentialInstance() @@ -67,10 +70,11 @@ public static function lifetimeProvider() } /** - * @dataProvider lifetimeProvider * * @param $lifetime - */ + + */ + #[DataProvider('lifetimeProvider')] public function testCanCreateAuthTokenWthNonDefaultLifetime($lifetime) { $creds = new Credentials('foo', 'bar', 'baz'); @@ -105,10 +109,11 @@ public static function lifetimeFailureProvider() } /** - * @dataProvider lifetimeFailureProvider * * @param $lifetime - */ + + */ + #[DataProvider('lifetimeFailureProvider')] public function testThrowsExceptionWithInvalidLifetime($lifetime) { $this->expectExceptionMessage("Lifetime must be a positive number less than or equal to 15, was"); diff --git a/tests/Rds/RdsClientTest.php b/tests/Rds/RdsClientTest.php index 6de3885773..cdade290eb 100644 --- a/tests/Rds/RdsClientTest.php +++ b/tests/Rds/RdsClientTest.php @@ -8,11 +8,14 @@ use Aws\Result; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Signature/sig_hack.php'; /** - * @covers Aws\Rds\RdsClient + */ +#[CoversClass(RdsClient::class)] class RdsClientTest extends TestCase { public static function set_up_before_class() @@ -72,14 +75,15 @@ public static function rdsPresignMethodProvider() } /** - * @dataProvider rdsPresignMethodProvider * * @param string $functionName * @param string $presignedUrl * @param string $sourceRegion * @param string $expectedUrl * @param string $expectedSignature - */ + + */ + #[DataProvider('rdsPresignMethodProvider')] public function testCorrectPresignRdsUrls( $functionName, $functionArgs, diff --git a/tests/RequestCompression/RequestCompressionMiddlewareTest.php b/tests/RequestCompression/RequestCompressionMiddlewareTest.php index ff82fb18b8..eaa190d79a 100644 --- a/tests/RequestCompression/RequestCompressionMiddlewareTest.php +++ b/tests/RequestCompression/RequestCompressionMiddlewareTest.php @@ -8,6 +8,7 @@ use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class RequestCompressionMiddlewareTest extends TestCase { @@ -46,14 +47,21 @@ public function testDoesNotCompressRequestWhenConfigured() $list->appendSign(Middleware::tap(function($cmd, $req) { $body = $req->getBody()->getContents(); $this->assertEmpty($req->getHeader('content-encoding')); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); gzdecode($body); })); - $client->putMetricData([ - 'MetricData' => $metricData, - 'Namespace' => 'foo' - ]); + try { + $client->putMetricData([ + 'MetricData' => $metricData, + 'Namespace' => 'foo' + ]); + } finally { + restore_error_handler(); + } } public static function specificSizeProvider() @@ -67,12 +75,13 @@ public static function specificSizeProvider() } /** - * @dataProvider specificSizeProvider * * @param $minSize * @param $numMetricData * @param $expectedBodySize - */ + + */ + #[DataProvider('specificSizeProvider')] public function testCompressesRequestAtSpecificSize($minSize, $numMetricData, $expectedBodySize) { $service = $this->generateTestService(); @@ -140,15 +149,22 @@ public function testCommandLevelDisableRequestCompressionOverrides() $list->appendSign(Middleware::tap(function($cmd, $req) { $body = $req->getBody()->getContents(); $this->assertEmpty($req->getHeader('content-encoding')); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); gzdecode($body); })); - $client->putMetricData([ - 'MetricData' => $metricData, - 'Namespace' => 'foo', - '@disable_request_compression' => true - ]); + try { + $client->putMetricData([ + 'MetricData' => $metricData, + 'Namespace' => 'foo', + '@disable_request_compression' => true + ]); + } finally { + restore_error_handler(); + } } public function testCommandLevelMinRequestSizeOverrides() @@ -161,15 +177,22 @@ public function testCommandLevelMinRequestSizeOverrides() $list->appendSign(Middleware::tap(function($cmd, $req) { $body = $req->getBody()->getContents(); $this->assertEmpty($req->getHeader('content-encoding')); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); gzdecode($body); })); - $client->putMetricData([ - 'MetricData' => $metricData, - 'Namespace' => 'foo', - '@request_min_compression_size_bytes' => 10485760 - ]); + try { + $client->putMetricData([ + 'MetricData' => $metricData, + 'Namespace' => 'foo', + '@request_min_compression_size_bytes' => 10485760 + ]); + } finally { + restore_error_handler(); + } } public static function invalidDisableCompressionType() @@ -181,10 +204,11 @@ public static function invalidDisableCompressionType() } /** - * @dataProvider invalidDisableCompressionType * * @param $invalidType - */ + + */ + #[DataProvider('invalidDisableCompressionType')] public function testThrowsExceptionWhenDisableMinCompressionNotBool($invalidType) { $this->expectException(\InvalidArgumentException::class); @@ -203,10 +227,11 @@ public static function invalidMinRequestSizeProvider() } /** - * @dataProvider invalidMinRequestSizeProvider * * @param $minRequestSize - */ + + */ + #[DataProvider('invalidMinRequestSizeProvider')] public function testThrowsExceptionWhenInvalidMinCompressionSizeOnClient($minRequestSize) { if (is_int($minRequestSize)) { @@ -227,10 +252,11 @@ public function testThrowsExceptionWhenInvalidMinCompressionSizeOnClient($minReq } /** - * @dataProvider invalidMinRequestSizeProvider * * @param $minRequestSize - */ + + */ + #[DataProvider('invalidMinRequestSizeProvider')] public function testThrowsExceptionWhenInvalidMinCompressionSize($minRequestSize) { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/ResultPaginatorTest.php b/tests/ResultPaginatorTest.php index 9cf1e77470..d6f21fd041 100644 --- a/tests/ResultPaginatorTest.php +++ b/tests/ResultPaginatorTest.php @@ -12,10 +12,13 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\ResultPaginator + */ +#[CoversClass(ResultPaginator::class)] class ResultPaginatorTest extends TestCase { use UsesServiceTrait; @@ -42,8 +45,9 @@ private function getCustomClientProvider(array $config) } /** - * @dataProvider getPaginatorIterationData - */ + + */ + #[DataProvider('getPaginatorIterationData')] public function testStandardIterationWorkflow( array $config, array $results, @@ -78,8 +82,9 @@ function () use (&$requestCount) { } /** - * @dataProvider getPaginatorIterationData - */ + + */ + #[DataProvider('getPaginatorIterationData')] public function testAsyncWorkflow( array $config, array $results, diff --git a/tests/ResultTest.php b/tests/ResultTest.php index 633009e40d..9ba3958be8 100644 --- a/tests/ResultTest.php +++ b/tests/ResultTest.php @@ -3,10 +3,12 @@ use Aws\Result; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Result + */ +#[CoversClass(Result::class)] class ResultTest extends TestCase { public function testHasData() diff --git a/tests/Retry/ConfigurationProviderTest.php b/tests/Retry/ConfigurationProviderTest.php index 846f17e68d..e9d1510221 100644 --- a/tests/Retry/ConfigurationProviderTest.php +++ b/tests/Retry/ConfigurationProviderTest.php @@ -9,10 +9,13 @@ use Aws\Retry\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Retry\ConfigurationProvider + */ +#[CoversClass(\Aws\Retry\ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -401,10 +404,11 @@ function () use ($expected) { } /** - * @dataProvider getSuccessfulUnwrapData * @param $toUnwrap * @param ConfigurationInterface $expected - */ + + */ + #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { $this->assertSame( diff --git a/tests/Retry/ConfigurationTest.php b/tests/Retry/ConfigurationTest.php index 312b1d47de..cfed8aab7f 100644 --- a/tests/Retry/ConfigurationTest.php +++ b/tests/Retry/ConfigurationTest.php @@ -4,10 +4,12 @@ use Aws\Retry\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Retry\Configuration + */ +#[CoversClass(\Aws\Retry\Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/Retry/QuotaManagerTest.php b/tests/Retry/QuotaManagerTest.php index 97b691fc94..d9ecbf8dfc 100644 --- a/tests/Retry/QuotaManagerTest.php +++ b/tests/Retry/QuotaManagerTest.php @@ -7,10 +7,12 @@ use Aws\Result; use Aws\Retry\QuotaManager; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Retry\QuotaManager + */ +#[CoversClass(\Aws\Retry\QuotaManager::class)] class QuotaManagerTest extends TestCase { public function testReturnsFalseWithNoCapacity() diff --git a/tests/Retry/RateLimiterTest.php b/tests/Retry/RateLimiterTest.php index 4f211b308b..a690ec35e3 100644 --- a/tests/Retry/RateLimiterTest.php +++ b/tests/Retry/RateLimiterTest.php @@ -4,10 +4,13 @@ use Aws\Retry\RateLimiter; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Retry\RateLimiter + */ +#[CoversClass(\Aws\Retry\RateLimiter::class)] class RateLimiterTest extends TestCase { /** @@ -64,12 +67,13 @@ public static function cubicSuccessProvider() } /** - * @dataProvider cubicSuccessProvider * * @param $timestamp * @param $expectedRate * @throws \ReflectionException - */ + + */ + #[DataProvider('cubicSuccessProvider')] public function testCalculatesCubicSuccessValues($timestamp, $expectedRate) { $rateLimiter = new RateLimiter(); diff --git a/tests/RetryMiddlewareTest.php b/tests/RetryMiddlewareTest.php index 8a021016d3..fa8a15aa8e 100644 --- a/tests/RetryMiddlewareTest.php +++ b/tests/RetryMiddlewareTest.php @@ -15,10 +15,13 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\RetryMiddleware + */ +#[CoversClass(RetryMiddleware::class)] class RetryMiddlewareTest extends TestCase { public function testAddRetryHeader() @@ -168,8 +171,9 @@ public static function awsErrorCodeProvider() /** * @param $err * - * @dataProvider awsErrorCodeProvider - */ + + */ + #[DataProvider('awsErrorCodeProvider')] public function testDeciderRetriesWhenAwsErrorCodeMatches($err) { $decider = RetryMiddleware::createDefaultDecider(); diff --git a/tests/RetryMiddlewareV2Test.php b/tests/RetryMiddlewareV2Test.php index ef214ec077..4389897542 100644 --- a/tests/RetryMiddlewareV2Test.php +++ b/tests/RetryMiddlewareV2Test.php @@ -19,16 +19,18 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\RetryMiddlewareV2 + */ +#[CoversClass(\Aws\RetryMiddlewareV2::class)] class RetryMiddlewareV2Test extends TestCase { use UsesServiceTrait; /** - * @dataProvider standardModeTestCases * * @param CommandInterface $command * @param QuotaManager $quotaManager @@ -36,7 +38,9 @@ class RetryMiddlewareV2Test extends TestCase * @param array $options * @param $expected * @throws \Exception - */ + + */ + #[DataProvider('standardModeTestCases')] public function testRetriesForStandardMode( CommandInterface $command, QuotaManager $quotaManager, @@ -602,8 +606,9 @@ public static function awsErrorCodeProvider() /** * @param $err * - * @dataProvider awsErrorCodeProvider - */ + + */ + #[DataProvider('awsErrorCodeProvider')] public function testDeciderRetriesWhenAwsErrorCodeMatches($err) { $decider = RetryMiddlewareV2::createDefaultDecider(new QuotaManager()); diff --git a/tests/Route53/RouteClient53Test.php b/tests/Route53/RouteClient53Test.php index 88dde9306c..81c5bc0d2f 100644 --- a/tests/Route53/RouteClient53Test.php +++ b/tests/Route53/RouteClient53Test.php @@ -3,10 +3,12 @@ use Aws\Route53\Route53Client; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Route53\Route53Client + */ +#[CoversClass(Route53Client::class)] class RouteClient53Test extends TestCase { public function testCleansIds() diff --git a/tests/S3/AmbiguousSuccessParserTest.php b/tests/S3/AmbiguousSuccessParserTest.php index 2f96c0e087..7603b892d4 100644 --- a/tests/S3/AmbiguousSuccessParserTest.php +++ b/tests/S3/AmbiguousSuccessParserTest.php @@ -10,6 +10,7 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\ResponseInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AmbiguousSuccessParserTest extends TestCase { @@ -30,10 +31,11 @@ public function set_up() } /** - * @dataProvider opsWithAmbiguousSuccessesProvider * * @param string $operation - */ + + */ + #[DataProvider('opsWithAmbiguousSuccessesProvider')] public function testConvertsAmbiguousSuccessesToExceptions($operation) { $this->expectExceptionMessage("Sorry!"); @@ -52,10 +54,11 @@ public function testConvertsAmbiguousSuccessesToExceptions($operation) } /** - * @dataProvider opsWithoutAmbiguousSuccessesProvider * @param string $operation * @doesNotPerformAssertions - */ + + */ + #[DataProvider('opsWithoutAmbiguousSuccessesProvider')] public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations($operation) { $command = $this->getMockBuilder(CommandInterface::class)->getMock(); @@ -72,8 +75,9 @@ public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations($operation) } /** - * @dataProvider opsWithAmbiguousSuccessesProvider - */ + + */ + #[DataProvider('opsWithAmbiguousSuccessesProvider')] public function testThrowsConnectionErrorForEmptyBody($operation) { $this->expectExceptionMessage("An error connecting to the service occurred while performing the"); diff --git a/tests/S3/ApplyChecksumMiddlewareTest.php b/tests/S3/ApplyChecksumMiddlewareTest.php index c411f74bf8..8198d2cdff 100644 --- a/tests/S3/ApplyChecksumMiddlewareTest.php +++ b/tests/S3/ApplyChecksumMiddlewareTest.php @@ -5,17 +5,21 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\ApplyChecksumMiddleware + */ +#[CoversClass(ApplyChecksumMiddleware::class)] class ApplyChecksumMiddlewareTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider getFlexibleChecksumUseCases - */ + + */ + #[DataProvider('getFlexibleChecksumUseCases')] public function testFlexibleChecksums( $operation, $config, @@ -198,8 +202,9 @@ public static function getFlexibleChecksumUseCases() } /** - * @dataProvider getContentSha256UseCases - */ + + */ + #[DataProvider('getContentSha256UseCases')] public function testAddsContentSHA256($operation, $args, $hashAdded, $hashValue) { $client = $this->getTestClient('s3'); @@ -251,16 +256,20 @@ public function testAddContentMd5EmitsDeprecationWarning() }); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); - $client = $this->getTestClient('s3'); - $nextHandler = function ($cmd, $request) { - $this->assertTrue($request->hasHeader('x-amz-checksum-crc32')); - }; - $service = $client->getApi(); - $mw = new ApplyChecksumMiddleware($nextHandler, $service); - $command = $client->getCommand('putObject', ['AddContentMD5' => true]); - $request = new Request('PUT', 'foo'); + try { + $client = $this->getTestClient('s3'); + $nextHandler = function ($cmd, $request) { + $this->assertTrue($request->hasHeader('x-amz-checksum-crc32')); + }; + $service = $client->getApi(); + $mw = new ApplyChecksumMiddleware($nextHandler, $service); + $command = $client->getCommand('putObject', ['AddContentMD5' => true]); + $request = new Request('PUT', 'foo'); - $mw($command, $request); + $mw($command, $request); + } finally { + restore_error_handler(); + } } public function testInvalidChecksumThrows() diff --git a/tests/S3/BatchDeleteTest.php b/tests/S3/BatchDeleteTest.php index f6d6bbd561..989db26c53 100644 --- a/tests/S3/BatchDeleteTest.php +++ b/tests/S3/BatchDeleteTest.php @@ -8,10 +8,12 @@ use Aws\S3\Exception\DeleteMultipleObjectsException; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\S3\BatchDelete + */ +#[CoversClass(\Aws\S3\BatchDelete::class)] class BatchDeleteTest extends TestCase { use UsesServiceTrait; diff --git a/tests/S3/BucketEndpointArnMiddlewareTest.php b/tests/S3/BucketEndpointArnMiddlewareTest.php index 1ef7f33185..eb65488ed1 100644 --- a/tests/S3/BucketEndpointArnMiddlewareTest.php +++ b/tests/S3/BucketEndpointArnMiddlewareTest.php @@ -13,16 +13,18 @@ use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\S3\BucketEndpointMiddleware + */ +#[CoversClass(\Aws\S3\BucketEndpointMiddleware::class)] class BucketEndpointArnMiddlewareTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider accessPointArnCases * * @param $arn * @param $options @@ -31,7 +33,9 @@ class BucketEndpointArnMiddlewareTest extends TestCase * @param $signingRegion * @param $signingService * @throws \Exception - */ + + */ + #[DataProvider('accessPointArnCases')] public function testCorrectlyModifiesUri( $arn, $options, @@ -330,12 +334,13 @@ public static function accessPointArnCases() } /** - * @dataProvider incorrectUsageProvider * * @param CommandInterface $command * @param array $config * @param \Exception $expected - */ + + */ + #[DataProvider('incorrectUsageProvider')] public function testThrowsForIncorrectArnUsage($command, $config, \Exception $expected) { try { diff --git a/tests/S3/BucketEndpointMiddlewareTest.php b/tests/S3/BucketEndpointMiddlewareTest.php index a55fddfb0e..449c6e513c 100644 --- a/tests/S3/BucketEndpointMiddlewareTest.php +++ b/tests/S3/BucketEndpointMiddlewareTest.php @@ -4,10 +4,13 @@ use Aws\Middleware; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\BucketEndpointMiddleware + */ +#[CoversClass(BucketEndpointMiddleware::class)] class BucketEndpointMiddlewareTest extends TestCase { use UsesServiceTrait; @@ -151,10 +154,11 @@ public static function keyContainsBucketNameProvider(): iterable } /** - * @dataProvider keyContainsBucketNameProvider * * @param $key - */ + + */ + #[DataProvider('keyContainsBucketNameProvider')] public function testsHandlesDuplicatePathWithKeyContainsBucketName($key): void { $s3 = $this->getTestClient('s3', [ diff --git a/tests/S3/Crypto/HeadersMetadataStrategyTest.php b/tests/S3/Crypto/HeadersMetadataStrategyTest.php index 1115675b07..9985f55c6e 100644 --- a/tests/S3/Crypto/HeadersMetadataStrategyTest.php +++ b/tests/S3/Crypto/HeadersMetadataStrategyTest.php @@ -4,17 +4,21 @@ use Aws\S3\Crypto\HeadersMetadataStrategy; use Aws\Test\Crypto\UsesMetadataEnvelopeTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\Crypto\HeadersMetadataStrategy + */ +#[CoversClass(HeadersMetadataStrategy::class)] class HeadersMetadataStrategyTest extends TestCase { use UsesMetadataEnvelopeTrait; /** - * @dataProvider getMetadataFields - */ + + */ + #[DataProvider('getMetadataFields')] public function testSave($fields) { $strategy = new HeadersMetadataStrategy(); @@ -30,8 +34,9 @@ public function testSave($fields) } /** - * @dataProvider getMetadataResult - */ + + */ + #[DataProvider('getMetadataResult')] public function testLoad($args, $metadata) { $strategy = new HeadersMetadataStrategy(); diff --git a/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php b/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php index d063fc0eb6..366d8273e4 100644 --- a/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php +++ b/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php @@ -8,17 +8,21 @@ use Aws\Test\Crypto\UsesMetadataEnvelopeTrait; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\Crypto\InstructionFileMetadataStrategy + */ +#[CoversClass(InstructionFileMetadataStrategy::class)] class InstructionFileMetadataStrategyTest extends TestCase { use UsesMetadataEnvelopeTrait, UsesServiceTrait; /** - * @dataProvider getMetadataFields - */ + + */ + #[DataProvider('getMetadataFields')] public function testSave($fields) { /** @var S3Client $client */ @@ -46,8 +50,9 @@ public function testSave($fields) /** * Tests that only required data gets saved to the instruction file * and other data is left to the object metadata headers - * @dataProvider getV3MetadataFields - */ + + */ + #[DataProvider('getV3MetadataFields')] public function testSaveV3MetadataEnvelope($fields): void { /** @var S3Client $client */ @@ -110,8 +115,9 @@ public function testSaveV3MetadataEnvelope($fields): void } /** - * @dataProvider getMetadataResult - */ + + */ + #[DataProvider('getMetadataResult')] public function testLoad($args, $metadata) { /** @var S3Client $client */ @@ -136,8 +142,9 @@ public function testLoad($args, $metadata) } /** - * @dataProvider getV3FieldsForInstructionFile - */ + + */ + #[DataProvider('getV3FieldsForInstructionFile')] public function testLoadV3FromInstructionFileAndMetadata($args, $instructionFile): void { /** @var S3Client $client */ @@ -166,8 +173,9 @@ public function testLoadV3FromInstructionFileAndMetadata($args, $instructionFile } /** - * @dataProvider getV3MetadataResult - */ + + */ + #[DataProvider('getV3MetadataResult')] public function testLoadV3FromInstructionFileAndMetadataCorruptInstructionFile($args, $instructionFile) { /** @var S3Client $client */ @@ -184,8 +192,9 @@ public function testLoadV3FromInstructionFileAndMetadataCorruptInstructionFile($ } /** - * @dataProvider getMetadataResult - */ + + */ + #[DataProvider('getMetadataResult')] public function testLoadV2FromInstructionFileAndMetadataCorruptInstructionFile($args, $instructionFile) { /** @var S3Client $client */ @@ -204,8 +213,9 @@ public function testLoadV2FromInstructionFileAndMetadataCorruptInstructionFile($ } /** - * @dataProvider getMetadataResult - */ + + */ + #[DataProvider('getMetadataResult')] public function testLoadV2FromInstructionFileAndMetadataInvalidJson($args, $instructionFile) { /** @var S3Client $client */ diff --git a/tests/S3/Crypto/S3EncryptionClientTest.php b/tests/S3/Crypto/S3EncryptionClientTest.php index c79fe3c29a..84eeb4d774 100644 --- a/tests/S3/Crypto/S3EncryptionClientTest.php +++ b/tests/S3/Crypto/S3EncryptionClientTest.php @@ -22,6 +22,7 @@ use Aws\Test\MetricsBuilderTestTrait; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class S3EncryptionClientTest extends TestCase { @@ -62,8 +63,9 @@ private function setupProvidedExpectedException($exception) } /** - * @dataProvider getValidMaterialsProviders - */ + + */ + #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, $exception @@ -96,8 +98,9 @@ public function testPutObjectTakesValidMaterialsProviders( } /** - * @dataProvider getInvalidMaterialsProviders - */ + + */ + #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, $exception @@ -121,8 +124,9 @@ public function testPutObjectRejectsInvalidMaterialsProviders( } /** - * @dataProvider getValidMetadataStrategies - */ + + */ + #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, $exception, @@ -162,8 +166,9 @@ public function testPutObjectTakesValidMetadataStrategy( } /** - * @dataProvider getInvalidMetadataStrategies - */ + + */ + #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy($strategy, $exception) { if ($exception) { @@ -250,8 +255,9 @@ public function testPutObjectWithOperationInstructionFileSuffix() } /** - * @dataProvider getCiphers - */ + + */ + #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, $exception = null, @@ -287,8 +293,9 @@ public function testPutObjectValidatesCipher( } /** - * @dataProvider getKeySizes - */ + + */ + #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, $exception @@ -710,8 +717,11 @@ public function testGetObjectSavesFile() */ public function testTriggersWarningForGcmEncryptionWithAad() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("'Aad' has been supplied for content encryption with AES/GCM/NoPadding"); - $this->expectWarning(); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }, E_USER_WARNING); $s3 = new S3Client([ 'region' => 'us-west-2', 'version' => 'latest', @@ -724,28 +734,32 @@ public function testTriggersWarningForGcmEncryptionWithAad() }, ]); - $kms = $this->getKmsClient(); - $keyId = '11111111-2222-3333-4444-555555555555'; - $provider = new KmsMaterialsProvider($kms, $keyId); - $this->addMockResults($kms, [ - new Result([ - 'CiphertextBlob' => 'encrypted', - 'Plaintext' => random_bytes(32), - ]) - ]); - - $client = @new S3EncryptionClient($s3); - $client->putObject([ - 'Bucket' => 'foo', - 'Key' => 'bar', - 'Body' => 'test', - '@MaterialsProvider' => $provider, - '@CipherOptions' => [ - 'Cipher' => 'gcm', - 'Aad' => 'test' - ], - ]); - $this->assertTrue($this->mockQueueEmpty()); + try { + $kms = $this->getKmsClient(); + $keyId = '11111111-2222-3333-4444-555555555555'; + $provider = new KmsMaterialsProvider($kms, $keyId); + $this->addMockResults($kms, [ + new Result([ + 'CiphertextBlob' => 'encrypted', + 'Plaintext' => random_bytes(32), + ]) + ]); + + $client = @new S3EncryptionClient($s3); + $client->putObject([ + 'Bucket' => 'foo', + 'Key' => 'bar', + 'Body' => 'test', + '@MaterialsProvider' => $provider, + '@CipherOptions' => [ + 'Cipher' => 'gcm', + 'Aad' => 'test' + ], + ]); + $this->assertTrue($this->mockQueueEmpty()); + } finally { + restore_error_handler(); + } } public function testAppendsMetricsCaptureMiddleware() diff --git a/tests/S3/Crypto/S3EncryptionClientV2Test.php b/tests/S3/Crypto/S3EncryptionClientV2Test.php index 76492b2f81..60766ffcc1 100644 --- a/tests/S3/Crypto/S3EncryptionClientV2Test.php +++ b/tests/S3/Crypto/S3EncryptionClientV2Test.php @@ -21,6 +21,7 @@ use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; class S3EncryptionClientV2Test extends TestCase { @@ -61,8 +62,9 @@ private function setupProvidedExpectedException($exception) } /** - * @dataProvider getValidMaterialsProviders - */ + + */ + #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, $exception @@ -99,8 +101,9 @@ public function testPutObjectTakesValidMaterialsProviders( } /** - * @dataProvider getInvalidMaterialsProviders - */ + + */ + #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, $exception @@ -125,8 +128,9 @@ public function testPutObjectRejectsInvalidMaterialsProviders( } /** - * @dataProvider getValidMetadataStrategies - */ + + */ + #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, $exception, @@ -170,8 +174,9 @@ public function testPutObjectTakesValidMetadataStrategy( } /** - * @dataProvider getInvalidMetadataStrategies - */ + + */ + #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy($strategy, $exception) { if ($exception) { @@ -267,8 +272,9 @@ public function testPutObjectWithOperationInstructionFileSuffix() } /** - * @dataProvider getCiphers - */ + + */ + #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, $exception = null @@ -308,8 +314,9 @@ public function testPutObjectValidatesCipher( } /** - * @dataProvider getKeySizes - */ + + */ + #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, $exception @@ -418,8 +425,11 @@ public function testPutObjectWrapsBodyInAesGcmEncryptingStream() */ public function testTriggersWarningForGcmEncryptionWithAad() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("'Aad' has been supplied for content encryption with AES/GCM/NoPadding"); - $this->expectWarning(); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }, E_USER_WARNING); $s3 = new S3Client([ 'region' => 'us-west-2', 'version' => 'latest', @@ -432,29 +442,33 @@ public function testTriggersWarningForGcmEncryptionWithAad() }, ]); - $kms = $this->getKmsClient(); - $keyId = '11111111-2222-3333-4444-555555555555'; - $provider = new KmsMaterialsProviderV2($kms, $keyId); - $this->addMockResults($kms, [ - new Result([ - 'CiphertextBlob' => 'encrypted', - 'Plaintext' => random_bytes(32), - ]) - ]); - - $client = @new S3EncryptionClientV2($s3); - $client->putObject([ - 'Bucket' => 'foo', - 'Key' => 'bar', - 'Body' => 'test', - '@MaterialsProvider' => $provider, - '@CipherOptions' => [ - 'Cipher' => 'gcm', - 'Aad' => 'test' - ], - '@KmsEncryptionContext' => [], - ]); - $this->assertTrue($this->mockQueueEmpty()); + try { + $kms = $this->getKmsClient(); + $keyId = '11111111-2222-3333-4444-555555555555'; + $provider = new KmsMaterialsProviderV2($kms, $keyId); + $this->addMockResults($kms, [ + new Result([ + 'CiphertextBlob' => 'encrypted', + 'Plaintext' => random_bytes(32), + ]) + ]); + + $client = @new S3EncryptionClientV2($s3); + $client->putObject([ + 'Bucket' => 'foo', + 'Key' => 'bar', + 'Body' => 'test', + '@MaterialsProvider' => $provider, + '@CipherOptions' => [ + 'Cipher' => 'gcm', + 'Aad' => 'test' + ], + '@KmsEncryptionContext' => [], + ]); + $this->assertTrue($this->mockQueueEmpty()); + } finally { + restore_error_handler(); + } } public function testAddsEncryptionContextForKms() @@ -917,8 +931,11 @@ public function testGetObjectSavesFile() public function testEmitsWarningForLegacySecurityProfile() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("This S3 Encryption Client operation is configured to read encrypted data with legacy encryption modes"); - $this->expectWarning(); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }, E_USER_WARNING); $kms = $this->getKmsClient(); $list = $kms->getHandlerList(); $list->setHandler(function($cmd, $req) { @@ -934,31 +951,35 @@ public function testEmitsWarningForLegacySecurityProfile() new Result(['Plaintext' => random_bytes(32)]) ); }); - $providerV1 = new KmsMaterialsProvider($kms); - $providerV2 = new KmsMaterialsProviderV2($kms); - - $s3 = new S3Client([ - 'region' => 'us-west-2', - 'version' => 'latest', - 'http_handler' => function () use ($providerV1) { - return new FulfilledPromise(new Response( - 200, - $this->getFieldsAsMetaHeaders( - $this->getValidV1CbcMetadataFields($providerV1) - ), - 'test' - )); - }, - ]); - - $client = @new S3EncryptionClientV2($s3); - $client->getObject([ - 'Bucket' => 'foo', - 'Key' => 'bar', - '@MaterialsProvider' => $providerV2, - '@CommitmentPolicy' => 'FORBID_ENCRYPT_ALLOW_DECRYPT', - '@SecurityProfile' => 'V2_AND_LEGACY', - ]); + try { + $providerV1 = new KmsMaterialsProvider($kms); + $providerV2 = new KmsMaterialsProviderV2($kms); + + $s3 = new S3Client([ + 'region' => 'us-west-2', + 'version' => 'latest', + 'http_handler' => function () use ($providerV1) { + return new FulfilledPromise(new Response( + 200, + $this->getFieldsAsMetaHeaders( + $this->getValidV1CbcMetadataFields($providerV1) + ), + 'test' + )); + }, + ]); + + $client = @new S3EncryptionClientV2($s3); + $client->getObject([ + 'Bucket' => 'foo', + 'Key' => 'bar', + '@MaterialsProvider' => $providerV2, + '@CommitmentPolicy' => 'FORBID_ENCRYPT_ALLOW_DECRYPT', + '@SecurityProfile' => 'V2_AND_LEGACY', + ]); + } finally { + restore_error_handler(); + } } public function testThrowsForV2ProfileAndLegacyObject() diff --git a/tests/S3/Crypto/S3EncryptionClientV3Test.php b/tests/S3/Crypto/S3EncryptionClientV3Test.php index 780fbfc6ce..81d9a96dee 100644 --- a/tests/S3/Crypto/S3EncryptionClientV3Test.php +++ b/tests/S3/Crypto/S3EncryptionClientV3Test.php @@ -20,9 +20,12 @@ use GuzzleHttp\Promise; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\Attributes\CoversNothing; use TypeError; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; class S3EncryptionClientV3Test extends TestCase { @@ -55,8 +58,9 @@ protected function getKmsClient(): mixed } /** - * @dataProvider getValidMaterialsProviders - */ + + */ + #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, $exception @@ -97,8 +101,9 @@ public function testPutObjectTakesValidMaterialsProviders( } /** - * @dataProvider getInvalidMaterialsProviders - */ + + */ + #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, $exception @@ -126,8 +131,9 @@ public function testPutObjectRejectsInvalidMaterialsProviders( } /** - * @dataProvider getValidMetadataStrategies - */ + + */ + #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, $exception, @@ -175,8 +181,9 @@ public function testPutObjectTakesValidMetadataStrategy( } /** - * @dataProvider getInvalidMetadataStrategies - */ + + */ + #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy( $strategy, $exception @@ -286,9 +293,7 @@ public function testPutObjectWithOperationInstructionFileSuffix(): void /** * Test that by default, S3EC stores content metadata in S3 Object Metadata (headers) * This verifies the specification requirement that metadata is stored in object headers by default. - * - * @covers \Aws\S3\Crypto\S3EncryptionClientV3::putObject - */ + * */ public function testV2MetadataStorageInObjectHeaders(): void { $s3 = new S3Client([ @@ -343,8 +348,9 @@ public function testV2MetadataStorageInObjectHeaders(): void * Test that by default, S3EC stores content metadata in S3 Object Metadata (headers) * This verifies the specification requirement that metadata is stored in object headers by default. * - * @covers \Aws\S3\Crypto\S3EncryptionClientV3::putObject - */ + + */ + #[CoversClass(\Aws\S3\Crypto\S3EncryptionClientV3::putObject::class)] public function testV3MetadataStorageInObjectHeaders(): void { $s3 = new S3Client([ @@ -401,8 +407,9 @@ public function testV3MetadataStorageInObjectHeaders(): void * Test that the default metadata strategy does not write instruction files * This verifies the specification requirement that instruction files are not enabled by default. * - * @covers \Aws\S3\Crypto\S3EncryptionClientV3::putObject - */ + + */ + #[CoversClass(\Aws\S3\Crypto\S3EncryptionClientV3::putObject::class)] public function testDefaultMetadataStrategyDoesNotWriteInstructionFile(): void { $requestCount = 0; @@ -534,8 +541,9 @@ public function testDefaultVsInstructionFileMetadataStorage(): void } /** - * @dataProvider getCiphers - */ + + */ + #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, $exception = null @@ -578,8 +586,9 @@ public function testPutObjectValidatesCipher( } /** - * @dataProvider getKeySizes - */ + + */ + #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, $exception @@ -693,46 +702,53 @@ public function testPutObjectWrapsBodyInAesGcmEncryptingStream(): void */ public function testTriggersWarningForGcmEncryptionWithAad(): void { + $this->$this->expectException(\RuntimeException::class); $this->expectExceptionMessage('\'Aad\' has been supplied for content encryption' . ' with AES/GCM/NoPadding'); - $this->expectWarning(); - $s3 = new S3Client([ - 'region' => 'us-west-2', - 'version' => 'latest', - 'http_handler' => function (RequestInterface $request) { - return new FulfilledPromise(new Response( - 200, - [], - $this->getSuccessfulPutObjectResponse() - )); - }, - ]); - - $kms = $this->getKmsClient(); - $keyId = '11111111-2222-3333-4444-555555555555'; - $provider = new KmsMaterialsProviderV3($kms, $keyId); - $this->addMockResults($kms, [ - new Result([ - 'CiphertextBlob' => 'encrypted', - 'Plaintext' => random_bytes(32), - ]) - ]); - - $client = new S3EncryptionClientV3($s3); - $client->putObject([ - 'Bucket' => 'foo', - 'Key' => 'bar', - 'Body' => 'test', - '@MaterialsProvider' => $provider, - '@CommitmentPolicy' => 'FORBID_ENCRYPT_ALLOW_DECRYPT', - '@CipherOptions' => [ - 'Cipher' => 'gcm', - 'Aad' => 'test' - ], - '@KmsEncryptionContext' => [], - ]); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }, E_USER_WARNING); + try { + $s3 = new S3Client([ + 'region' => 'us-west-2', + 'version' => 'latest', + 'http_handler' => function (RequestInterface $request) { + return new FulfilledPromise(new Response( + 200, + [], + $this->getSuccessfulPutObjectResponse() + )); + }, + ]); + + $kms = $this->getKmsClient(); + $keyId = '11111111-2222-3333-4444-555555555555'; + $provider = new KmsMaterialsProviderV3($kms, $keyId); + $this->addMockResults($kms, [ + new Result([ + 'CiphertextBlob' => 'encrypted', + 'Plaintext' => random_bytes(32), + ]) + ]); + + $client = new S3EncryptionClientV3($s3); + $client->putObject([ + 'Bucket' => 'foo', + 'Key' => 'bar', + 'Body' => 'test', + '@MaterialsProvider' => $provider, + '@CommitmentPolicy' => 'FORBID_ENCRYPT_ALLOW_DECRYPT', + '@CipherOptions' => [ + 'Cipher' => 'gcm', + 'Aad' => 'test' + ], + '@KmsEncryptionContext' => [], + ]); - $this->assertTrue($this->mockQueueEmpty()); + $this->assertTrue($this->mockQueueEmpty()); + } finally { + restore_error_handler(); + } } public function testAddsEncryptionContextForKms(): void @@ -1220,7 +1236,7 @@ public function testEmitsWarningForLegacySecurityProfile(): void { $this->expectExceptionMessage('This S3 Encryption Client operation' . ' is configured to read encrypted data with legacy encryption modes'); - $this->expectWarning(); + $this->$this->expectException(\RuntimeException::class); $kms = $this->getKmsClient(); $list = $kms->getHandlerList(); $list->setHandler(function ($cmd, $req) { @@ -1397,8 +1413,9 @@ public function testAppendsMetricsCaptureMiddleware(): void /** - * @dataProvider getValidMaterialsProviders - */ + + */ + #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProvidersKC( $provider, $exception @@ -1466,8 +1483,9 @@ public function testPutObjectRequiresCommitmentPolicy(): void /** * Test that putObject rejects invalid commitment policies - * @dataProvider getInvalidCommitmentPolicies - */ + + */ + #[DataProvider('getInvalidCommitmentPolicies')] public function testPutObjectRejectsInvalidCommitmentPolicy($policy, $expectedException): void { $this->expectException($expectedException[0]); @@ -1535,8 +1553,9 @@ public function testGetObjectRequiresV3SecurityProfile(): void /** * Test that V2 security profiles are rejected in V3 - * @dataProvider getV2SecurityProfiles - */ + + */ + #[DataProvider('getV2SecurityProfiles')] public function testGetObjectRejectsV2SecurityProfiles($securityProfile): void { $this->expectException(\Aws\Exception\CryptoException::class); @@ -1558,13 +1577,14 @@ public function testGetObjectRejectsV2SecurityProfiles($securityProfile): void /** * Test valid V3 security profiles are accepted - * @dataProvider getValidV3SecurityProfiles - */ + + */ + #[DataProvider('getValidV3SecurityProfiles')] public function testGetObjectAcceptsValidV3SecurityProfiles($securityProfile): void { if ($securityProfile === 'V3_AND_LEGACY') { $this->expectExceptionMessage("This S3 Encryption Client operation is configured to read encrypted data with legacy encryption modes"); - $this->expectWarning(); + $this->$this->expectException(\RuntimeException::class); } elseif ($securityProfile === 'V3') { $this->expectExceptionMessage("Invalid MessageId length found in object envelope."); $this->expectException(\Aws\Exception\CryptoException::class); @@ -1735,8 +1755,9 @@ public function testExceptionThrownForLegacyAlgorithmOnPut(): void /** * Test that we validate the commitment policy with the encryption algorithm - * @dataProvider getCiphersAndKCPolicies - */ + + */ + #[DataProvider('getCiphersAndKCPolicies')] public function testCompatibleCipherAndKC( $cipherName, $keySize, @@ -1783,8 +1804,9 @@ public function testCompatibleCipherAndKC( /** * Test that we validate the commitment policy with the encryption algorithm - * @dataProvider getIncompatibleCiphersAndKCPolicies - */ + + */ + #[DataProvider('getIncompatibleCiphersAndKCPolicies')] public function testIncompatibleCipherAndKC( $cipherName, $keySize, @@ -1823,8 +1845,9 @@ public function testIncompatibleCipherAndKC( /** * Test that we validate the commitment policy with the encryption algorithm - * @dataProvider getKCPolicies - */ + + */ + #[DataProvider('getKCPolicies')] public function testIncompatibleCipherCBCAndKCGetObject( $commitmentPolicy ): void @@ -1903,8 +1926,9 @@ public function testIncompatibleCipherCBCAndKCGetObject( /** * Test that we validate the commitment policy with the encryption algorithm - * @dataProvider getKCPolicies - */ + + */ + #[DataProvider('getKCPolicies')] public function testIncompatibleCipherGCMAndKCGetObject( $commitmentPolicy ): void diff --git a/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php b/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php index 805b39c2de..7064a14606 100644 --- a/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php +++ b/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php @@ -11,6 +11,7 @@ use Aws\Test\Crypto\UsesMetadataEnvelopeTrait; use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class S3EncryptionMultipartUploaderTest extends TestCase { @@ -50,8 +51,9 @@ private function setupProvidedExpectedException($exception) } /** - * @dataProvider getValidMaterialsProviders - */ + + */ + #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, $exception @@ -94,8 +96,9 @@ public function testPutObjectTakesValidMaterialsProviders( } /** - * @dataProvider getInvalidMaterialsProviders - */ + + */ + #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, $exception @@ -122,8 +125,9 @@ public function testPutObjectRejectsInvalidMaterialsProviders( } /** - * @dataProvider getValidMetadataStrategies - */ + + */ + #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, $exception, @@ -174,8 +178,9 @@ public function testPutObjectTakesValidMetadataStrategy( } /** - * @dataProvider getInvalidMetadataStrategies - */ + + */ + #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy( $strategy, $exception @@ -246,8 +251,9 @@ public function testPutObjectWithClientInstructionFileSuffix() } /** - * @dataProvider getCiphers - */ + + */ + #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, $exception = null, @@ -292,8 +298,9 @@ public function testPutObjectValidatesCipher( } /** - * @dataProvider getKeySizes - */ + + */ + #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, $exception diff --git a/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php b/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php index 62bbe73679..b241a27a3b 100644 --- a/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php +++ b/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php @@ -13,6 +13,7 @@ use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; class S3EncryptionMultipartUploaderV2Test extends TestCase { @@ -52,8 +53,9 @@ private function setupProvidedExpectedException($exception) } /** - * @dataProvider getValidMaterialsProviders - */ + + */ + #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, $exception @@ -100,8 +102,9 @@ public function testPutObjectTakesValidMaterialsProviders( } /** - * @dataProvider getInvalidMaterialsProviders - */ + + */ + #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, $exception @@ -129,8 +132,9 @@ public function testPutObjectRejectsInvalidMaterialsProviders( } /** - * @dataProvider getValidMetadataStrategies - */ + + */ + #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, $exception, @@ -185,8 +189,9 @@ public function testPutObjectTakesValidMetadataStrategy( } /** - * @dataProvider getInvalidMetadataStrategies - */ + + */ + #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy( $strategy, $exception @@ -262,8 +267,9 @@ public function testPutObjectWithClientInstructionFileSuffix() } /** - * @dataProvider getCiphers - */ + + */ + #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, $exception = null @@ -312,8 +318,9 @@ public function testPutObjectValidatesCipher( } /** - * @dataProvider getKeySizes - */ + + */ + #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, $exception diff --git a/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php b/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php index 97acc0c053..597a0daf9c 100644 --- a/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php +++ b/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php @@ -3,10 +3,12 @@ use Aws\S3\Exception\DeleteMultipleObjectsException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\Exception\DeleteMultipleObjectsException + */ +#[CoversClass(DeleteMultipleObjectsException::class)] class DeleteMultipleObjectsExceptionTest extends TestCase { public function testReturnsData() diff --git a/tests/S3/Exception/S3MultipartUploadExceptionTest.php b/tests/S3/Exception/S3MultipartUploadExceptionTest.php index b27f638659..4ece8af3aa 100644 --- a/tests/S3/Exception/S3MultipartUploadExceptionTest.php +++ b/tests/S3/Exception/S3MultipartUploadExceptionTest.php @@ -7,10 +7,12 @@ use Aws\Multipart\UploadState; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\Exception\S3MultipartUploadException + */ +#[CoversClass(S3MultipartUploadException::class)] class S3MultipartUploadExceptionTest extends TestCase { public function testCanProviderFailedTransferFilePathInfo() diff --git a/tests/S3/ExpiresParsingMiddlewareTest.php b/tests/S3/ExpiresParsingMiddlewareTest.php index 6b1aaa6e99..dbcd7e0878 100644 --- a/tests/S3/ExpiresParsingMiddlewareTest.php +++ b/tests/S3/ExpiresParsingMiddlewareTest.php @@ -8,33 +8,41 @@ use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\ExpiresParsingMiddleware + */ +#[CoversClass(ExpiresParsingMiddleware::class)] class ExpiresParsingMiddlewareTest extends TestCase { use UsesServiceTrait; public function testEmitsWarningWhenMissingExpires() { - $this->expectWarning(); - $this->expectWarningMessage( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( "Failed to parse the `expires` header as a timestamp due to " . " an invalid timestamp format.\nPlease refer to `ExpiresString` " . "for the unparsed string format of this header.\n" ); + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }); + try { + $command = $this->getMockBuilder(CommandInterface::class)->getMock(); + $request = $this->getMockBuilder(RequestInterface::class)->getMock(); + $nextHandler = function ($cmd, $request) { + return Promise\Create::promiseFor(new Result([ + 'ExpiresString' => 'not-a-timestamp' + ])); + }; - $command = $this->getMockBuilder(CommandInterface::class)->getMock(); - $request = $this->getMockBuilder(RequestInterface::class)->getMock(); - $nextHandler = function ($cmd, $request) { - return Promise\Create::promiseFor(new Result([ - 'ExpiresString' => 'not-a-timestamp' - ])); - }; - - $mw = new ExpiresParsingMiddleware($nextHandler); - $mw($command, $request)->wait(); + $mw = new ExpiresParsingMiddleware($nextHandler); + $mw($command, $request)->wait(); + } finally { + restore_error_handler(); + } } public function testDoesNotEmitWarningWhenExpiresPresent() diff --git a/tests/S3/GetBucketLocationParserTest.php b/tests/S3/GetBucketLocationParserTest.php index de638dd714..bad995ce56 100644 --- a/tests/S3/GetBucketLocationParserTest.php +++ b/tests/S3/GetBucketLocationParserTest.php @@ -7,17 +7,21 @@ use Aws\Result; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\GetBucketLocationParser + */ +#[CoversClass(GetBucketLocationParser::class)] class GetBucketLocationParserTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider getTestCases - */ + + */ + #[DataProvider('getTestCases')] public function testParsesLocationFromGetBucketLocationOperations( $commandName, $responseBody, $expectedValue ) { diff --git a/tests/S3/MultipartCopyTest.php b/tests/S3/MultipartCopyTest.php index 75460d9681..be606acbaf 100644 --- a/tests/S3/MultipartCopyTest.php +++ b/tests/S3/MultipartCopyTest.php @@ -9,6 +9,7 @@ use GuzzleHttp\Promise; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class MultipartCopyTest extends TestCase { @@ -17,8 +18,9 @@ class MultipartCopyTest extends TestCase const MB = 1048576; /** - * @dataProvider getTestCases - */ + + */ + #[DataProvider('getTestCases')] public function testS3MultipartCopyWorkflow( array $uploadOptions = [], $error = false diff --git a/tests/S3/MultipartUploaderTest.php b/tests/S3/MultipartUploaderTest.php index 022f93c920..1cbff61ece 100644 --- a/tests/S3/MultipartUploaderTest.php +++ b/tests/S3/MultipartUploaderTest.php @@ -10,10 +10,13 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\MultipartUploader + */ +#[CoversClass(MultipartUploader::class)] class MultipartUploaderTest extends TestCase { use UsesServiceTrait; @@ -27,8 +30,9 @@ public static function tear_down_after_class() } /** - * @dataProvider getTestCases - */ + + */ + #[DataProvider('getTestCases')] public function testS3MultipartUploadWorkflow( array $clientOptions = [], array $uploadOptions = [], @@ -155,8 +159,9 @@ public static function testMultipartSuccessStreams() } /** - * @dataProvider testMultipartSuccessStreams - */ + + */ + #[DataProvider('testMultipartSuccessStreams')] public function testS3MultipartUploadParams($stream, $size) { /** @var \Aws\S3\S3Client $client */ @@ -228,8 +233,9 @@ public static function getContentTypeSettingTests() } /** - * @dataProvider getContentTypeSettingTests - */ + + */ + #[DataProvider('getContentTypeSettingTests')] public function testS3MultipartContentTypeSetting( $stream, $params, @@ -305,8 +311,9 @@ public function testAppliesAmbiguousSuccessParsing() } /** - * @dataProvider testMultipartSuccessStreams - */ + + */ + #[DataProvider('testMultipartSuccessStreams')] public function testUploaderAddsFlexibleChecksums($stream, $size) { /** @var \Aws\S3\S3Client $client */ @@ -357,21 +364,25 @@ public function testAddContentMd5EmitsDeprecationNotice() }); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); - $data = str_repeat('.', 12 * self::MB); - $filename = sys_get_temp_dir() . '/' . self::FILENAME; - file_put_contents($filename, $data); - $source = Psr7\Utils::streamFor(fopen($filename, 'r')); - $client = $this->getTestClient('s3'); - $options = ['bucket' => 'foo', 'key' => 'bar', 'add_content_md5' => true]; - $this->addMockResults($client, [ - new Result(['UploadId' => 'baz']), - new Result(['ETag' => 'A']), - new Result(['ETag' => 'B']), - new Result(['ETag' => 'C']), - ]); - - $uploader = new MultipartUploader($client, $source, $options); - $result = $uploader->upload(); + try { + $data = str_repeat('.', 12 * self::MB); + $filename = sys_get_temp_dir() . '/' . self::FILENAME; + file_put_contents($filename, $data); + $source = Psr7\Utils::streamFor(fopen($filename, 'r')); + $client = $this->getTestClient('s3'); + $options = ['bucket' => 'foo', 'key' => 'bar', 'add_content_md5' => true]; + $this->addMockResults($client, [ + new Result(['UploadId' => 'baz']), + new Result(['ETag' => 'A']), + new Result(['ETag' => 'B']), + new Result(['ETag' => 'C']), + ]); + + $uploader = new MultipartUploader($client, $source, $options); + $uploader->upload(); + } finally { + restore_error_handler(); + } } public function testUploadPrintsProgress() diff --git a/tests/S3/ObjectCopierTest.php b/tests/S3/ObjectCopierTest.php index fc87c75014..09f23b516d 100644 --- a/tests/S3/ObjectCopierTest.php +++ b/tests/S3/ObjectCopierTest.php @@ -12,14 +12,16 @@ use GuzzleHttp\Promise; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; class ObjectCopierTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider copyDataProvider - */ + + */ + #[DataProvider('copyDataProvider')] public function testDoesCorrectOperation( array $mockedResults, array $options @@ -39,8 +41,9 @@ public function testDoesCorrectOperation( } /** - * @dataProvider copyWithPathStyleDataProvider - */ + + */ + #[DataProvider('copyWithPathStyleDataProvider')] public function testDoesCorrectOperationWithPathStyle( array $mockedResults, array $options @@ -62,10 +65,11 @@ public function testDoesCorrectOperationWithPathStyle( } /** - * @dataProvider copyDataProvider * @param array $mockedResults * @param array $options - */ + + */ + #[DataProvider('copyDataProvider')] public function testDoesCorrectOperationWithAccessPointArn( array $mockedResults, array $options @@ -140,8 +144,9 @@ function (CommandInterface $cmd, RequestInterface $req) { } /** - * @dataProvider copyDataProvider - */ + + */ + #[DataProvider('copyDataProvider')] public function testDoesCorrectOperationAsynchronously( array $mockedResults, array $options @@ -163,8 +168,9 @@ public function testDoesCorrectOperationAsynchronously( } /** - * @dataProvider copyWithPathStyleDataProvider - */ + + */ + #[DataProvider('copyWithPathStyleDataProvider')] public function testDoesCorrectOperationAsynchronouslyWithPathStyle( array $mockedResults, array $options @@ -407,8 +413,9 @@ public static function MultipartCopierProvider(){ } /** - * @dataProvider MultipartCopierProvider - */ + + */ + #[DataProvider('MultipartCopierProvider')] public function testS3ObjectMultipartCopier($input, $expectedOutput) { /** @var \Aws\S3\S3Client $client */ diff --git a/tests/S3/ObjectUploaderTest.php b/tests/S3/ObjectUploaderTest.php index 62e2e3a69c..3aa9fed7cb 100644 --- a/tests/S3/ObjectUploaderTest.php +++ b/tests/S3/ObjectUploaderTest.php @@ -8,10 +8,13 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\FnStream; +use PHPUnit\Framework\Attributes\CoversClass; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(ObjectUploader::class)] class ObjectUploaderTest extends TestCase { use UsesServiceTrait; @@ -19,8 +22,9 @@ class ObjectUploaderTest extends TestCase const MB = 1048576; /** - * @dataProvider uploadDataProvider - */ + + */ + #[DataProvider('uploadDataProvider')] public function testDoesCorrectOperation( StreamInterface $body, array $mockedResults, @@ -36,8 +40,9 @@ public function testDoesCorrectOperation( } /** - * @dataProvider getUploadTestCasesWithPathStyle - */ + + */ + #[DataProvider('getUploadTestCasesWithPathStyle')] public function testDoesCorrectOperationWithPathStyle( StreamInterface $body, array $mockedResults, @@ -55,8 +60,9 @@ public function testDoesCorrectOperationWithPathStyle( } /** - * @dataProvider uploadDataProvider - */ + + */ + #[DataProvider('uploadDataProvider')] public function testDoesCorrectOperationWithAccessPointArn( StreamInterface $body, array $mockedResults, @@ -91,8 +97,9 @@ function(CommandInterface $cmd, RequestInterface $req) { } /** - * @dataProvider uploadDataProvider - */ + + */ + #[DataProvider('uploadDataProvider')] public function testDoesCorrectOperationAsynchronously( StreamInterface $body, array $mockedResults, @@ -109,8 +116,9 @@ public function testDoesCorrectOperationAsynchronously( } /** - * @dataProvider getUploadTestCasesWithPathStyle - */ + + */ + #[DataProvider('getUploadTestCasesWithPathStyle')] public function testDoesCorrectOperationAsynchronouslyWithPathStyle( StreamInterface $body, array $mockedResults, @@ -327,8 +335,9 @@ public function testS3ObjectUploaderMultipartParams() * @param $checksumAlgorithm * @return void * - * @dataProvider flexibleChecksumsProvider - */ + + */ + #[DataProvider('flexibleChecksumsProvider')] public function testAddsFlexibleChecksums($checksumAlgorithm, $value) { if ($checksumAlgorithm === 'crc32c' @@ -373,15 +382,19 @@ public function testAddContentMd5EmitsDeprecationNotice() }); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); - $client = $this->getTestClient('S3'); - $this->addMockResults($client, [new Result()]); - (new ObjectUploader( - $client, - 'bucket', - 'key', - self::generateStream(1024 * 1024 * 1), - 'private', - ['add_content_md5' => true] - ))->upload(); + try { + $client = $this->getTestClient('S3'); + $this->addMockResults($client, [new Result()]); + (new ObjectUploader( + $client, + 'bucket', + 'key', + self::generateStream(1024 * 1024 * 1), + 'private', + ['add_content_md5' => true] + ))->upload(); + } finally { + restore_error_handler(); + } } } diff --git a/tests/S3/Parser/GetBucketLocationResultMutatorTest.php b/tests/S3/Parser/GetBucketLocationResultMutatorTest.php index 1ca5f9bd31..6d62a9e379 100644 --- a/tests/S3/Parser/GetBucketLocationResultMutatorTest.php +++ b/tests/S3/Parser/GetBucketLocationResultMutatorTest.php @@ -7,6 +7,7 @@ use Aws\S3\Parser\GetBucketLocationResultMutator; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class GetBucketLocationResultMutatorTest extends TestCase { @@ -15,8 +16,9 @@ class GetBucketLocationResultMutatorTest extends TestCase * and added to the result as the LocationConstraint field. * * @return void - * @dataProvider getTestCases - */ + + */ + #[DataProvider('getTestCases')] public function testInjectsLocationConstraint($operationName, $responseBody, $expectedValue) { $mutator = new GetBucketLocationResultMutator(); diff --git a/tests/S3/Parser/S3ParserTest.php b/tests/S3/Parser/S3ParserTest.php index 17965f12e9..5c95c397eb 100644 --- a/tests/S3/Parser/S3ParserTest.php +++ b/tests/S3/Parser/S3ParserTest.php @@ -17,6 +17,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class S3ParserTest extends TestCase { @@ -32,11 +33,12 @@ class S3ParserTest extends TestCase EOXML; /** - * @dataProvider s3200ErrorHandlingCasesProvider * @param string $operation The operation to test. * * @return void - */ + + */ + #[DataProvider('s3200ErrorHandlingCasesProvider')] public function testHandle200Errors(string $operation) { $this->expectException(AwsException::class); @@ -253,10 +255,11 @@ public function __invoke( * @param StreamInterface $stream * @param bool $expectValidation * - * @dataProvider validate200ErrorValidationJustInSeekableStreamsProvider * * @return void - */ + + */ + #[DataProvider('validate200ErrorValidationJustInSeekableStreamsProvider')] public function testValidate200ErrorValidationJustInSeekableStreams( StreamInterface $stream, bool $expectValidation diff --git a/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php b/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php index 36437c2723..f4f0cc2565 100644 --- a/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php +++ b/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php @@ -12,6 +12,7 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * The tests defined here are similar to the tests @@ -22,7 +23,6 @@ class ValidateResponseChecksumResultMutatorTest extends TestCase use UsesServiceTrait; /** - * @dataProvider checksumCasesDataProvider * @param array $responseAlgorithms * @param array $checksumHeadersReturned * @param string|null $expectedChecksumAlgorithm @@ -30,7 +30,9 @@ class ValidateResponseChecksumResultMutatorTest extends TestCase * @param string $operation * @param string|null $checksumMode * @return void - */ + + */ + #[DataProvider('checksumCasesDataProvider')] public function testChecksumValidation( array $responseAlgorithms, array $checksumHeadersReturned, diff --git a/tests/S3/PermanentRedirectMiddlewareTest.php b/tests/S3/PermanentRedirectMiddlewareTest.php index eda7f92424..7cb9c48c0e 100644 --- a/tests/S3/PermanentRedirectMiddlewareTest.php +++ b/tests/S3/PermanentRedirectMiddlewareTest.php @@ -3,10 +3,12 @@ use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\S3\PermanentRedirectMiddleware + */ +#[CoversClass(\Aws\S3\PermanentRedirectMiddleware::class)] class PermanentRedirectMiddlewareTest extends TestCase { use UsesServiceTrait; diff --git a/tests/S3/PostObjectTest.php b/tests/S3/PostObjectTest.php index 4d412c261c..bfc161706d 100644 --- a/tests/S3/PostObjectTest.php +++ b/tests/S3/PostObjectTest.php @@ -6,10 +6,13 @@ use Aws\S3\S3Client; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\PostObject + */ +#[CoversClass(PostObject::class)] class PostObjectTest extends TestCase { use UsesServiceTrait; @@ -74,12 +77,13 @@ public function testCanHandleDomainsWithDots() } /** - * @dataProvider pathStyleProvider * * @param string $endpoint * @param string $bucket * @param string $expected - */ + + */ + #[DataProvider('pathStyleProvider')] public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expected) { $s3 = new S3Client([ diff --git a/tests/S3/PostObjectV4Test.php b/tests/S3/PostObjectV4Test.php index 4a6b221802..c72d99371e 100644 --- a/tests/S3/PostObjectV4Test.php +++ b/tests/S3/PostObjectV4Test.php @@ -6,12 +6,15 @@ use Aws\S3\S3Client; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Aws\Test\UsesServiceTrait; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/sig_hack.php'; /** - * @covers Aws\S3\PostObjectV4 + */ +#[CoversClass(PostObjectV4::class)] class PostObjectV4Test extends TestCase { use UsesServiceTrait; @@ -245,12 +248,13 @@ public function testCanHandleDomainsWithDots() } /** - * @dataProvider virtualStyleProvider * * @param string $endpoint * @param string $bucket * @param string $expected - */ + + */ + #[DataProvider('virtualStyleProvider')] public function testCanHandleVirtualStyleEndpoint($endpoint, $bucket, $expected) { $s3 = new S3Client([ @@ -280,12 +284,13 @@ public static function virtualStyleProvider() } /** - * @dataProvider pathStyleProvider * * @param string $endpoint * @param string $bucket * @param string $expected - */ + + */ + #[DataProvider('pathStyleProvider')] public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expected) { $s3 = new S3Client([ diff --git a/tests/S3/PutObjectUrlMiddlewareTest.php b/tests/S3/PutObjectUrlMiddlewareTest.php index 5ad4d65a3e..e42d873c95 100644 --- a/tests/S3/PutObjectUrlMiddlewareTest.php +++ b/tests/S3/PutObjectUrlMiddlewareTest.php @@ -3,10 +3,12 @@ use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\PutObjectUrlMiddleware + */ +#[CoversClass(PutObjectUrlMiddleware::class)] class PutObjectUrlMiddlewareTest extends TestCase { use UsesServiceTrait; diff --git a/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php b/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php index 12936986e8..9a57ecbe3f 100644 --- a/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php +++ b/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php @@ -10,10 +10,13 @@ use Aws\S3\RegionalEndpoint\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\S3\RegionalEndpoint\ConfigurationProvider + */ +#[CoversClass(\Aws\S3\RegionalEndpoint\ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -294,10 +297,11 @@ function () use ($expected) { } /** - * @dataProvider getSuccessfulUnwrapData * @param $toUnwrap * @param ConfigurationInterface $expected - */ + + */ + #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { $this->assertSame( diff --git a/tests/S3/RegionalEndpoint/ConfigurationTest.php b/tests/S3/RegionalEndpoint/ConfigurationTest.php index a7fc2f16f7..1ad94f92ab 100644 --- a/tests/S3/RegionalEndpoint/ConfigurationTest.php +++ b/tests/S3/RegionalEndpoint/ConfigurationTest.php @@ -4,10 +4,12 @@ use Aws\Sts\RegionalEndpoints\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\S3\RegionalEndpoint\Configuration + */ +#[CoversClass(\Aws\S3\RegionalEndpoint\Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/S3/S3ClientTest.php b/tests/S3/S3ClientTest.php index a179be1ae3..dd88e7e0eb 100644 --- a/tests/S3/S3ClientTest.php +++ b/tests/S3/S3ClientTest.php @@ -29,11 +29,10 @@ use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Aws\Exception\UnresolvedEndpointException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; -/** - * @covers Aws\S3\S3Client - * @covers Aws\S3\S3ClientTrait - */ +#[CoversClass(S3Client::class)] class S3ClientTest extends TestCase { use UsesServiceTrait; @@ -81,8 +80,9 @@ public static function bucketNameProvider() } /** - * @dataProvider bucketNameProvider - */ + + */ + #[DataProvider('bucketNameProvider')] public function testValidatesDnsBucketNames($bucket, $valid) { $this->assertEquals($valid, S3Client::isBucketDnsCompatible($bucket)); @@ -313,8 +313,9 @@ private static function getS3ErrorMock( } /** - * @dataProvider doesExistProvider - */ + + */ + #[DataProvider('doesExistProvider')] public function testsIfExists( $bucket, $key, @@ -509,8 +510,9 @@ public function testProxiesToObjectCopy() } /** - * @dataProvider getTestCasesForLocationConstraints - */ + + */ + #[DataProvider('getTestCasesForLocationConstraints')] public function testAddsLocationConstraintAutomatically($region, $target, $command, $contains) { $client = $this->getTestClient('S3', ['region' => $region]); @@ -556,8 +558,9 @@ public static function getTestCasesForLocationConstraints() /** * @param string $bucket * - * @dataProvider directoryBucketLocationConstraintProvider - */ + + */ + #[DataProvider('directoryBucketLocationConstraintProvider')] public function testDoesNotAddLocationConstraintForDirectoryBuckets( string $bucket ): void @@ -621,10 +624,11 @@ public function testRequestSucceedsWithColon() } /** - * @dataProvider clientRetrySettingsProvider * * @param array $retrySettings - */ + + */ + #[DataProvider('clientRetrySettingsProvider')] public function testRetriesConnectionErrors($retrySettings) { $retries = $retrySettings['max_attempts'] - 1; @@ -654,7 +658,7 @@ public function testRetriesConnectionErrors($retrySettings) $this->assertSame(0, $retries); } - public static function clientRetrySettingsProvider() + public static function clientRetrySettingsProvider(): array { return [ [ @@ -679,12 +683,13 @@ public static function clientRetrySettingsProvider() } /** - * @dataProvider s3OperationsProvider * * @param string $operation * @param array $payload * @param array $retryOptions - */ + + */ + #[DataProvider('s3OperationsProvider')] public function testRetries200Errors( string $operation, array $payload, @@ -783,10 +788,11 @@ private function getWellFormedXml() } /** - * @dataProvider clientRetrySettingsProvider * * @param array $retrySettings - */ + + */ + #[DataProvider('clientRetrySettingsProvider')] public function testClientSocketTimeoutErrorsAreNotRetriedIndefinitely($retrySettings) { $this->expectExceptionMessageMatches("/Your socket connection to the server/"); @@ -827,16 +833,19 @@ private function getSocketTimeoutResponse() } /** - * @dataProvider clientRetrySettingsProvider * * @param array $retrySettings - */ - public function testNetworkingErrorsAreRetriedOnIdempotentCommands($retrySettings) + */ + #[DataProvider('clientRetrySettingsProvider')] + public function testNetworkingErrorsAreRetriedOnIdempotentCommands( + array $retrySettings + ) { $networkingError = $this->getMockBuilder(RequestException::class) ->disableOriginalConstructor() - ->setMethods([]) + ->onlyMethods(['getHandlerContext']) ->getMock(); + $networkingError->method('getHandlerContext')->willReturn([]); $retries = $retrySettings['max_attempts'] - 1; $client = new S3Client([ @@ -865,18 +874,20 @@ public function testNetworkingErrorsAreRetriedOnIdempotentCommands($retrySetting } /** - * @dataProvider clientRetrySettingsProvider * * @param array $retrySettings - */ + + */ + #[DataProvider('clientRetrySettingsProvider')] public function testNetworkingErrorsAreNotRetriedOnNonIdempotentCommands($retrySettings) { $this->expectExceptionMessageMatches("/CompleteMultipartUpload/"); $this->expectException(\Aws\S3\Exception\S3Exception::class); $networkingError = $this->getMockBuilder(RequestException::class) ->disableOriginalConstructor() - ->setMethods([]) + ->onlyMethods(['getHandlerContext']) ->getMock(); + $networkingError->method('getHandlerContext')->willReturn([]); $retries = $retrySettings['max_attempts']; $client = new S3Client([ @@ -906,16 +917,18 @@ public function testNetworkingErrorsAreNotRetriedOnNonIdempotentCommands($retryS } /** - * @dataProvider clientRetrySettingsProvider * * @param array $retrySettings - */ + + */ + #[DataProvider('clientRetrySettingsProvider')] public function testErrorsWithUnparseableBodiesCanBeRetried($retrySettings) { $networkingError = $this->getMockBuilder(RequestException::class) ->disableOriginalConstructor() - ->setMethods([]) + ->onlyMethods(['getHandlerContext']) ->getMock(); + $networkingError->method('getHandlerContext')->willReturn([]); $retries = $retrySettings['max_attempts']; $client = new S3Client([ @@ -944,9 +957,10 @@ public function testErrorsWithUnparseableBodiesCanBeRetried($retrySettings) } /** - * @dataProvider clientRetrySettingsProvider * @param $retrySettings - */ + + */ + #[DataProvider('clientRetrySettingsProvider')] public function testRetriesFailOn400Errors($retrySettings) { $retryCount = 0; $client = new S3Client([ @@ -1550,10 +1564,11 @@ public function testAddsS3RegionalEndpointsCacheArgument() /** * Tests that S3 client configuration options lead to correct endpoints * - * @dataProvider optionsToEndpointsCases * @param $options * @param $host - */ + + */ + #[DataProvider('optionsToEndpointsCases')] public function testResolvesOptionsToProperEndpoints($options, $host) { $client = new S3Client($options); @@ -1697,8 +1712,9 @@ public static function multiRegionSuccessProvider() } /** - * @dataProvider multiRegionSuccessProvider - */ + + */ + #[DataProvider('multiRegionSuccessProvider')] public function testMrapParsing( $bucketFieldInput, $clientRegion, @@ -1771,8 +1787,9 @@ public static function mrapExceptionTestProvider() { } /** - * @dataProvider mrapExceptionTestProvider - */ + + */ + #[DataProvider('mrapExceptionTestProvider')] public function testMrapExceptions( $bucketFieldInput, $clientRegion, @@ -1809,14 +1826,15 @@ public function testMrapExceptions( } /** - * @dataProvider AccessPointFailureProvider * @param $bucketFieldInput * @param $clientRegion * @param $additionalFlags * @param $useArnRegion * @param $disableMraps * @param $expectedException - */ + + */ + #[DataProvider('AccessPointFailureProvider')] public function testAccessPointFailures ( $bucketFieldInput, $clientRegion, @@ -1949,10 +1967,11 @@ public static function jsonCaseProvider() } /** - * @dataProvider jsonCaseProvider * * @param array $testCase - */ + + */ + #[DataProvider('jsonCaseProvider')] public function testPassesCompliance( $bucket, $configuredAddressingStyle, @@ -1985,7 +2004,6 @@ public function testPassesCompliance( } /** - * @dataProvider objectLambdasSuccessProvider * * @param $bucketFieldInput * @param $clientRegion @@ -1993,7 +2011,9 @@ public function testPassesCompliance( * @param $useArnRegion * @param $endpointUrl * @param $expectedEndpoint - */ + + */ + #[DataProvider('objectLambdasSuccessProvider')] public function testObjectLambdaArnSuccess( $bucketFieldInput, $clientRegion, @@ -2059,7 +2079,6 @@ public static function objectLambdasSuccessProvider() } /** - * @dataProvider objectLambdasFailureProvider * * @param $bucketFieldInput * @param $clientRegion @@ -2067,7 +2086,9 @@ public static function objectLambdasSuccessProvider() * @param $useArnRegion * @param $endpointUrl * @param $expectedException - */ + + */ + #[DataProvider('objectLambdasFailureProvider')] public function testObjectLambdaArnFailures( $bucketFieldInput, $clientRegion, @@ -2188,13 +2209,14 @@ public static function objectLambdasFailureProvider() /** - * @dataProvider writeGetObjectResponseProvider * * @param $clientRegion * @param $route * @param $endpointUrl * @param $expectedEndpoint - */ + + */ + #[DataProvider('writeGetObjectResponseProvider')] public function testWriteGetObjectResponse( $clientRegion, $route, @@ -2298,8 +2320,9 @@ public static function addMD5Provider() { } /** - * @dataProvider addMD5Provider - */ + + */ + #[DataProvider('addMD5Provider')] public function testAddContentMd5EmitsDeprecationNotice($options, $operation) { set_error_handler(function ($err, $message) { @@ -2307,16 +2330,21 @@ public function testAddContentMd5EmitsDeprecationNotice($options, $operation) }); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); - $s3 = $this->getTestClient('s3'); - $this->addMockResults($s3, [[]]); - $options['AddContentMD5'] = true; - $command = $s3->getCommand($operation, $options); - $s3->execute($command); + try { + $s3 = $this->getTestClient('s3'); + $this->addMockResults($s3, [[]]); + $options['AddContentMD5'] = true; + $command = $s3->getCommand($operation, $options); + $s3->execute($command); + } finally { + restore_error_handler(); + } } /** - * @dataProvider dotSegmentProvider - */ + + */ + #[DataProvider('dotSegmentProvider')] public function testHandlesDotSegmentsInKey($key, $expectedUri) { $s3 = $this->getTestClient('s3'); @@ -2342,8 +2370,9 @@ public static function dotSegmentProvider() } /** - * @dataProvider dotSegmentPathStyleProvider - */ + + */ + #[DataProvider('dotSegmentPathStyleProvider')] public function testHandlesDotSegmentsInKeyWithPathStyle($key, $expectedUri) { $s3 = $this->getTestClient('s3', ['use_path_style_endpoint' => true]); @@ -2369,8 +2398,9 @@ public static function dotSegmentPathStyleProvider() } /** - * @dataProvider builtinRegionProvider - */ + + */ + #[DataProvider('builtinRegionProvider')] public function testCorrectlyResolvesGlobalEndpointWithoutRegionInConstructor( $region, $expected ){ @@ -2491,11 +2521,12 @@ public static function builtinRegionProvider() * This test makes sure that not parsable xml errors are retried. * This handling is specified in the s3 parser implementation. * - * @dataProvider clientRetrySettingsProvider * @param array $retrySettings * * @return void - */ + + */ + #[DataProvider('clientRetrySettingsProvider')] public function testS3RetriesOnNotParsableBody(array $retrySettings) { $retries = $retrySettings['max_attempts']; @@ -2521,8 +2552,9 @@ public function testS3RetriesOnNotParsableBody(array $retrySettings) * * @return void * - * @dataProvider directoryBucketProvider - */ + + */ + #[DataProvider('directoryBucketProvider')] public function testIsDirectoryBucket(string $bucketName, bool $expected): void { $client = $this->getTestClient('s3'); @@ -2565,8 +2597,9 @@ public function testAddCrc32ForDirectoryBucketsAsAppropriate() } /** - * @dataProvider getContentSha256UseCases - */ + + */ + #[DataProvider('getContentSha256UseCases')] public function testAddsContentSHA256AsAppropriate($operation, $args, $hashAdded, $hashValue) { $s3 = $this->getTestClient('s3'); @@ -2611,8 +2644,9 @@ public static function getContentSha256UseCases() } /** - * @dataProvider getFlexibleChecksumUseCases - */ + + */ + #[DataProvider('getFlexibleChecksumUseCases')] public function testAddsFlexibleChecksumAsAppropriate($operation, $clientArgs, $operationArgs, $headerAdded, $headerValue) { if (isset($operationArgs['ChecksumAlgorithm']) @@ -2744,8 +2778,9 @@ public static function getFlexibleChecksumUseCases() * @param array $clientConfig * @return void * - * @dataProvider responseChecksumValidationProvider - */ + + */ + #[DataProvider('responseChecksumValidationProvider')] public function testResponseChecksumValidation( array $clientConfig, ?string $checksumAlgorithm, @@ -2816,9 +2851,10 @@ public static function responseChecksumValidationProvider(): array } /** - * @dataProvider checksumConfigProvider * @return void - */ + + */ + #[DataProvider('checksumConfigProvider')] public function testChecksumConfigThrowsForInvalidInput( string $option, string $invalidOption @@ -2908,8 +2944,9 @@ public function testCreatesPresignedPutRequestsWithChecksumValue() * The purpose of this test is to ensure ApplyChecksumMiddleware is * not invoked twice, ensuring checksum calculation is not repeated. * - * @dataProvider retriesWithoutRecalculatingChecksumProvider - */ + + */ + #[DataProvider('retriesWithoutRecalculatingChecksumProvider')] public function testRetriesWithoutRecalculatingChecksum( string $commandName, array $commandArgs, diff --git a/tests/S3/S3EndpointMiddlewareTest.php b/tests/S3/S3EndpointMiddlewareTest.php index 276f17a649..413a9de732 100644 --- a/tests/S3/S3EndpointMiddlewareTest.php +++ b/tests/S3/S3EndpointMiddlewareTest.php @@ -13,6 +13,7 @@ use GuzzleHttp\Psr7\Uri; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class S3EndpointMiddlewareTest extends TestCase { @@ -49,10 +50,11 @@ public function testAppliesAccelerateDualStackEndpointToCommand() } /** - * @dataProvider excludedCommandProvider * * @param CommandInterface $command - */ + + */ + #[DataProvider('excludedCommandProvider')] public function testAppliesDualStackToCommandForInvalidOperationsWhenEnableBoth(CommandInterface $command) { $middleware = new S3EndpointMiddleware( @@ -68,10 +70,11 @@ public function testAppliesDualStackToCommandForInvalidOperationsWhenEnableBoth( } /** - * @dataProvider excludedCommandProvider * * @param CommandInterface $command - */ + + */ + #[DataProvider('excludedCommandProvider')] public function testAppliesDualStackWithPathStyleToCommandForInvalidOperationsWhenEnableBoth(CommandInterface $command) { $middleware = new S3EndpointMiddleware( @@ -145,10 +148,11 @@ public function testAppliesAccelerateDualStackEndpointWithOperationalLevelOptIn( } /** - * @dataProvider excludedCommandProvider * * @param CommandInterface $command - */ + + */ + #[DataProvider('excludedCommandProvider')] public function testAppliesDualStackForInvalidOperationsWhenEnableBothAtOperationalLevel(CommandInterface $command) { $middleware = new S3EndpointMiddleware( @@ -163,10 +167,11 @@ public function testAppliesDualStackForInvalidOperationsWhenEnableBothAtOperatio } /** - * @dataProvider excludedCommandProvider * * @param CommandInterface $command - */ + + */ + #[DataProvider('excludedCommandProvider')] public function testAppliesDualStackForInvalidOperationsWhenEnableBothWithPathStyleAtOperationalLevel(CommandInterface $command) { $middleware = new S3EndpointMiddleware( @@ -220,10 +225,11 @@ public function testDoesNothingWhenDisabledBothOnOperationLevel() } /** - * @dataProvider excludedCommandProvider * * @param CommandInterface $command - */ + + */ + #[DataProvider('excludedCommandProvider')] public function testIgnoresExcludedCommands(CommandInterface $command) { $middleware = new S3EndpointMiddleware( @@ -534,10 +540,11 @@ public static function jsonCaseProvider() } /** - * @dataProvider jsonCaseProvider * * @param array $testCase - */ + + */ + #[DataProvider('jsonCaseProvider')] public function testPassesCompliance( $bucket, $configuredAddressingStyle, @@ -570,7 +577,6 @@ public function testPassesCompliance( } /** - * @dataProvider objectLambdasSuccessProvider * * @param $bucketFieldInput * @param $clientRegion @@ -578,7 +584,9 @@ public function testPassesCompliance( * @param $useArnRegion * @param $endpointUrl * @param $expectedEndpoint - */ + + */ + #[DataProvider('objectLambdasSuccessProvider')] public function testObjectLambdaArnSuccess( $bucketFieldInput, $clientRegion, @@ -644,7 +652,6 @@ public static function objectLambdasSuccessProvider() } /** - * @dataProvider objectLambdasFailureProvider * * @param $bucketFieldInput * @param $clientRegion @@ -652,7 +659,9 @@ public static function objectLambdasSuccessProvider() * @param $useArnRegion * @param $endpointUrl * @param $expectedException - */ + + */ + #[DataProvider('objectLambdasFailureProvider')] public function testObjectLambdaArnFailures( $bucketFieldInput, $clientRegion, @@ -772,13 +781,14 @@ public static function objectLambdasFailureProvider() /** - * @dataProvider writeGetObjectResponseProvider * * @param $clientRegion * @param $route * @param $endpointUrl * @param $expectedEndpoint - */ + + */ + #[DataProvider('writeGetObjectResponseProvider')] public function testWriteGetObjectResponse( $clientRegion, $route, diff --git a/tests/S3/S3MultiRegionClientTest.php b/tests/S3/S3MultiRegionClientTest.php index 54ee3d6ed2..5198fa9faf 100644 --- a/tests/S3/S3MultiRegionClientTest.php +++ b/tests/S3/S3MultiRegionClientTest.php @@ -16,6 +16,7 @@ use GuzzleHttp\Promise\RejectedPromise; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class S3MultiRegionClientTest extends TestCase { @@ -568,10 +569,11 @@ public function testWillDefaultToRegionInPartitionWithPathStyle() } /** - * @dataProvider booleanProvider * * @param bool $regionalized - */ + + */ + #[DataProvider('booleanProvider')] public function testCallbacksAttachedToCommandHandlerListsAreInvoked($regionalized) { /** @var S3ClientInterface $client */ diff --git a/tests/S3/S3Transfer/MultipartUploaderTest.php b/tests/S3/S3Transfer/MultipartUploaderTest.php index 8688773c7d..8507ac1248 100644 --- a/tests/S3/S3Transfer/MultipartUploaderTest.php +++ b/tests/S3/S3Transfer/MultipartUploaderTest.php @@ -21,6 +21,7 @@ use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; +use PHPUnit\Framework\Attributes\DataProvider; class MultipartUploaderTest extends TestCase { @@ -44,8 +45,9 @@ protected function tearDown(): void * @param array $expected * @return void * - * @dataProvider multipartUploadProvider - */ + + */ + #[DataProvider('multipartUploadProvider')] public function testMultipartUpload( array $sourceConfig, array $commandArgs, @@ -276,10 +278,11 @@ private function getMultipartUploadS3Client(): S3ClientInterface * @param int $partSize * @param bool $expectError * - * @dataProvider validatePartSizeProvider * * @return void - */ + + */ + #[DataProvider('validatePartSizeProvider')] public function testValidatePartSize( int $partSize, bool $expectError @@ -335,10 +338,11 @@ public static function validatePartSizeProvider(): array { * @param string|int $source * @param bool $expectError * - * @dataProvider invalidSourceStringProvider * * @return void - */ + + */ + #[DataProvider('invalidSourceStringProvider')] public function testInvalidSourceStringThrowsException( string|int $source, bool $expectError @@ -534,10 +538,11 @@ public function testMultipartOperationsAreCalled(): void { * @param array $checksumConfig * @param array $expectedOperationHeaders * - * @dataProvider multipartUploadWithCustomChecksumProvider * * @return void - */ + + */ + #[DataProvider('multipartUploadWithCustomChecksumProvider')] public function testMultipartUploadWithCustomChecksum( array $sourceConfig, array $checksumConfig, @@ -845,10 +850,11 @@ public function testTransferListenerNotifierWithEmptyListeners(): void * @param array $checksumConfig * @param bool $expectsError * - * @dataProvider fullObjectChecksumWorksJustWithCRCProvider * * @return void - */ + + */ + #[DataProvider('fullObjectChecksumWorksJustWithCRCProvider')] public function testFullObjectChecksumWorksJustWithCRC( array $checksumConfig, bool $expectsError @@ -923,8 +929,9 @@ public static function fullObjectChecksumWorksJustWithCRCProvider(): Generator { * @param bool $expectsError * @param int|null $errorOnPartNumber * @return void - * @dataProvider inputArgumentsPerOperationProvider - */ + + */ + #[DataProvider('inputArgumentsPerOperationProvider')] public function testInputArgumentsPerOperation( array $sourceConfig, array $requestArgs, diff --git a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php index 0300ba3edf..4ee05097ac 100644 --- a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php @@ -12,6 +12,7 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Utils; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests PartGetMultipartDownloader implementation. @@ -25,10 +26,11 @@ class PartGetMultipartDownloaderTest extends TestCase * @param int $objectSizeInBytes * @param int $targetPartSize * - * @dataProvider partGetMultipartDownloaderProvider * * @return void - */ + + */ + #[DataProvider('partGetMultipartDownloaderProvider')] public function testPartGetMultipartDownloader( string $objectKey, int $objectSizeInBytes, @@ -209,10 +211,11 @@ public function testComputeObjectDimensions(): void * @param int $targetPartSize * @param string $eTag * - * @dataProvider ifMatchIsPresentInEachPartRequestAfterFirstProvider * * @return void - */ + + */ + #[DataProvider('ifMatchIsPresentInEachPartRequestAfterFirstProvider')] public function testIfMatchIsPresentInEachRangeRequestAfterFirst( int $objectSizeInBytes, int $targetPartSize, diff --git a/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php b/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php index def762a2c2..70236ab835 100644 --- a/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php +++ b/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php @@ -7,6 +7,7 @@ use Aws\S3\S3Transfer\Progress\AbstractProgressBarFormat; use Aws\S3\S3Transfer\Progress\TransferProgressBarFormat; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AbstractProgressBarFormatTest extends TestCase { @@ -20,9 +21,10 @@ class AbstractProgressBarFormatTest extends TestCase * @param string $expectedFormat * * @return void - * @dataProvider progressBarFormatProvider * - */ + + */ + #[DataProvider('progressBarFormatProvider')] public function testProgressBarFormat( string $implementationClass, array $args, diff --git a/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php b/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php index fb19ca9902..b84d569b4e 100644 --- a/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php +++ b/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php @@ -8,6 +8,7 @@ use Aws\S3\S3Transfer\Progress\AbstractProgressBarFormat; use Aws\S3\S3Transfer\Progress\TransferProgressBarFormat; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests console progress bar. @@ -96,9 +97,10 @@ public function testPercentIsNotOverOneHundred(): void * @param string $expectedOutput * * @return void - * @dataProvider progressBarRenderingProvider * - */ + + */ + #[DataProvider('progressBarRenderingProvider')] public function testProgressBarRendering( string $progressBarChar, int $progressBarWidth, diff --git a/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php b/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php index ceb169718b..ee0485d5bc 100644 --- a/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php +++ b/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php @@ -11,6 +11,7 @@ use Aws\S3\S3Transfer\Progress\TransferProgressSnapshot; use Closure; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class MultiProgressTrackerTest extends TestCase { @@ -28,7 +29,6 @@ public function testDefaultInitialization(): void } /** - * @dataProvider customInitializationProvider * * @param array $progressTrackers * @param mixed $output @@ -37,7 +37,9 @@ public function testDefaultInitialization(): void * @param int $failed * * @return void - */ + + */ + #[DataProvider('customInitializationProvider')] public function testCustomInitialization( array $progressTrackers, mixed $output, @@ -65,9 +67,10 @@ public function testCustomInitialization( * @param array $expectedOutputs * * @return void - * @dataProvider multiProgressTrackerProvider * - */ + + */ + #[DataProvider('multiProgressTrackerProvider')] public function testMultiProgressTracker( Closure $progressBarFactory, callable $eventInvoker, diff --git a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php index bc3898f9a5..cc58481212 100644 --- a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php +++ b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php @@ -10,6 +10,7 @@ use Aws\S3\S3Transfer\Progress\AbstractTransferListener; use Aws\S3\S3Transfer\Progress\TransferProgressSnapshot; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class SingleProgressTrackerTest extends TestCase { @@ -31,10 +32,11 @@ public function testDefaultInitialization(): void * @param bool $clear * @param TransferProgressSnapshot $snapshot * - * @dataProvider customInitializationProvider * * @return void - */ + + */ + #[DataProvider('customInitializationProvider')] public function testCustomInitialization( ProgressBarInterface $progressBar, mixed $output, @@ -88,10 +90,11 @@ public static function customInitializationProvider(): array * @param callable $eventInvoker * @param array $expectedOutputs * - * @dataProvider singleProgressTrackingProvider * * @return void - */ + + */ + #[DataProvider('singleProgressTrackingProvider')] public function testSingleProgressTracking( ProgressBarInterface $progressBar, callable $eventInvoker, diff --git a/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php b/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php index 6c81545f07..2b6ef5fee5 100644 --- a/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php +++ b/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php @@ -4,6 +4,7 @@ use Aws\S3\S3Transfer\Progress\TransferProgressSnapshot; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class TransferProgressSnapshotTest extends TestCase { @@ -31,9 +32,10 @@ public function testInitialization(): void * @param float $expectedRatio * * @return void - * @dataProvider ratioTransferredProvider * - */ + + */ + #[DataProvider('ratioTransferredProvider')] public function testRatioTransferred( int $transferredBytes, int $totalBytes, diff --git a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php index 7b15a6e9d5..c063ed9c31 100644 --- a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php @@ -13,6 +13,7 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Utils; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * Tests RangeGetMultipartDownloader implementation. @@ -26,10 +27,11 @@ class RangeGetMultipartDownloaderTest extends TestCase * @param int $objectSizeInBytes * @param int $targetPartSize * - * @dataProvider rangeGetMultipartDownloaderProvider * * @return void - */ + + */ + #[DataProvider('rangeGetMultipartDownloaderProvider')] public function testRangeGetMultipartDownloader( string $objectKey, int $objectSizeInBytes, @@ -259,10 +261,11 @@ public function testNextCommandIncludesIfMatchWhenETagPresent(): void * @param int $targetPartSize * @param string $eTag * - * @dataProvider ifMatchIsPresentInEachRangeRequestAfterFirstProvider * * @return void - */ + + */ + #[DataProvider('ifMatchIsPresentInEachRangeRequestAfterFirstProvider')] public function testIfMatchIsPresentInEachRangeRequestAfterFirst( int $objectSizeInBytes, int $targetPartSize, diff --git a/tests/S3/S3Transfer/S3TransferManagerTest.php b/tests/S3/S3Transfer/S3TransferManagerTest.php index 5def42808c..b4132cb6a9 100644 --- a/tests/S3/S3Transfer/S3TransferManagerTest.php +++ b/tests/S3/S3Transfer/S3TransferManagerTest.php @@ -40,6 +40,7 @@ use RecursiveDirectoryIterator; use RuntimeException; use function Aws\filter; +use PHPUnit\Framework\Attributes\DataProvider; class S3TransferManagerTest extends TestCase { @@ -198,13 +199,14 @@ public function testUploadExpectsAReadableSource(): void } /** - * @dataProvider uploadBucketAndKeyProvider * * @param array $bucketKeyArgs * @param string $missingProperty * * @return void - */ + + */ + #[DataProvider('uploadBucketAndKeyProvider')] public function testUploadFailsWhenBucketAndKeyAreNotProvided( array $bucketKeyArgs, string $missingProperty @@ -378,10 +380,11 @@ public function testUploadUsesTransferManagerConfigDefaultMupThreshold(): void * @param int $expectedPartSize * @param bool $isMultipartUpload * - * @dataProvider uploadUsesCustomMupThresholdProvider * * @return void - */ + + */ + #[DataProvider('uploadUsesCustomMupThresholdProvider')] public function testUploadUsesCustomMupThreshold( int $mupThreshold, int $expectedPartCount, @@ -547,10 +550,11 @@ public function testUploadUsesDefaultChecksumAlgorithm(): void /** * @param string $checksumAlgorithm * - * @dataProvider uploadUsesCustomChecksumAlgorithmProvider * * @return void - */ + + */ + #[DataProvider('uploadUsesCustomChecksumAlgorithmProvider')] public function testUploadUsesCustomChecksumAlgorithm( string $checksumAlgorithm, ): void @@ -631,10 +635,11 @@ private function testUploadResolvedChecksum( * @param string $directory * @param bool $isDirectoryValid * - * @dataProvider uploadDirectoryValidatesProvidedDirectoryProvider * * @return void - */ + + */ + #[DataProvider('uploadDirectoryValidatesProvidedDirectoryProvider')] public function testUploadDirectoryValidatesProvidedDirectory( string $directory, bool $isDirectoryValid @@ -1549,13 +1554,14 @@ public function testDownloadFailsOnInvalidS3UriSource(): void } /** - * @dataProvider downloadFailsWhenSourceAsArrayMissesBucketOrKeyPropertyProvider * * @param array $sourceAsArray * @param string $expectedExceptionMessage * * @return void - */ + + */ + #[DataProvider('downloadFailsWhenSourceAsArrayMissesBucketOrKeyPropertyProvider')] public function testDownloadFailsWhenSourceAsArrayMissesBucketOrKeyProperty( array $sourceAsArray, string $expectedExceptionMessage, @@ -1673,9 +1679,10 @@ public function testDownloadWorksWithBucketAndKeyAsSource(): void * @param bool $expectedChecksumMode * * @return void - * @dataProvider downloadAppliesChecksumProvider * - */ + + */ + #[DataProvider('downloadAppliesChecksumProvider')] public function testDownloadAppliesChecksumMode( array $transferManagerConfig, array $downloadConfig, @@ -1797,10 +1804,11 @@ public static function downloadAppliesChecksumProvider(): array * @param string $multipartDownloadType * @param string $expectedParameter * - * @dataProvider downloadChoosesMultipartDownloadTypeProvider * * @return void - */ + + */ + #[DataProvider('downloadChoosesMultipartDownloadTypeProvider')] public function testDownloadChoosesMultipartDownloadType( string $multipartDownloadType, string $expectedParameter @@ -1861,9 +1869,10 @@ public static function downloadChoosesMultipartDownloadTypeProvider(): array * * @return void * - * @dataProvider rangeGetMultipartDownloadMinimumPartSizeProvider * - */ + + */ + #[DataProvider('rangeGetMultipartDownloadMinimumPartSizeProvider')] public function testRangeGetMultipartDownloadMinimumPartSize( int $minimumPartSize, int $objectSize, @@ -2005,10 +2014,11 @@ public function testDownloadDirectoryCreatesDestinationDirectory(): void * @param array $config * @param string $expectedS3Prefix * - * @dataProvider downloadDirectoryAppliesS3PrefixProvider * * @return void - */ + + */ + #[DataProvider('downloadDirectoryAppliesS3PrefixProvider')] public function testDownloadDirectoryAppliesS3Prefix( array $config, string $expectedS3Prefix @@ -2294,10 +2304,11 @@ public function testDownloadDirectoryUsesFailurePolicy(): void * @param array $objectList * @param array $expectedObjectList * - * @dataProvider downloadDirectoryAppliesFilterProvider * * @return void - */ + + */ + #[DataProvider('downloadDirectoryAppliesFilterProvider')] public function testDownloadDirectoryAppliesFilter( Closure $filter, array $objectList, @@ -2611,10 +2622,11 @@ public function testDownloadDirectoryGetObjectRequestCallbackWorks(): void * @param array $listObjectsContent * @param array $expectedFileKeys * - * @dataProvider downloadDirectoryCreateFilesProvider * * @return void - */ + + */ + #[DataProvider('downloadDirectoryCreateFilesProvider')] public function testDownloadDirectoryCreateFiles( array $listObjectsContent, array $expectedFileKeys, @@ -2726,8 +2738,9 @@ public static function downloadDirectoryCreateFilesProvider(): array * @param array $expectedOutput * * @return void - * @dataProvider resolvesOutsideTargetDirectoryProvider - */ + + */ + #[DataProvider('resolvesOutsideTargetDirectoryProvider')] public function testResolvesOutsideTargetDirectory( ?string $prefix, array $objects, @@ -2929,9 +2942,10 @@ public static function resolvesOutsideTargetDirectoryProvider(): array * @param array $outcomes * * @return void - * @dataProvider modeledDownloadCasesProvider * - */ + + */ + #[DataProvider('modeledDownloadCasesProvider')] public function testModeledCasesForDownload( string $testId, array $config, @@ -3104,9 +3118,10 @@ public function bytesTransferred(array $context): bool { * @param array $outcomes * * @return void - * @dataProvider modeledUploadCasesProvider * - */ + + */ + #[DataProvider('modeledUploadCasesProvider')] public function testModeledCasesForUpload( string $testId, array $config, @@ -3253,8 +3268,9 @@ public function bytesTransferred(array $context): bool { * @param array $outcomes * * @return void - * @dataProvider modeledUploadDirectoryCasesProvider - */ + + */ + #[DataProvider('modeledUploadDirectoryCasesProvider')] public function testModeledCasesForUploadDirectory( string $testId, array $config, @@ -3419,9 +3435,10 @@ function (string $operation, ?array $body): StreamInterface { * @param array $outcomes * * @return void - * @dataProvider modeledDownloadDirectoryCasesProvider * - */ + + */ + #[DataProvider('modeledDownloadDirectoryCasesProvider')] public function testModeledCasesForDownloadDirectory( string $testId, array $config, diff --git a/tests/S3/S3UriParserTest.php b/tests/S3/S3UriParserTest.php index 6a9a173fbb..86b60e95e7 100644 --- a/tests/S3/S3UriParserTest.php +++ b/tests/S3/S3UriParserTest.php @@ -4,10 +4,13 @@ use Aws\Arn\Exception\InvalidArnException; use Aws\S3\S3UriParser; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\S3UriParser + */ +#[CoversClass(S3UriParser::class)] class S3UriParserTest extends TestCase { public static function uriProvider() @@ -90,8 +93,9 @@ public static function uriProvider() } /** - * @dataProvider uriProvider - */ + + */ + #[DataProvider('uriProvider')] public function testParsesUrls($uri, $result, $isError = false) { ksort($result); diff --git a/tests/S3/SSECMiddlewareTest.php b/tests/S3/SSECMiddlewareTest.php index 5dc03103a9..391f2e8273 100644 --- a/tests/S3/SSECMiddlewareTest.php +++ b/tests/S3/SSECMiddlewareTest.php @@ -5,17 +5,21 @@ use Aws\Result; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\SSECMiddleware + */ +#[CoversClass(SSECMiddleware::class)] class SSECMiddlewareTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider getListenerTestCases - */ + + */ + #[DataProvider('getListenerTestCases')] public function testSseCpkListener($operation, array $params, array $expectedResults) { $s3 = $this->getTestClient('s3'); diff --git a/tests/S3/StreamWrapperPathStyleTest.php b/tests/S3/StreamWrapperPathStyleTest.php index e647ebd55f..54d381f3b0 100644 --- a/tests/S3/StreamWrapperPathStyleTest.php +++ b/tests/S3/StreamWrapperPathStyleTest.php @@ -12,10 +12,13 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\StreamWrapper + */ +#[CoversClass(StreamWrapper::class)] class StreamWrapperPathStyleTest extends TestCase { use UsesServiceTrait; @@ -36,6 +39,9 @@ public function set_up() 'use_path_style_endpoint' => true ]); $this->client->registerStreamWrapper(); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); } public function tear_down() @@ -49,26 +55,27 @@ public function testRegistersStreamWrapperOnlyOnce() StreamWrapper::register($this->client); $this->assertContains('s3', stream_get_wrappers()); StreamWrapper::register($this->client); + restore_error_handler(); } public function testCannotOpenBuckets() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("Cannot open a bucket"); - $this->expectWarning(); fopen('s3://bucket', 'r'); } public function testSupportsOnlyReadWriteXA() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("Mode not supported"); - $this->expectWarning(); fopen('s3://bucket/key', 'c'); } public function testValidatesXMode() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("s3://bucket/key already exists on Amazon S3"); - $this->expectWarning(); $this->addMockResults($this->client, [new Result()]); fopen('s3://bucket/key', 'x'); } @@ -171,7 +178,7 @@ public function testCanOpenWriteOnlyStreams() public function testTriggersErrorInsteadOfExceptionWhenWriteFlushFails() { $this->expectExceptionMessage("403 Forbidden"); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->addMockResults($this->client, [ function ($cmd, $req) { return new S3Exception('403 Forbidden', $cmd); } ]); @@ -239,8 +246,8 @@ public function testCanUnlinkFiles() public function testThrowsErrorsWhenUnlinkFails() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("403 Forbidden"); - $this->expectWarning(); $this->addMockResults($this->client, [ function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, ]); @@ -254,7 +261,7 @@ public function testCreatingBucketWithNoBucketReturnsFalse() public function testCreatingAlreadyExistingBucketRaisesError() { - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("Bucket already exists: s3://already-existing-bucket"); $this->addMockResults($this->client, [new Result()]); mkdir('s3://already-existing-bucket'); @@ -262,7 +269,7 @@ public function testCreatingAlreadyExistingBucketRaisesError() public function testCreatingAlreadyExistingBucketForKeyRaisesError() { - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("Subfolder already exists: s3://already-existing-bucket/key"); $this->addMockResults($this->client, [new Result()]); mkdir('s3://already-existing-bucket/key'); @@ -321,15 +328,15 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, public function testCannotDeleteS3() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("specify a bucket"); - $this->expectWarning(); rmdir('s3://'); } public function testRmDirWithExceptionTriggersError() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("403 Forbidden"); - $this->expectWarning(); $this->addMockResults($this->client, [ function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, ]); @@ -349,7 +356,7 @@ public function testCanDeleteBucketWithRmDir() $this->assertSame('s3.amazonaws.com', $entries[0]['request']->getUri()->getHost()); } - public static function rmdirProvider() + public static function rmdirProvider(): array { return [ ['s3://bucket/object/'], @@ -358,8 +365,9 @@ public static function rmdirProvider() } /** - * @dataProvider rmdirProvider - */ + + */ + #[DataProvider('rmdirProvider')] public function testCanDeleteObjectWithRmDir($path) { $history = new History(); @@ -396,8 +404,8 @@ public function testCanDeleteNestedFolderWithRmDir() public function testRenameEnsuresProtocolsMatch() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("rename(): Cannot rename a file across wrapper types"); - $this->expectWarning(); StreamWrapper::register($this->client, 'baz'); rename('s3://foo/bar', 'baz://qux/quux'); } @@ -405,14 +413,14 @@ public function testRenameEnsuresProtocolsMatch() public function testRenameEnsuresKeyIsSet() { $this->expectExceptionMessage("The Amazon S3 stream wrapper only supports copying objects"); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); rename('s3://foo/bar', 's3://baz'); } public function testRenameWithExceptionThrowsError() { $this->expectExceptionMessage("Forbidden"); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->addMockResults($this->client, [ function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, ]); @@ -512,7 +520,7 @@ public function testCanPullStatDataFromCache() public function testFailingStatTriggersError() { $this->expectExceptionMessage("Forbidden"); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); // Sends one request for HeadObject, then another for ListObjects $this->addMockResults($this->client, [ function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, @@ -525,7 +533,7 @@ function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); } public function testBucketNotFoundTriggersError() { $this->expectExceptionMessage("File or directory not found: s3://bucket"); - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->addMockResults($this->client, [ function ($cmd, $r) { return new S3Exception('404', $cmd); }, ]); @@ -569,8 +577,8 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, public function testCannotStatPrefixWithNoResults() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("File or directory not found: s3://bucket/prefix"); - $this->expectWarning(); $this->addMockResults($this->client, [ function ($cmd, $r) { return new S3Exception('404', $cmd); }, new Result() @@ -613,8 +621,9 @@ public static function fileTypeProvider() } /** - * @dataProvider fileTypeProvider - */ + + */ + #[DataProvider('fileTypeProvider')] public function testDeterminesIfFileOrDir($uri, $queue, $result) { $history = new History(); @@ -642,13 +651,8 @@ public function testDeterminesIfFileOrDir($uri, $queue, $result) public function testStreamCastIsNotPossible() { - if (PHP_VERSION_ID < 80000) { - $this->expectExceptionMessage("cannot represent a stream of type user-space"); - $this->expectWarning(); - } else { - $this->expectExceptionMessage('No stream arrays were passed'); - $this->expectException(\ValueError::class); - } + $this->expectException(\ValueError::class); + $this->expectExceptionMessage('No stream arrays were passed'); $this->addMockResults($this->client, [ new Result(['Body' => Psr7\Utils::streamFor('')]) @@ -661,11 +665,17 @@ public function testStreamCastIsNotPossible() public function testEnsuresClientIsSet() { + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }); $this->expectExceptionMessage("No client in stream context"); - $this->expectWarning(); - fopen('s3://bucket/key', 'r', false, stream_context_create([ - 's3' => ['client' => null] - ])); + try { + fopen('s3://bucket/key', 'r', false, stream_context_create([ + 's3' => ['client' => null] + ])); + } finally { + restore_error_handler(); + } } public function testDoesNotErrorOnIsLink() diff --git a/tests/S3/StreamWrapperTest.php b/tests/S3/StreamWrapperTest.php index 59027eb3c1..b7eb831123 100644 --- a/tests/S3/StreamWrapperTest.php +++ b/tests/S3/StreamWrapperTest.php @@ -13,10 +13,13 @@ use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\StreamWrapper + */ +#[CoversClass(StreamWrapper::class)] class StreamWrapperTest extends TestCase { use UsesServiceTrait; @@ -40,6 +43,7 @@ public function tear_down() { stream_wrapper_unregister('s3'); $this->client = null; + restore_exception_handler(); // In case it was not restored } public function testRegistersStreamWrapperOnlyOnce() @@ -51,34 +55,66 @@ public function testRegistersStreamWrapperOnlyOnce() public function testCannotOpenBuckets() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("Cannot open a bucket"); - $this->expectWarning(); - fopen('s3://bucket', 'r'); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + fopen('s3://bucket', 'r'); + } finally { + restore_error_handler(); + } } public function testSupportsOnlyReadWriteXA() { $this->expectExceptionMessage("Mode not supported"); - $this->expectWarning(); - fopen('s3://bucket/key', 'c'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + fopen('s3://bucket/key', 'c'); + } finally { + restore_error_handler(); + } } public function testValidatesXMode() { $this->expectExceptionMessage("s3://bucket/key already exists on Amazon S3"); - $this->expectWarning(); - $this->addMockResults($this->client, [new Result()]); - fopen('s3://bucket/key', 'x'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [new Result()]); + fopen('s3://bucket/key', 'x'); + } finally { + restore_error_handler(); + } } public function testValidatesArn() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage( "Invalid ARN: Unrecognized format:" . " arn:aws:s3:us-east-1:123456789012:foo:myaccess (type: foo)" ); - $this->expectWarning(); - fopen('s3://arn:aws:s3:us-east-1:123456789012:foo:myaccess/test_key', 'r'); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + fopen('s3://arn:aws:s3:us-east-1:123456789012:foo:myaccess/test_key', 'r'); + } finally { + restore_error_handler(); + } } /** @doesNotPerformAssertions */ @@ -284,13 +320,21 @@ public function testCanWriteEmptyFileToStream() public function testTriggersErrorInsteadOfExceptionWhenWriteFlushFails() { $this->expectExceptionMessage("403 Forbidden"); - $this->expectWarning(); - $this->addMockResults($this->client, [ - function ($cmd, $req) { return new S3Exception('403 Forbidden', $cmd); } - ]); - $s = fopen('s3://bucket/key', 'w'); - fwrite($s, 'test'); - fclose($s); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $req) { return new S3Exception('403 Forbidden', $cmd); } + ]); + $s = fopen('s3://bucket/key', 'w'); + fwrite($s, 'test'); + fclose($s); + } finally { + restore_error_handler(); + } } public function testCanOpenAppendStreamsWithOriginalFile() @@ -353,11 +397,19 @@ public function testCanUnlinkFiles() public function testThrowsErrorsWhenUnlinkFails() { $this->expectExceptionMessage("403 Forbidden"); - $this->expectWarning(); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - ]); - $this->assertFalse(unlink('s3://bucket/key')); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + ]); + $this->assertFalse(unlink('s3://bucket/key')); + } finally { + restore_error_handler(); + } } public function testCreatingBucketWithNoBucketReturnsFalse() @@ -367,18 +419,34 @@ public function testCreatingBucketWithNoBucketReturnsFalse() public function testCreatingAlreadyExistingBucketRaisesError() { - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("Bucket already exists: s3://already-existing-bucket"); - $this->addMockResults($this->client, [new Result()]); - mkdir('s3://already-existing-bucket'); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [new Result()]); + mkdir('s3://already-existing-bucket'); + } finally { + restore_error_handler(); + } } public function testCreatingAlreadyExistingBucketForKeyRaisesError() { - $this->expectWarning(); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("Subfolder already exists: s3://already-existing-bucket/key"); - $this->addMockResults($this->client, [new Result()]); - mkdir('s3://already-existing-bucket/key'); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [new Result()]); + mkdir('s3://already-existing-bucket/key'); + } finally { + restore_error_handler(); + } } public function testCreatingBucketsDoesNotSetAcl() @@ -434,19 +502,34 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, public function testCannotDeleteS3() { + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage("specify a bucket"); - $this->expectWarning(); - rmdir('s3://'); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + rmdir('s3://'); + } finally { + restore_error_handler(); + } } public function testRmDirWithExceptionTriggersError() { $this->expectExceptionMessage("403 Forbidden"); - $this->expectWarning(); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - ]); - rmdir('s3://bucket'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + ]); + rmdir('s3://bucket'); + } finally { + restore_error_handler(); + } } public function testCanDeleteBucketWithRmDir() @@ -471,8 +554,9 @@ public static function rmdirProvider() } /** - * @dataProvider rmdirProvider - */ + + */ + #[DataProvider('rmdirProvider')] public function testCanDeleteObjectWithRmDir($path) { $history = new History(); @@ -511,26 +595,50 @@ public function testCanDeleteNestedFolderWithRmDir() public function testRenameEnsuresProtocolsMatch() { $this->expectExceptionMessage("rename(): Cannot rename a file across wrapper types"); - $this->expectWarning(); - StreamWrapper::register($this->client, 'baz'); - rename('s3://foo/bar', 'baz://qux/quux'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_WARNING); + try { + StreamWrapper::register($this->client, 'baz'); + rename('s3://foo/bar', 'baz://qux/quux'); + } finally { + restore_error_handler(); + } } public function testRenameEnsuresKeyIsSet() { $this->expectExceptionMessage("The Amazon S3 stream wrapper only supports copying objects"); - $this->expectWarning(); - rename('s3://foo/bar', 's3://baz'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + rename('s3://foo/bar', 's3://baz'); + } finally { + restore_error_handler(); + } } public function testRenameWithExceptionThrowsError() { $this->expectExceptionMessage("Forbidden"); - $this->expectWarning(); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - ]); - rename('s3://foo/bar', 's3://baz/bar'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + ]); + rename('s3://foo/bar', 's3://baz/bar'); + } finally { + restore_error_handler(); + } } public function testCanRenameObjects() @@ -627,25 +735,41 @@ public function testCanPullStatDataFromCache() public function testFailingStatTriggersError() { $this->expectExceptionMessage("Forbidden"); - $this->expectWarning(); - // Sends one request for HeadObject, then another for ListObjects - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); } - ]); - clearstatcache('s3://bucket/key'); - stat('s3://bucket/key'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + // Sends one request for HeadObject, then another for ListObjects + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); } + ]); + clearstatcache('s3://bucket/key'); + stat('s3://bucket/key'); + } finally { + restore_error_handler(); + } } public function testBucketNotFoundTriggersError() { $this->expectExceptionMessage("File or directory not found: s3://bucket"); - $this->expectWarning(); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('404', $cmd); }, - ]); - clearstatcache('s3://bucket'); - stat('s3://bucket'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('404', $cmd); }, + ]); + clearstatcache('s3://bucket'); + stat('s3://bucket'); + } finally { + restore_error_handler(); + } } public function testStatsRegularObjects() @@ -708,13 +832,21 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, public function testCannotStatPrefixWithNoResults() { $this->expectExceptionMessage("File or directory not found: s3://bucket/prefix"); - $this->expectWarning(); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('404', $cmd); }, - new Result() - ]); - clearstatcache('s3://bucket/prefix'); - stat('s3://bucket/prefix'); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('404', $cmd); }, + new Result() + ]); + clearstatcache('s3://bucket/prefix'); + stat('s3://bucket/prefix'); + } finally { + restore_error_handler(); + } } public static function fileTypeProvider() @@ -751,8 +883,9 @@ public static function fileTypeProvider() } /** - * @dataProvider fileTypeProvider - */ + + */ + #[DataProvider('fileTypeProvider')] public function testDeterminesIfFileOrDir($uri, $queue, $result) { $history = new History(); @@ -780,13 +913,8 @@ public function testDeterminesIfFileOrDir($uri, $queue, $result) public function testStreamCastIsNotPossible() { - if (PHP_VERSION_ID < 80000) { - $this->expectExceptionMessage("cannot represent a stream of type user-space"); - $this->expectWarning(); - } else { - $this->expectExceptionMessage('No stream arrays were passed'); - $this->expectException(\ValueError::class); - } + $this->expectExceptionMessage('No stream arrays were passed'); + $this->expectException(\ValueError::class); $this->addMockResults($this->client, [ new Result(['Body' => Psr7\Utils::streamFor('')]) @@ -800,10 +928,18 @@ public function testStreamCastIsNotPossible() public function testEnsuresClientIsSet() { $this->expectExceptionMessage("No client in stream context"); - $this->expectWarning(); - fopen('s3://bucket/key', 'r', false, stream_context_create([ - 's3' => ['client' => null] - ])); + $this->expectException(\RuntimeException::class); + + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + fopen('s3://bucket/key', 'r', false, stream_context_create([ + 's3' => ['client' => null] + ])); + } finally { + restore_error_handler(); + } } public function testDoesNotErrorOnIsLink() @@ -1025,7 +1161,7 @@ public function testStatDataIsClearedOnWriteUsingCustomProtocol() stream_wrapper_unregister('foo'); } - public static function contentProvider() + public static function contentProvider(): array { return [ ['foo'], @@ -1034,13 +1170,17 @@ public static function contentProvider() } /** - * @dataProvider contentProvider - */ - public function testTriggersErrorOnNoFlushOrClose($content) + + */ + #[DataProvider('contentProvider')] + public function testTriggersErrorOnNoFlushOrClose(string $content) { - $this->expectWarning(); - $this->expectWarning("Unable to determine stream size. Did you forget to close or flush the stream?"); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage("Unable to determine stream size. Did you forget to close or flush the stream?"); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); $stream = $this->getMockBuilder(Psr7\Stream::class) ->disableOriginalConstructor() ->getMock(); @@ -1087,22 +1227,30 @@ public function testStreamMetadataReturnsFalse() public function testStreamLockReturnsFalse() { - $this->expectWarning(); - $this->expectWarningMessage( + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage( 'stream_lock() is not supported by the Amazon S3 stream wrapper' ); - $stream = $this->getMockBuilder(Psr7\Stream::class) - ->disableOriginalConstructor() - ->getMock(); - $this->addMockResults( - $this->client, - [ - new Result(['Body' => $stream]), - ] - ); - $handle = fopen('s3://bucket/key', 'r'); - $this->assertFalse(flock($handle, LOCK_EX)); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $stream = $this->getMockBuilder(Psr7\Stream::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->addMockResults( + $this->client, + [ + new Result(['Body' => $stream]), + ] + ); + $handle = fopen('s3://bucket/key', 'r'); + $this->assertFalse(flock($handle, LOCK_EX)); + } finally { + restore_error_handler(); + } } public function testStreamTruncateReturnsFalse() diff --git a/tests/S3/StreamWrapperV2ExistenceTest.php b/tests/S3/StreamWrapperV2ExistenceTest.php index c74c3cdf01..27a34cdb39 100644 --- a/tests/S3/StreamWrapperV2ExistenceTest.php +++ b/tests/S3/StreamWrapperV2ExistenceTest.php @@ -12,12 +12,12 @@ use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; -/** - * @covers Aws\S3\StreamWrapper - */ +#[CoversClass(StreamWrapper::class)] class StreamWrapperV2ExistenceTest extends TestCase { use UsesServiceTrait; @@ -239,14 +239,21 @@ public function testCanWriteEmptyFileToStream() public function testTriggersErrorInsteadOfExceptionWhenWriteFlushFails() { - $this->expectException(S3Exception::class); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('403 Forbidden'); - $this->addMockResults($this->client, [ - function ($cmd, $req) { return new S3Exception('403 Forbidden', $cmd); } - ]); - $s = fopen('s3://bucket/key', 'w'); - fwrite($s, 'test'); - fclose($s); + set_error_handler(function ($err, $message) { + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $req) { return new S3Exception('403 Forbidden', $cmd); } + ]); + $s = fopen('s3://bucket/key', 'w'); + fwrite($s, 'test'); + fclose($s); + } finally { + restore_error_handler(); + } } public function testCanOpenAppendStreamsWithOriginalFile() @@ -308,12 +315,20 @@ public function testCanUnlinkFiles() public function testThrowsErrorsWhenUnlinkFails() { - $this->expectError(); - $this->expectErrorMessage('403 Forbidden'); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - ]); - $this->assertFalse(unlink('s3://bucket/key')); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('403 Forbidden'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + ]); + $this->assertFalse(unlink('s3://bucket/key')); + } finally { + restore_error_handler(); + } } public function testCreatingBucketWithNoBucketReturnsFalse() @@ -323,18 +338,34 @@ public function testCreatingBucketWithNoBucketReturnsFalse() public function testCreatingAlreadyExistingBucketRaisesError() { - $this->expectError(); - $this->expectErrorMessage('Bucket already exists: s3://already-existing-bucket'); - $this->addMockResults($this->client, [new Result()]); - mkdir('s3://already-existing-bucket'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Bucket already exists: s3://already-existing-bucket'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [new Result()]); + mkdir('s3://already-existing-bucket'); + } finally { + restore_error_handler(); + } } public function testCreatingAlreadyExistingBucketForKeyRaisesError() { - $this->expectError(); - $this->expectErrorMessage('Subfolder already exists: s3://already-existing-bucket/key'); - $this->addMockResults($this->client, [new Result()]); - mkdir('s3://already-existing-bucket/key'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Subfolder already exists: s3://already-existing-bucket/key'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [new Result()]); + mkdir('s3://already-existing-bucket/key'); + } finally { + restore_error_handler(); + } } public function testCreatingBucketsDoesNotSetAcl() @@ -407,19 +438,35 @@ function ($cmd, $r) { return new S3Exception( public function testCannotDeleteS3() { - $this->expectError(); - $this->expectErrorMessage('specify a bucket'); - rmdir('s3://'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('specify a bucket'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + rmdir('s3://'); + } finally { + restore_error_handler(); + } } public function testRmDirWithExceptionTriggersError() { - $this->expectError(); - $this->expectErrorMessage('403 Forbidden'); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - ]); - rmdir('s3://bucket'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('403 Forbidden'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + ]); + rmdir('s3://bucket'); + } finally { + restore_error_handler(); + } } public function testCanDeleteBucketWithRmDir() @@ -443,9 +490,7 @@ public static function rmdirProvider() ]; } - /** - * @dataProvider rmdirProvider - */ + #[DataProvider('rmdirProvider')] public function testCanDeleteObjectWithRmDir($path) { $history = new History(); @@ -483,27 +528,52 @@ public function testCanDeleteNestedFolderWithRmDir() public function testRenameEnsuresProtocolsMatch() { - $this->expectError(); - $this->expectErrorMessage('rename(): Cannot rename a file across wrapper types'); - StreamWrapper::register($this->client, 'baz'); - rename('s3://foo/bar', 'baz://qux/quux'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('rename(): Cannot rename a file across wrapper types'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_WARNING); + try { + StreamWrapper::register($this->client, 'baz'); + rename('s3://foo/bar', 'baz://qux/quux'); + } finally { + restore_error_handler(); + } } public function testRenameEnsuresKeyIsSet() { - $this->expectError(); - $this->expectErrorMessage('The Amazon S3 stream wrapper only supports copying objects'); - rename('s3://foo/bar', 's3://baz'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('The Amazon S3 stream wrapper only supports copying objects'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + rename('s3://foo/bar', 's3://baz'); + } finally { + restore_error_handler(); + } } public function testRenameWithExceptionThrowsError() { - $this->expectError(); - $this->expectErrorMessage('Forbidden'); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - ]); - rename('s3://foo/bar', 's3://baz/bar'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Forbidden'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + ]); + rename('s3://foo/bar', 's3://baz/bar'); + } finally { + restore_error_handler(); + } } public function testCanRenameObjects() @@ -599,31 +669,47 @@ public function testCanPullStatDataFromCache() public function testFailingStatTriggersError() { - $this->expectError(); - $this->expectErrorMessage('Forbidden'); - // Sends one request for HeadObject, then another for ListObjects - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, - function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); } - ]); - clearstatcache('s3://bucket/key'); - stat('s3://bucket/key'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Forbidden'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + // Sends one request for HeadObject, then another for ListObjects + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); }, + function ($cmd, $r) { return new S3Exception('403 Forbidden', $cmd); } + ]); + clearstatcache('s3://bucket/key'); + stat('s3://bucket/key'); + } finally { + restore_error_handler(); + } } public function testBucketNotFoundTriggersError() { - $this->expectError(); - $this->expectErrorMessage('File or directory not found: s3://bucket'); - $this->addMockResults($this->client, [ - function ($cmd, $r) { - return new S3Exception( - '404', - $cmd, - ['response' => new Response(404)] - );}, - ]); - clearstatcache('s3://bucket'); - stat('s3://bucket'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('File or directory not found: s3://bucket'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { + return new S3Exception( + '404', + $cmd, + ['response' => new Response(404)] + );}, + ]); + clearstatcache('s3://bucket'); + stat('s3://bucket'); + } finally { + restore_error_handler(); + } } public function testStatsRegularObjects() @@ -667,19 +753,27 @@ function ($cmd, $r) { return new S3Exception( public function testCannotStatPrefixWithNoResults() { - $this->expectError(); - $this->expectErrorMessage('File or directory not found: s3://bucket/prefix'); - $this->addMockResults($this->client, [ - function ($cmd, $r) { return new S3Exception( - '404', - $cmd, - ['response' => new Response(404)] - ); - }, - new Result() - ]); - clearstatcache('s3://bucket/prefix'); - stat('s3://bucket/prefix'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('File or directory not found: s3://bucket/prefix'); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + try { + $this->addMockResults($this->client, [ + function ($cmd, $r) { return new S3Exception( + '404', + $cmd, + ['response' => new Response(404)] + ); + }, + new Result() + ]); + clearstatcache('s3://bucket/prefix'); + stat('s3://bucket/prefix'); + } finally { + restore_error_handler(); + } } public static function fileTypeProvider() @@ -720,9 +814,7 @@ public static function fileTypeProvider() ]; } - /** - * @dataProvider fileTypeProvider - */ + #[DataProvider('fileTypeProvider')] public function testDeterminesIfFileOrDir($uri, $queue, $result) { $history = new History(); @@ -750,21 +842,24 @@ public function testDeterminesIfFileOrDir($uri, $queue, $result) public function testStreamCastIsNotPossible() { - if (PHP_VERSION_ID < 80000) { - $this->expectExceptionMessage("cannot represent a stream of type user-space"); - $this->expectWarning(); - } else { - $this->expectExceptionMessage('No stream arrays were passed'); - $this->expectException(\ValueError::class); + $this->expectExceptionMessage('No stream arrays were passed'); + $this->expectException(\ValueError::class); + + set_error_handler(function ($err, $message){ + throw new \RuntimeException($message); + }, E_USER_WARNING); + + try { + $this->addMockResults($this->client, [ + new Result(['Body' => Psr7\Utils::streamFor('')]) + ]); + $r = fopen('s3://bucket/key', 'r'); + $read = [$r]; + $write = $except = null; + stream_select($read, $write, $except, 0); + } finally { + restore_error_handler(); } - - $this->addMockResults($this->client, [ - new Result(['Body' => Psr7\Utils::streamFor('')]) - ]); - $r = fopen('s3://bucket/key', 'r'); - $read = [$r]; - $write = $except = null; - stream_select($read, $write, $except, 0); } public function testDoesNotErrorOnIsLink() diff --git a/tests/S3/TransferTest.php b/tests/S3/TransferTest.php index 3171d1a9e4..ee41229e18 100644 --- a/tests/S3/TransferTest.php +++ b/tests/S3/TransferTest.php @@ -13,10 +13,13 @@ use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use SplFileInfo; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\Transfer + */ +#[CoversClass(Transfer::class)] class TransferTest extends TestCase { use UsesServiceTrait; @@ -379,8 +382,9 @@ function (CommandInterface $cmd, RequestInterface $req) { } /** - * @dataProvider providedPathsOutsideTarget - */ + + */ + #[DataProvider('providedPathsOutsideTarget')] public function testCannotDownloadObjectsOutsideTarget($key) { $this->expectException(\Aws\Exception\AwsException::class); @@ -555,8 +559,9 @@ function (CommandInterface $cmd, RequestInterface $req) { * @param $value * @return void * - * @dataProvider flexibleChecksumsProvider - */ + + */ + #[DataProvider('flexibleChecksumsProvider')] public function testAddsFlexibleChecksums($checksumAlgorithm) { if ($checksumAlgorithm === 'crc32c' diff --git a/tests/S3/UseArnRegion/ConfigurationProviderTest.php b/tests/S3/UseArnRegion/ConfigurationProviderTest.php index 3cfea47ef3..ab945f102e 100644 --- a/tests/S3/UseArnRegion/ConfigurationProviderTest.php +++ b/tests/S3/UseArnRegion/ConfigurationProviderTest.php @@ -9,10 +9,12 @@ use Aws\S3\UseArnRegion\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\UseArnRegion\ConfigurationProvider + */ +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; diff --git a/tests/S3/UseArnRegion/ConfigurationTest.php b/tests/S3/UseArnRegion/ConfigurationTest.php index 4100da4e50..7b8daec011 100644 --- a/tests/S3/UseArnRegion/ConfigurationTest.php +++ b/tests/S3/UseArnRegion/ConfigurationTest.php @@ -3,18 +3,22 @@ use Aws\S3\UseArnRegion\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\S3\UseArnRegion\Configuration + */ +#[CoversClass(\Aws\S3\UseArnRegion\Configuration::class)] class ConfigurationTest extends TestCase { /** - * @dataProvider correctValueCases * * @param $param * @param $expected - */ + + */ + #[DataProvider('correctValueCases')] public function testGetsCorrectValues($param, $expected) { $config = new Configuration($param); diff --git a/tests/S3/ValidateResponseChecksumParserTest.php b/tests/S3/ValidateResponseChecksumParserTest.php index 14d18fe69d..6a05178a18 100644 --- a/tests/S3/ValidateResponseChecksumParserTest.php +++ b/tests/S3/ValidateResponseChecksumParserTest.php @@ -10,17 +10,21 @@ use Aws\Result; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3\ValidateResponseChecksumParser + */ +#[CoversClass(ValidateResponseChecksumParser::class)] class ValidateResponseChecksumParserTest extends TestCase { use UsesServiceTrait; /** - * @dataProvider getChosenChecksumCases - */ + + */ + #[DataProvider('getChosenChecksumCases')] public function testValidatesChoosesRightChecksum( $responseAlgorithms, $checksumHeadersReturned, $expectedChecksum ) { diff --git a/tests/S3Control/EndpointArnMiddlewareTest.php b/tests/S3Control/EndpointArnMiddlewareTest.php index 4c6f37fd62..0c1294b5cf 100644 --- a/tests/S3Control/EndpointArnMiddlewareTest.php +++ b/tests/S3Control/EndpointArnMiddlewareTest.php @@ -10,16 +10,18 @@ use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\S3Control\EndpointArnMiddleware + */ +#[CoversClass(\Aws\S3Control\EndpointArnMiddleware::class)] class EndpointArnMiddlewareTest extends TestCase { use S3ControlTestingTrait; /** - * @dataProvider providedSuccessCases * * @param $cmdName * @param $cmdParams @@ -30,7 +32,9 @@ class EndpointArnMiddlewareTest extends TestCase * @param $signingRegion * @param $signingService * @throws \Exception - */ + + */ + #[DataProvider('providedSuccessCases')] public function testCorrectlyModifiesRequestAndCommand( $cmdName, $cmdParams, @@ -423,14 +427,15 @@ public static function providedSuccessCases() } /** - * @dataProvider providedFailureCases * * @param $cmdName * @param $cmdParams * @param $options * @param $expectedException * @throws \Exception - */ + + */ + #[DataProvider('providedFailureCases')] public function testCorrectlyThrowsForBadInputsOrConfig( $cmdName, $cmdParams, diff --git a/tests/S3Control/S3ControlClientTest.php b/tests/S3Control/S3ControlClientTest.php index 0f71a5f38d..f8d994c640 100644 --- a/tests/S3Control/S3ControlClientTest.php +++ b/tests/S3Control/S3ControlClientTest.php @@ -6,10 +6,12 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\S3Control\S3ControlClient + */ +#[CoversClass(S3ControlClient::class)] class S3ControlClientTest extends TestCase { use S3ControlTestingTrait; diff --git a/tests/Script/ComposerTest.php b/tests/Script/ComposerTest.php index cdd333b08c..5f8ca87cff 100644 --- a/tests/Script/ComposerTest.php +++ b/tests/Script/ComposerTest.php @@ -6,6 +6,7 @@ use Symfony\Component\Filesystem\Exception\IOException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Symfony\Component\Filesystem\Filesystem; +use PHPUnit\Framework\Attributes\DataProvider; class ComposerTest extends TestCase { @@ -20,11 +21,12 @@ public static function invalidServiceNameProvider() } /** - * @dataProvider invalidServiceNameProvider * * @param $serviceList * @param $invalidService - */ + + */ + #[DataProvider('invalidServiceNameProvider')] public function testListInvalidServiceName($serviceList, $invalidService) { $this->expectException(\InvalidArgumentException::class); @@ -58,10 +60,11 @@ public static function servicesToKeepProvider() } /** - * @dataProvider servicesToKeepProvider * * @param $servicesToKeep - */ + + */ + #[DataProvider('servicesToKeepProvider')] public function testRemoveServices($servicesToKeep) { $filesystem = new Filesystem(); @@ -114,8 +117,9 @@ public function testRemoveServices($servicesToKeep) } /** - * @dataProvider retryProvider - */ + + */ + #[DataProvider('retryProvider')] public function testRetriesOnException($success, $writeCalls) { if (!$success) { diff --git a/tests/SdkTest.php b/tests/SdkTest.php index a0db561489..560e3664ef 100644 --- a/tests/SdkTest.php +++ b/tests/SdkTest.php @@ -6,10 +6,12 @@ use Aws\S3\S3MultiRegionClient; use Aws\Sdk; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Sdk + */ +#[CoversClass(Sdk::class)] class SdkTest extends TestCase { diff --git a/tests/Signature/AnonymousSignatureTest.php b/tests/Signature/AnonymousSignatureTest.php index 40d4a256af..46a8a49123 100644 --- a/tests/Signature/AnonymousSignatureTest.php +++ b/tests/Signature/AnonymousSignatureTest.php @@ -5,10 +5,12 @@ use Aws\Signature\AnonymousSignature; use GuzzleHttp\Psr7\Request; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Signature\AnonymousSignature + */ +#[CoversClass(AnonymousSignature::class)] class AnonymousSignatureTest extends TestCase { public function testDoesNotSignsRequests() diff --git a/tests/Signature/DpopSignatureTest.php b/tests/Signature/DpopSignatureTest.php index f2f3c7f201..b75cbf01e6 100644 --- a/tests/Signature/DpopSignatureTest.php +++ b/tests/Signature/DpopSignatureTest.php @@ -4,10 +4,12 @@ use Aws\Signature\DpopSignature; use PHPUnit\Framework\TestCase; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Signature\DpopSignature + */ +#[CoversClass(DpopSignature::class)] class DpopSignatureTest extends TestCase { private function getValidEcKey(): \OpenSSLAsymmetricKey diff --git a/tests/Signature/S3ExpressSignatureTest.php b/tests/Signature/S3ExpressSignatureTest.php index 9c383ca966..4288466672 100644 --- a/tests/Signature/S3ExpressSignatureTest.php +++ b/tests/Signature/S3ExpressSignatureTest.php @@ -6,12 +6,14 @@ use Aws\Signature\S3SignatureV4; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/sig_hack.php'; /** - * @covers Aws\Signature\S3ExpressSignature + */ +#[CoversClass(S3ExpressSignature::class)] class S3ExpressSignatureTest extends TestCase { private function getFixtures() diff --git a/tests/Signature/S3SignatureV4Test.php b/tests/Signature/S3SignatureV4Test.php index f2f6eb4226..50c70d5672 100644 --- a/tests/Signature/S3SignatureV4Test.php +++ b/tests/Signature/S3SignatureV4Test.php @@ -5,11 +5,13 @@ use Aws\Signature\S3SignatureV4; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/sig_hack.php'; /** - * @covers Aws\Signature\S3SignatureV4 + */ +#[CoversClass(S3SignatureV4::class)] class S3SignatureV4Test extends TestCase { public static function set_up_before_class() diff --git a/tests/Signature/SignatureProviderTest.php b/tests/Signature/SignatureProviderTest.php index 4811f949bc..94a7884b80 100644 --- a/tests/Signature/SignatureProviderTest.php +++ b/tests/Signature/SignatureProviderTest.php @@ -9,10 +9,13 @@ use Aws\Signature\SignatureProvider; use Aws\Signature\SignatureV4; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Signature\SignatureProvider + */ +#[CoversClass(SignatureProvider::class)] class SignatureProviderTest extends TestCase { public static function versionProvider() @@ -37,8 +40,9 @@ public static function versionProvider() } /** - * @dataProvider versionProvider - */ + + */ + #[DataProvider('versionProvider')] public function testCreatesSignatureFromVersionString($v, $type, $service) { $fn = SignatureProvider::version(); diff --git a/tests/Signature/SignatureV4Test.php b/tests/Signature/SignatureV4Test.php index 950e15d67e..7ae13b13ee 100644 --- a/tests/Signature/SignatureV4Test.php +++ b/tests/Signature/SignatureV4Test.php @@ -7,12 +7,15 @@ use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\NoSeekStream; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/sig_hack.php'; /** - * @covers Aws\Signature\SignatureV4 + */ +#[CoversClass(SignatureV4::class)] class SignatureV4Test extends TestCase { const DEFAULT_KEY = 'AKIDEXAMPLE'; @@ -131,8 +134,9 @@ public static function getExpiresDateTimeInterfaceInputs() } /** - * @dataProvider getExpiresDateTimeInterfaceInputs - */ + + */ + #[DataProvider('getExpiresDateTimeInterfaceInputs')] public function testCreatesPresignedDatesFromDateTime($dateTime) { $_SERVER['override_v4_time'] = true; @@ -194,8 +198,9 @@ public static function getStartDateTimeInterfaceInputs() } /** - * @dataProvider getStartDateTimeInterfaceInputs - */ + + */ + #[DataProvider('getStartDateTimeInterfaceInputs')] public function testUsesStartDateFromDateTimeIfPresent($dateTime) { $options = ['start_time' => $dateTime]; @@ -448,8 +453,9 @@ public static function testUnsignedPayloadProvider() } /** - * @dataProvider testUnsignedPayloadProvider - */ + + */ + #[DataProvider('testUnsignedPayloadProvider')] public function testSignRequestUnsignedPayload($req, $sreq, $creq) { $_SERVER['aws_time'] = '20110909T233600Z'; @@ -571,8 +577,9 @@ public static function testProvider() } /** - * @dataProvider testProvider - */ + + */ + #[DataProvider('testProvider')] public function testSignsRequests($req, $sreq, $creq) { $_SERVER['aws_time'] = '20110909T233600Z'; diff --git a/tests/Sqs/SqsClientTest.php b/tests/Sqs/SqsClientTest.php index 7e5944db9a..7b1e4fa651 100644 --- a/tests/Sqs/SqsClientTest.php +++ b/tests/Sqs/SqsClientTest.php @@ -6,10 +6,12 @@ use Aws\Sqs\SqsClient; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Sqs\SqsClient + */ +#[CoversClass(SqsClient::class)] class SqsClientTest extends TestCase { use UsesServiceTrait; diff --git a/tests/Ssm/SsmClientTest.php b/tests/Ssm/SsmClientTest.php index f072aef541..7bbf734e92 100644 --- a/tests/Ssm/SsmClientTest.php +++ b/tests/Ssm/SsmClientTest.php @@ -5,10 +5,12 @@ use Aws\MockHandler; use Aws\Result; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Ssm\SsmClient + */ +#[CoversClass(SsmClient::class)] class SsmClientTest extends TestCase { public function testCanDisableAutoFillPerClient() diff --git a/tests/StreamRequestPayloadMiddlewareTest.php b/tests/StreamRequestPayloadMiddlewareTest.php index 9c519a5a70..80245b662e 100644 --- a/tests/StreamRequestPayloadMiddlewareTest.php +++ b/tests/StreamRequestPayloadMiddlewareTest.php @@ -14,21 +14,25 @@ use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\StreamRequestPayloadMiddleware + */ +#[CoversClass(\Aws\StreamRequestPayloadMiddleware::class)] class StreamRequestPayloadMiddlewareTest extends TestCase { use ArraySubsetAsserts; /** - * @dataProvider addsProperHeadersDataProvider * * @param array $commandDef * @param array $expectedHeaders * @param array $expectedNonHeaders - */ + + */ + #[DataProvider('addsProperHeadersDataProvider')] public function testAddsProperHeaders( array $commandDef, array $expectedHeaders, diff --git a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php index 8c1d7f454d..c7f4e0971a 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php @@ -10,6 +10,7 @@ use Aws\Sts\RegionalEndpoints\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; /** * git\Sts\RegionalEndpoints\ConfigurationProvider @@ -384,10 +385,11 @@ function () use ($expected) { } /** - * @dataProvider getSuccessfulUnwrapData * @param $toUnwrap * @param ConfigurationInterface $expected - */ + + */ + #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { $this->assertSame( diff --git a/tests/Sts/RegionalEndpoints/ConfigurationTest.php b/tests/Sts/RegionalEndpoints/ConfigurationTest.php index ec4120c89e..5ad7c96e5d 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationTest.php @@ -4,10 +4,12 @@ use Aws\Sts\RegionalEndpoints\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\Sts\RegionalEndpoints\Configuration + */ +#[CoversClass(\Aws\Sts\RegionalEndpoints\Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/Sts/StsClientTest.php b/tests/Sts/StsClientTest.php index 5aaae803cc..c689879c8a 100644 --- a/tests/Sts/StsClientTest.php +++ b/tests/Sts/StsClientTest.php @@ -15,10 +15,13 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Uri; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Sts\StsClient + */ +#[CoversClass(StsClient::class)] class StsClientTest extends TestCase { private $originalEnv = []; @@ -184,10 +187,11 @@ public function testCanCreateCredentialsObjectFromStsResultWithFederatedUser() } /** - * @dataProvider stsAssumeRoleOperationsDataProvider * * @return void - */ + + */ + #[DataProvider('stsAssumeRoleOperationsDataProvider')] public function testStsAssumeRoleOperationsWithAccountId($response, $expected) { $operation = 'assumeRole'; @@ -233,8 +237,9 @@ public static function stsAssumeRoleOperationsDataProvider(): array } /** - * @dataProvider stsAssumeRoleWithSAMLOperationsDataProvider - */ + + */ + #[DataProvider('stsAssumeRoleWithSAMLOperationsDataProvider')] public function testStsAssumeRoleWithSAMLOperationsWithAccountId( $response, $expected @@ -292,8 +297,9 @@ public static function stsAssumeRoleWithSAMLOperationsDataProvider(): array } /** - * @dataProvider stsAssumeRoleWithWebIdentityOperationsDataProvider - */ + + */ + #[DataProvider('stsAssumeRoleWithWebIdentityOperationsDataProvider')] public function testStsAssumeRoleWithWebIdentityOperationsWithAccountId( $response, $expected @@ -348,8 +354,9 @@ public static function stsAssumeRoleWithWebIdentityOperationsDataProvider(): arr } /** - * @dataProvider stsGetFederationTokenOperationsDataProvider - */ + + */ + #[DataProvider('stsGetFederationTokenOperationsDataProvider')] public function testStsGetFederationTokenOperationsWithAccountId( $response, $expected diff --git a/tests/Token/BearerTokenAuthorizationTest.php b/tests/Token/BearerTokenAuthorizationTest.php index f7bce113a9..166eb4cd1f 100644 --- a/tests/Token/BearerTokenAuthorizationTest.php +++ b/tests/Token/BearerTokenAuthorizationTest.php @@ -4,10 +4,13 @@ use Aws\Token\Token; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Token\BearerTokenAuthorization + */ +#[CoversClass(BearerTokenAuthorization::class)] class BearerTokenAuthorizationTest extends TestCase { public static function bearerTestProvider() { @@ -34,8 +37,9 @@ public static function bearerTestProvider() { } /** - * @dataProvider bearerTestProvider - */ + + */ + #[DataProvider('bearerTestProvider')] public function testBearerSuccessCases($headers, $tokenString, $expectedHeaders) { $authorizer = new \Aws\Token\BearerTokenAuthorization(); $request = new Request('GET', 'http://foo.com'); diff --git a/tests/Token/BedrockTokenProviderTest.php b/tests/Token/BedrockTokenProviderTest.php index 9b7aa70988..0b6809d97e 100644 --- a/tests/Token/BedrockTokenProviderTest.php +++ b/tests/Token/BedrockTokenProviderTest.php @@ -13,6 +13,7 @@ use Aws\Token\TokenSource; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class BedrockTokenProviderTest extends TestCase { @@ -244,8 +245,9 @@ public function testMemoization(): void * @param $expectations * @param $iniConfig * - * @dataProvider integrationWithClientProvider - */ + + */ + #[DataProvider('integrationWithClientProvider')] public function testIntegrationWithClient( $serviceName, $envVars, @@ -395,8 +397,9 @@ public static function integrationWithClientProvider(): \Generator /** * Test that token source is added to user agent header * - * @dataProvider tokenSourceUserAgentProvider - */ + + */ + #[DataProvider('tokenSourceUserAgentProvider')] public function testTokenSourceInUserAgent( string $service, string $operation, diff --git a/tests/Token/SsoTokenProviderTest.php b/tests/Token/SsoTokenProviderTest.php index 9372b80280..142f283006 100644 --- a/tests/Token/SsoTokenProviderTest.php +++ b/tests/Token/SsoTokenProviderTest.php @@ -8,12 +8,14 @@ use Aws\Token\SsoTokenProvider; use Aws\Token\TokenProvider; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Token/token_hack.php'; /** - * @covers \Aws\Token\SsoTokenProvider + */ +#[CoversClass(\Aws\Token\SsoTokenProvider::class)] class SsoTokenProviderTest extends TestCase { use UsesServiceTrait; diff --git a/tests/Token/TokenProviderTest.php b/tests/Token/TokenProviderTest.php index 458935c1b4..7860e82d5c 100644 --- a/tests/Token/TokenProviderTest.php +++ b/tests/Token/TokenProviderTest.php @@ -11,12 +11,15 @@ use Aws\Token\TokenProvider; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Token/token_hack.php'; /** - * @covers Aws\Token\TokenProvider + */ +#[CoversClass(TokenProvider::class)] class TokenProviderTest extends TestCase { use UsesServiceTrait; @@ -159,8 +162,9 @@ public static function tokenProviderSuccessCases(): array } /** - * @dataProvider tokenProviderSuccessCases - */ + + */ + #[DataProvider('tokenProviderSuccessCases')] public function testTokenProviderCachedSuccess($cachedToken, $expectedToken) { $_SERVER['aws_time'] = 1640466950; @@ -261,8 +265,9 @@ public static function tokenProviderSuccessCasesWithRefresh(): array } /** - * @dataProvider tokenProviderSuccessCasesWithRefresh - */ + + */ + #[DataProvider('tokenProviderSuccessCasesWithRefresh')] public function testTokenProviderCachedSuccessWithRefresh( $currentTime, $cachedToken, @@ -395,8 +400,9 @@ public static function tokenProviderFailureCases(): array } /** - * @dataProvider tokenProviderFailureCases - */ + + */ + #[DataProvider('tokenProviderFailureCases')] public function testTokenProviderFailureCases($cachedToken, $expectedException) { $cache = new LruArrayCache; diff --git a/tests/Token/TokenTest.php b/tests/Token/TokenTest.php index 286a6c511f..23918e7a60 100644 --- a/tests/Token/TokenTest.php +++ b/tests/Token/TokenTest.php @@ -6,10 +6,12 @@ use Aws\Token\Token; use Aws\Identity\IdentityInterface; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Token\Token + */ +#[CoversClass(Token::class)] class TokenTest extends TestCase { public function testHasGetters() diff --git a/tests/TraceMiddlewareTest.php b/tests/TraceMiddlewareTest.php index be23c32685..1bbdbea9ce 100644 --- a/tests/TraceMiddlewareTest.php +++ b/tests/TraceMiddlewareTest.php @@ -15,10 +15,13 @@ use GuzzleHttp\Psr7\Response; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\TraceMiddleware + */ +#[CoversClass(TraceMiddleware::class)] class TraceMiddlewareTest extends TestCase { public function testEmitsDebugInfo() @@ -129,12 +132,13 @@ public function testTracksAwsSpecificExceptions() } /** - * @dataProvider authStringProvider * * @param string $key * @param string $signature * @param array $headers - */ + + */ + #[DataProvider('authStringProvider')] public function testScrubsAuthStrings($key, $signature, array $headers) { $str = ''; diff --git a/tests/UserAgentMiddlewareTest.php b/tests/UserAgentMiddlewareTest.php index 4e150fd5d5..7114d10d1d 100644 --- a/tests/UserAgentMiddlewareTest.php +++ b/tests/UserAgentMiddlewareTest.php @@ -41,11 +41,14 @@ use Psr\Http\Message\RequestInterface; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers \Aws\UserAgentMiddleware * @runInSeparateProcess + */ +#[CoversClass(\Aws\UserAgentMiddleware::class)] class UserAgentMiddlewareTest extends TestCase { use MetricsBuilderTestTrait; @@ -133,12 +136,13 @@ public function testAppendsUserAgentHeader() * Tests the user agent header value contains the expected * component. * - * @dataProvider userAgentCasesDataProvider * @param array $args * @param string $expected * * @return void - */ + + */ + #[DataProvider('userAgentCasesDataProvider')] public function testUserAgentContainsValue(array $args, string $expected) { $handler = UserAgentMiddleware::wrap($args); @@ -321,10 +325,11 @@ public function testUserAgentCapturePaginatorMetric() /** * Tests user agent captures retry config metric. * - * @dataProvider retryConfigMetricProvider * * @return void - */ + + */ + #[DataProvider('retryConfigMetricProvider')] public function testUserAgentCaptureRetryConfigMetric( $retryMode, $expectedMetric @@ -827,10 +832,11 @@ private function getDynamoDBTestRuleSet(): array * @param string $checksumMetric * @param bool $supported * - * @dataProvider flexibleChecksumTestProvider * * @return void - */ + + */ + #[DataProvider('flexibleChecksumTestProvider')] public function testUserAgentCaptureFlexibleChecksumMetric( string $algorithm, string $checksumMetric, diff --git a/tests/UsesServiceTrait.php b/tests/UsesServiceTrait.php index faf4133087..0372420480 100644 --- a/tests/UsesServiceTrait.php +++ b/tests/UsesServiceTrait.php @@ -109,7 +109,7 @@ private function createMockAwsException( $type = $type ?: AwsException::class; $client = $this->getMockBuilder(AwsClientInterface::class) - ->setMethods(['getApi']) + ->onlyMethods(['getApi']) ->getMockForAbstractClass(); $client->expects($this->any()) diff --git a/tests/WaiterTest.php b/tests/WaiterTest.php index 55b2b63743..d8ba72e8a2 100644 --- a/tests/WaiterTest.php +++ b/tests/WaiterTest.php @@ -20,10 +20,13 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\Waiter + */ +#[CoversClass(Waiter::class)] class WaiterTest extends TestCase { use UsesServiceTrait; @@ -147,8 +150,9 @@ public function testCanWait() } /** - * @dataProvider waiterWorkflowDataProvider - */ + + */ + #[DataProvider('waiterWorkflowDataProvider')] public function testWaiterWorkflow($results, $expectedException) { // Normalize results @@ -280,8 +284,9 @@ private function getApiProvider() } /** - * @dataProvider matcherDataProvider - */ + + */ + #[DataProvider('matcherDataProvider')] public function testMatchers($matcher, $result, $acceptor, $expected) { diff --git a/tests/WrappedHttpHandlerTest.php b/tests/WrappedHttpHandlerTest.php index 1288ae701c..05455a423b 100644 --- a/tests/WrappedHttpHandlerTest.php +++ b/tests/WrappedHttpHandlerTest.php @@ -16,10 +16,13 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\ResponseInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\CoversClass; /** - * @covers Aws\WrappedHttpHandler + */ +#[CoversClass(WrappedHttpHandler::class)] class WrappedHttpHandlerTest extends TestCase { use TestServiceTrait; @@ -92,7 +95,6 @@ public function testCanRejectWithoutResponse() } /** - * @dataProvider responseAndParserProvider * * @param Response $res * @param string $serviceName @@ -100,7 +102,9 @@ public function testCanRejectWithoutResponse() * @param string|null $expectedCode * @param string|null $expectedId * @param array $expectedArray - */ + + */ + #[DataProvider('responseAndParserProvider')] public function testCanRejectWithAndParseResponse( Response $res, string $serviceName, diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3591ad7425..0dbfa771e3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,18 +9,6 @@ define('PHPUNIT_COMPOSER_INSTALL', __DIR__ . '/../vendor/autoload.php'); } -if (!class_exists('\PHPUnit\Framework\Constraint\RegularExpression')) { - class_alias('\PHPUnit_Framework_Constraint_PCREMatch', '\PHPUnit\Framework\Constraint\RegularExpression'); -} - -if (!class_exists('\PHPUnit\Framework\Constraint\Callback')) { - class_alias('\PHPUnit_Framework_Constraint_Callback', '\PHPUnit\Framework\Constraint\Callback'); -} - -if (!class_exists('\PHPUnit\Framework\Error\Warning')) { - class_alias('\PHPUnit_Framework_Error_Warning', '\PHPUnit\Framework\Error\Warning'); -} - // Clear out any previously compiled JMESPath files. JmesPath\Env::cleanCompileDir(); From 641e45af9df77802f5de7173c827fca0ad90833d Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Tue, 27 Jan 2026 03:48:12 -0800 Subject: [PATCH 05/19] chore: update essential files --- Makefile | 7 ++++++- composer.json | 4 ++-- phpunit.xml.dist | 21 +++++++++------------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 47df0e7d74..297a2d0fcb 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,12 @@ clear-cache: php build/aws-clear-cache.php test: - @AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar AWS_SESSION_TOKEN= AWS_CSM_ENABLED=false AWS_REGION= AWS_ENDPOINT_URL= AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \ + AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar AWS_SESSION_TOKEN= \ + AWS_CSM_ENABLED=false \ + AWS_REGION= \ + AWS_ENDPOINT_URL= \ + AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \ + XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite=unit $(TEST) test-phar: package diff --git a/composer.json b/composer.json index 3820ded327..ac95667707 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "ext-openssl": "*", "ext-dom": "*", "ext-sockets": "*", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.0", "behat/behat": "~3.0", "doctrine/cache": "~1.4", "aws/aws-php-sns-message-validator": "~1.0", @@ -42,7 +42,7 @@ "psr/simple-cache": "^2.0 || ^3.0", "sebastian/comparator": "^1.2.3 || ^4.0 || ^5.0", "yoast/phpunit-polyfills": "^2.0", - "dms/phpunit-arraysubset-asserts": "^0.4.0" + "dms/phpunit-arraysubset-asserts": "^v0.5.0" }, "suggest": { "ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d32051d2b7..5987d7c487 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,6 @@ - + - - src - - - src/data - @@ -26,4 +15,12 @@ + + + src + + + src/data + + From bb8822389830c17906f22ce55354afe0851c5390 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Wed, 28 Jan 2026 10:01:41 -0800 Subject: [PATCH 06/19] chore: minor fixes - Remove constructor override for TestCase extension. - Remove CoverClass from methods. --- tests/AbstractConfigurationProviderTest.php | 10 +- tests/DynamoDb/MarshalerTest.php | 20 +--- tests/FunctionsTest.php | 112 ++----------------- tests/Glacier/TreeHashTest.php | 28 +---- tests/S3/Crypto/S3EncryptionClientV3Test.php | 9 +- 5 files changed, 23 insertions(+), 156 deletions(-) diff --git a/tests/AbstractConfigurationProviderTest.php b/tests/AbstractConfigurationProviderTest.php index 6094ad3ec1..3c33baf92b 100644 --- a/tests/AbstractConfigurationProviderTest.php +++ b/tests/AbstractConfigurationProviderTest.php @@ -6,6 +6,7 @@ use Aws\Result; use Aws\ResultInterface; use GuzzleHttp\Promise; +use PHPUnit\Framework\MockObject\MockObject; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; @@ -15,13 +16,14 @@ #[CoversClass(\Aws\AbstractConfigurationProvider::class)] class AbstractConfigurationProviderTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var MockObject */ private $provider; - public function __construct() + protected function setUp(): void { - parent::__construct(); - $this->provider = $this->getMockForAbstractClass('\Aws\AbstractConfigurationProvider'); + $this->provider = $this->getMockForAbstractClass( + '\Aws\AbstractConfigurationProvider' + ); } public function testGetsHomeDirectoryForWindowsUsers() diff --git a/tests/DynamoDb/MarshalerTest.php b/tests/DynamoDb/MarshalerTest.php index b4e9dce480..55fe5e93b8 100644 --- a/tests/DynamoDb/MarshalerTest.php +++ b/tests/DynamoDb/MarshalerTest.php @@ -10,17 +10,11 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Marshaler::class)] class MarshalerTest extends TestCase { const ERROR = 'ERROR'; - /** - - */ #[DataProvider('getMarshalValueUseCases')] public function testMarshalValueUseCases($value, $expectedResult, $options = []) { @@ -347,11 +341,7 @@ public function testCanWrapLargeNumbersWithOption() $this->assertSame('99999999999999999999', (string) iterator_to_array($result['foo'])[0]); $this->assertSame('99999999999999999999.99999999999999999999', (string) $result['bar']); } - - /** - - */ - #[CoversClass(Marshaler::class)] + public function testNumberValueCanBeFormattedAndSerialized() { $number = new NumberValue('99999999999999999999'); @@ -359,10 +349,6 @@ public function testNumberValueCanBeFormattedAndSerialized() $this->assertSame('"99999999999999999999"', json_encode($number)); } - /** - - */ - #[CoversClass(Marshaler::class)] public function testBinaryValueCanBeFormattedAndSerialized() { $resource = fopen('php://temp', 'w+'); @@ -374,10 +360,6 @@ public function testBinaryValueCanBeFormattedAndSerialized() $this->assertSame('"foo"', json_encode($binary)); } - /** - - */ - #[CoversClass(Marshaler::class)] public function testSetValueCanBeFormattedAndSerialized() { $set = new SetValue(['foo', 'bar', 'baz']); diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index 4467a35589..b725b7417b 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -5,16 +5,26 @@ use Aws\MockHandler; use Aws\Result; use Aws\S3\S3Client; +use PHPUnit\Framework\Attributes\CoversFunction; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +#[CoversFunction('\Aws\recursive_dir_iterator')] +#[CoversClass('\Aws\or_chain')] +#[CoversClass('\Aws\load_compiled_json')] +#[CoversClass('\Aws\constantly')] +#[CoversClass('\Aws\filter')] +#[CoversClass('\Aws\map')] +#[CoversClass('\Aws\flatmap')] +#[CoversClass('\Aws\partition')] +#[CoversClass('\Aws\describe_type')] +#[CoversClass('\Aws\describe_type')] class FunctionsTest extends TestCase { /** */ - #[CoversClass(recursive_dir_iterator()::class)] public function testCreatesRecursiveDirIterator() { $iter = Aws\recursive_dir_iterator(__DIR__); @@ -23,10 +33,6 @@ public function testCreatesRecursiveDirIterator() $this->assertContains(realpath(__FILE__), $files); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testCreatesNonRecursiveDirIterator() { $iter = Aws\dir_iterator(__DIR__); @@ -35,10 +41,6 @@ public function testCreatesNonRecursiveDirIterator() $this->assertContains('FunctionsTest.php', $files); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testComposesOrFunctions() { $a = function ($a, $b) { return null; }; @@ -48,10 +50,6 @@ public function testComposesOrFunctions() $this->assertSame('+-', $comp('+', '-')); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testReturnsNullWhenNonResolve() { $called = []; @@ -63,30 +61,18 @@ public function testReturnsNullWhenNonResolve() $this->assertEquals(['a', 'b', 'c'], $called); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testCreatesConstantlyFunctions() { $fn = Aws\constantly('foo'); $this->assertSame('foo', $fn()); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testUsesJsonCompiler() { $this->expectException(\InvalidArgumentException::class); Aws\load_compiled_json('/path/to/not/here.json'); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testUsesPhpCompilationOfJsonIfPossible() { $soughtData = ['foo' => 'bar']; @@ -107,10 +93,6 @@ public function testUsesPhpCompilationOfJsonIfPossible() $this->assertSame($soughtData, Aws\load_compiled_json($jsonPath)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testOnlyLoadsCompiledJsonOnce() { $soughtData = ['foo' => 'bar']; @@ -140,10 +122,6 @@ public function testOnlyLoadsCompiledJsonOnce() $this->assertEquals($compiledAtime, fileatime($compiledPath)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testFilter() { $data = [0, 1, 2, 3, 4]; @@ -152,10 +130,6 @@ public function testFilter() $this->assertEquals([1, 3], iterator_to_array($result)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testMap() { $data = [0, 1, 2, 3, 4]; @@ -163,10 +137,6 @@ public function testMap() $this->assertEquals([1, 2, 3, 4, 5], iterator_to_array($result)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testFlatMap() { $data = ['Hello', 'World']; @@ -178,10 +148,6 @@ public function testFlatMap() ); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testPartition() { $data = [1, 2, 3, 4, 5]; @@ -189,30 +155,18 @@ public function testPartition() $this->assertEquals([[1, 2], [3, 4], [5]], iterator_to_array($result)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeObject() { $obj = new \stdClass(); $this->assertSame('object(stdClass)', Aws\describe_type($obj)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeArray() { $arr = [0, 1, 2]; $this->assertSame('array(3)', Aws\describe_type($arr)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeDoubleToFloat() { if (PHP_VERSION_ID >= 80500) { @@ -225,20 +179,12 @@ public function testDescribeDoubleToFloat() $this->assertSame('float(1.3)', Aws\describe_type($double)); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testDescribeType() { $this->assertSame('int(1)', Aws\describe_type(1)); $this->assertSame('string(4) "test"', Aws\describe_type("test")); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testGuzzleHttpHandler() { if (!class_exists('GuzzleHttp\Handler\StreamHandler')) { @@ -250,10 +196,6 @@ public function testGuzzleHttpHandler() ); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testSerializesHttpRequests() { $mock = new MockHandler([new Result([])]); @@ -284,19 +226,11 @@ public function testSerializesHttpRequests() $this->assertSame('123', (string) $request->getBody()); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testLoadsManifest() { $this->assertNotNull(Aws\manifest()); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testServiceManifest() { $manifest = Aws\manifest('s3'); @@ -312,10 +246,6 @@ public function testServiceManifest() $this->assertEquals($data, $manifest); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testAliasManifest() { $manifest = Aws\manifest('iotdataplane'); @@ -331,20 +261,12 @@ public function testAliasManifest() $this->assertEquals($data, $manifest); } - /** - - */ - #[CoversClass(recursive_dir_iterator()::class)] public function testInvalidManifest() { $this->expectException(\InvalidArgumentException::class); Aws\manifest('notarealservicename'); } - /** - - */ -#[CoversClass(recursive_dir_iterator()::class)] #[DataProvider('getHostnameTestCases')] public function testValidatesHostnames($hostname, $expected) { @@ -395,9 +317,7 @@ public static function getHostnameTestCases() /** * @param string $label * @param bool $expected - - */ -#[CoversClass(recursive_dir_iterator()::class)] + * */ #[DataProvider('getHostlabelTestCases')] public function testValidatesHostlabels($label, $expected) { @@ -430,10 +350,6 @@ public static function getHostlabelTestCases() ]; } - /** - - */ -#[CoversClass(recursive_dir_iterator()::class)] #[DataProvider('getIniFileTestCases')] public function testParsesIniFile($ini, $expected) { @@ -491,10 +407,6 @@ public static function getIniFileTestCases() ]; } - /** - - */ -#[CoversClass(recursive_dir_iterator()::class)] #[DataProvider('getIniFileServiceTestCases')] public function testParsesIniSectionsWithSubsections($ini, $expected) { diff --git a/tests/Glacier/TreeHashTest.php b/tests/Glacier/TreeHashTest.php index f8ad86a34a..6acb842891 100644 --- a/tests/Glacier/TreeHashTest.php +++ b/tests/Glacier/TreeHashTest.php @@ -5,15 +5,9 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; +#[CoversClass(TreeHash::class)] class TreeHashTest extends TestCase { - /** - - */ -#[CoversClass(Aws\Glacier\TreeHash::__construct::class)] -#[CoversClass(Aws\Glacier\TreeHash::update::class)] -#[CoversClass(Aws\Glacier\TreeHash::addChecksum::class)] - #[CoversClass(Aws\Glacier\TreeHash::complete::class)] public function testHashingIsHappeningCorrectly() { $chunks = [ @@ -39,10 +33,6 @@ public function testHashingIsHappeningCorrectly() $this->assertSame($expectedTreeHash, $hash->complete()); } - /** - - */ - #[CoversClass(Aws\Glacier\TreeHash::update::class)] public function testCannotUpdateAfterHashCalculation() { $this->expectException(\LogicException::class); @@ -53,10 +43,6 @@ public function testCannotUpdateAfterHashCalculation() $hash->update('bar'); } - /** - - */ - #[CoversClass(Aws\Glacier\TreeHash::addChecksum::class)] public function testCannotAddChecksumsAfterHashCalculation() { $this->expectException(\LogicException::class); @@ -67,10 +53,6 @@ public function testCannotAddChecksumsAfterHashCalculation() $hash->addChecksum('bar'); } - /** - - */ - #[CoversClass(Aws\Glacier\TreeHash::reset::class)] public function testCanResetHash() { $hash = new TreeHash('sha256'); @@ -81,10 +63,6 @@ public function testCanResetHash() $this->assertSame(hash('sha256', 'foo', true), $hash->complete()); } - /** - - */ - #[CoversClass(Aws\Glacier\TreeHash::complete::class)] public function testCanCalculateEmptyHash() { $hash = new TreeHash('sha256'); @@ -92,10 +70,6 @@ public function testCanCalculateEmptyHash() $this->assertSame(TreeHash::EMPTY_HASH, bin2hex($hash->complete())); } - /** - - */ - #[CoversClass(Aws\Glacier\TreeHash::complete::class)] public function testCanCalculateHashForSingleZero() { $data = "0"; diff --git a/tests/S3/Crypto/S3EncryptionClientV3Test.php b/tests/S3/Crypto/S3EncryptionClientV3Test.php index 81d9a96dee..040c2589e8 100644 --- a/tests/S3/Crypto/S3EncryptionClientV3Test.php +++ b/tests/S3/Crypto/S3EncryptionClientV3Test.php @@ -27,6 +27,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +#[CoversClass(S3EncryptionClientV3::class)] class S3EncryptionClientV3Test extends TestCase { use S3EncryptionClientTestingTrait; @@ -348,9 +349,7 @@ public function testV2MetadataStorageInObjectHeaders(): void * Test that by default, S3EC stores content metadata in S3 Object Metadata (headers) * This verifies the specification requirement that metadata is stored in object headers by default. * - - */ - #[CoversClass(\Aws\S3\Crypto\S3EncryptionClientV3::putObject::class)] + */ public function testV3MetadataStorageInObjectHeaders(): void { $s3 = new S3Client([ @@ -407,9 +406,7 @@ public function testV3MetadataStorageInObjectHeaders(): void * Test that the default metadata strategy does not write instruction files * This verifies the specification requirement that instruction files are not enabled by default. * - - */ - #[CoversClass(\Aws\S3\Crypto\S3EncryptionClientV3::putObject::class)] + */ public function testDefaultMetadataStrategyDoesNotWriteInstructionFile(): void { $requestCount = 0; From 13026898699158b9e735e1c6d4cef696fa2a4d5e Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Wed, 28 Jan 2026 10:05:14 -0800 Subject: [PATCH 07/19] chore: update phpunit version requirement --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 23e18cd327..8b18e8df1e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -71,7 +71,7 @@ jobs: composer update ${{ matrix.composer-options }} --no-interaction --prefer-dist --with-all-dependencies composer update psr/http-message guzzlehttp/psr7 guzzlehttp/guzzle --with-all-dependencies --no-interaction if [[ "${{ matrix.php-versions }}" == "8.4" ]]; then - composer update phpunit/phpunit:^9.6.18 --with-all-dependencies --no-interaction + composer update phpunit/phpunit:^10.0 --with-all-dependencies --no-interaction fi else composer update ${{ matrix.composer-options }} --no-interaction --prefer-dist --with-all-dependencies From 648bde14932f32d248ebabc8317e4098c04dc0a0 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Wed, 28 Jan 2026 12:11:34 -0800 Subject: [PATCH 08/19] chore: assert true on cover nothing test --- tests/S3/AmbiguousSuccessParserTest.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/S3/AmbiguousSuccessParserTest.php b/tests/S3/AmbiguousSuccessParserTest.php index 7603b892d4..6037047be0 100644 --- a/tests/S3/AmbiguousSuccessParserTest.php +++ b/tests/S3/AmbiguousSuccessParserTest.php @@ -8,6 +8,7 @@ use Aws\S3\AmbiguousSuccessParser; use Aws\S3\Exception\S3Exception; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\Attributes\CoversNothing; use Psr\Http\Message\ResponseInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; @@ -56,10 +57,10 @@ public function testConvertsAmbiguousSuccessesToExceptions($operation) /** * @param string $operation * @doesNotPerformAssertions - - */ + */ #[DataProvider('opsWithoutAmbiguousSuccessesProvider')] - public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations($operation) + #[CoversNothing] + public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations(string $operation) { $command = $this->getMockBuilder(CommandInterface::class)->getMock(); $command->expects($this->any()) @@ -72,6 +73,7 @@ public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations($operation) $instance = $this->instance; $instance($command, $response); + $this->assertTrue(true); } /** @@ -95,7 +97,7 @@ public function testThrowsConnectionErrorForEmptyBody($operation) $instance($command, $response); } - public static function opsWithAmbiguousSuccessesProvider() + public static function opsWithAmbiguousSuccessesProvider(): array { return [ ['CopyObject'], @@ -105,7 +107,7 @@ public static function opsWithAmbiguousSuccessesProvider() ]; } - public static function opsWithoutAmbiguousSuccessesProvider() + public static function opsWithoutAmbiguousSuccessesProvider(): array { $provider = ApiProvider::defaultProvider(); return array_map( From 664108c8e872ae241e2596d141f3db2c008ac039 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Wed, 28 Jan 2026 12:23:52 -0800 Subject: [PATCH 09/19] fix: missing breakline symbol --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 297a2d0fcb..af570a96ef 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ test: AWS_REGION= \ AWS_ENDPOINT_URL= \ AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \ - XDEBUG_MODE=coverage + XDEBUG_MODE=coverage \ vendor/bin/phpunit --testsuite=unit $(TEST) test-phar: package From 3141e832c9e31826d47e611deaa366b87f8af2e9 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Thu, 29 Jan 2026 13:51:06 -0800 Subject: [PATCH 10/19] chore: fixed multiple warnings and errors --- tests/AbstractConfigurationProviderTest.php | 3 - tests/Api/ApiProviderTest.php | 7 +- tests/Api/DateTimeResultTest.php | 3 - .../ErrorParser/JsonRpcErrorParserTest.php | 3 - .../ErrorParser/RestJsonErrorParserTest.php | 3 - tests/Api/ErrorParser/XmlErrorParserTest.php | 3 - tests/Api/ListShapeTest.php | 3 - tests/Api/MapShapeTest.php | 3 - tests/Api/OperationTest.php | 3 - tests/Api/Parser/ComplianceTest.php | 9 +- .../Api/Parser/Crc32ValidatingParserTest.php | 3 - .../DecodingEventStreamIteratorTest.php | 3 - tests/Api/Parser/EventParsingIteratorTest.php | 4 - .../Parser/Exception/ParserExceptionTest.php | 3 - tests/Api/Parser/JsonRpcParserTest.php | 29 +- ...eStreamDecodingEventStreamIteratorTest.php | 1 - tests/Api/Parser/RestJsonParserTest.php | 3 - tests/Api/Parser/RestXmlParserTest.php | 3 - tests/Api/Serializer/ComplianceTest.php | 9 +- tests/Api/Serializer/JsonBodyTest.php | 3 - .../Api/Serializer/JsonRpcSerializerTest.php | 3 - tests/Api/Serializer/QuerySerializerTest.php | 3 - .../Api/Serializer/RestJsonSerializerTest.php | 7 +- .../Api/Serializer/RestXmlSerializerTest.php | 3 - tests/Api/ServiceTest.php | 11 +- tests/Api/ShapeMapTest.php | 3 - tests/Api/ShapeTest.php | 3 - tests/Api/StructureShapeTest.php | 3 - tests/Api/TimestampShapeTest.php | 3 - tests/Api/ValidatorTest.php | 12 +- tests/Arn/AccessPointArnTest.php | 3 - tests/Arn/ArnParserTest.php | 3 - tests/Arn/ArnTest.php | 3 - tests/Arn/S3/AccessPointArnTest.php | 3 - tests/Arn/S3/OutpostsAccessPointArnTest.php | 3 - tests/Arn/S3/OutpostsBucketArnTest.php | 3 - tests/Auth/AuthSelectionMiddlewareTest.php | 1 - tests/AwsClientTest.php | 15 +- .../Build/Changelog/ChangelogBuilderTest.php | 12 +- tests/Build/Changelog/CurrentChangesTest.php | 8 +- tests/ClientResolverTest.php | 33 +- ...ApiCallAttemptMonitoringMiddlewareTest.php | 3 - .../ApiCallMonitoringMiddlewareTest.php | 3 - .../ConfigurationProviderTest.php | 5 +- .../ConfigurationTest.php | 3 - tests/CloudFront/CloudFrontClientTest.php | 9 +- tests/CloudFront/UrlSignerTest.php | 3 - .../CloudSearchDomainTest.php | 3 - tests/CloudTrail/LogFileIteratorTest.php | 3 - tests/CloudTrail/LogFileReaderTest.php | 3 - tests/CloudTrail/LogRecordIteratorTest.php | 3 - tests/CommandPoolTest.php | 3 - tests/CommandTest.php | 3 - .../AssumeRoleCredentialProviderTest.php | 3 - ...eWithWebIdentityCredentialProviderTest.php | 3 - tests/Credentials/CredentialProviderTest.php | 3 - tests/Credentials/CredentialsTest.php | 3 - tests/Credentials/CredentialsUtilsTest.php | 3 - .../Credentials/EcsCredentialProviderTest.php | 6 +- .../InstanceProfileProviderTest.php | 9 +- .../LoginCredentialProviderTest.php | 3 - tests/Crypto/AesEncryptingStreamTest.php | 3 +- tests/Crypto/AesEncryptionStreamTestTrait.php | 2 +- tests/Crypto/AlgorithmSuiteTest.php | 3 - .../EncryptionDecryptionTraitV3Test.php | 3 - tests/Crypto/KmsMaterialsProviderTest.php | 3 - tests/Crypto/KmsMaterialsProviderV2Test.php | 3 - tests/Crypto/KmsMaterialsProviderV3Test.php | 3 - tests/Crypto/MetadataEnvelopeTest.php | 3 - tests/DSQL/AuthTokenGeneratorTest.php | 3 - .../ConfigurationProviderTest.php | 5 +- tests/DefaultsMode/ConfigurationTest.php | 3 - tests/DocDb/DocDbClientTest.php | 3 - tests/DynamoDb/DynamoDbClientTest.php | 3 - .../DynamoDb/LockingSessionConnectionTest.php | 3 - .../SessionConnectionConfigTraitTest.php | 3 - tests/DynamoDb/SessionHandlerTest.php | 3 - .../StandardSessionConnectionTest.php | 3 - tests/DynamoDb/WriteRequestBatchTest.php | 3 - tests/Ec2/Ec2ClientTest.php | 3 - .../ElasticLoadBalancingV2ClientTest.php | 3 - tests/Endpoint/EndpointProviderTest.php | 3 - .../PartitionEndpointProviderTest.php | 3 - tests/Endpoint/PartitionTest.php | 6 +- .../Endpoint/PatternEndpointProviderTest.php | 3 - .../ConfigurationProviderTest.php | 5 +- .../ConfigurationTest.php | 3 - .../ConfigurationProviderTest.php | 5 +- .../UseFipsEndpoint/ConfigurationTest.php | 3 - .../ConfigurationProviderTest.php | 5 +- tests/EndpointDiscovery/ConfigurationTest.php | 3 - .../EndpointDiscoveryMiddlewareTest.php | 3 - tests/EndpointDiscovery/EndpointListTest.php | 3 - tests/EndpointParameterMiddlewareTest.php | 3 - tests/EndpointV2/EndpointProviderV2Test.php | 5 +- .../EndpointV2SerializerTraitTest.php | 3 - tests/EndpointV2/RuleCreatorTest.php | 3 - tests/EndpointV2/RulesetEndpointTest.php | 3 - tests/EndpointV2/RulesetParameterTest.php | 6 +- .../EndpointV2/RulesetStandardLibraryTest.php | 3 - tests/Exception/AwsExceptionTest.php | 3 - .../CouldNotCreateChecksumExceptionTest.php | 3 - .../EventStreamDataExceptionTest.php | 3 - .../MultipartUploadExceptionTest.php | 3 - tests/FunctionsTest.php | 4 +- tests/Glacier/GlacierClientTest.php | 3 - tests/Glacier/MultipartUploaderTest.php | 3 - tests/Handler/Guzzle/HandlerTest.php | 3 - tests/HandlerListTest.php | 26 +- tests/HasMonitoringEventsTraitTest.php | 3 - tests/HashingStreamTest.php | 3 - tests/HistoryTest.php | 3 - tests/IdempotencyTokenMiddlewareTest.php | 3 - .../S3ExpressIdentityProviderTest.php | 3 - tests/InputValidationMiddlewareTest.php | 3 - tests/JsonCompilerTest.php | 3 - tests/LexModelsV2/LexModelsV2ClientTest.php | 3 - tests/LruArrayCacheTest.php | 3 - .../MachineLearningClientTest.php | 3 - tests/MetricsBuilderTest.php | 8 +- tests/MiddlewareTest.php | 3 - tests/MockHandlerTest.php | 3 - tests/Multipart/AbstractUploaderTest.php | 3 - tests/Multipart/UploadStateTest.php | 3 - tests/Neptune/NeptuneClientTest.php | 3 - tests/PhpHashTest.php | 3 - tests/Polly/PollyClientTest.php | 3 - tests/PresignUrlMiddlewareTest.php | 4 - tests/QueryCompatibleInputMiddlewareTest.php | 3 - tests/Rds/AuthTokenGeneratorTest.php | 3 - tests/Rds/RdsClientTest.php | 3 - tests/ResultPaginatorTest.php | 6 +- tests/ResultTest.php | 3 - tests/Retry/ConfigurationProviderTest.php | 5 +- tests/Retry/ConfigurationTest.php | 3 - tests/Retry/QuotaManagerTest.php | 3 - tests/Retry/RateLimiterTest.php | 3 - tests/RetryMiddlewareTest.php | 3 - tests/RetryMiddlewareV2Test.php | 6 +- tests/Route53/RouteClient53Test.php | 3 - tests/S3/AmbiguousSuccessParserTest.php | 3 +- tests/S3/ApplyChecksumMiddlewareTest.php | 3 - tests/S3/BatchDeleteTest.php | 3 - tests/S3/BucketEndpointArnMiddlewareTest.php | 3 - tests/S3/BucketEndpointMiddlewareTest.php | 3 - .../S3/Crypto/HeadersMetadataStrategyTest.php | 3 - .../InstructionFileMetadataStrategyTest.php | 3 - .../DeleteMultipleObjectsExceptionTest.php | 3 - .../S3MultipartUploadExceptionTest.php | 3 - tests/S3/ExpiresParsingMiddlewareTest.php | 3 - tests/S3/GetBucketLocationParserTest.php | 3 - tests/S3/MultipartUploaderTest.php | 11 +- tests/S3/ObjectCopierTest.php | 2 +- tests/S3/Parser/S3ParserTest.php | 1 - tests/S3/PermanentRedirectMiddlewareTest.php | 6 +- tests/S3/PostObjectTest.php | 3 - tests/S3/PostObjectV4Test.php | 3 - tests/S3/PutObjectUrlMiddlewareTest.php | 4 +- .../ConfigurationProviderTest.php | 5 +- .../S3/RegionalEndpoint/ConfigurationTest.php | 3 - tests/S3/S3Transfer/MultipartUploaderTest.php | 4 - .../PartGetMultipartDownloaderTest.php | 2 - .../Progress/SingleProgressTrackerTest.php | 2 - .../RangeGetMultipartDownloaderTest.php | 2 - tests/S3/S3Transfer/S3TransferManagerTest.php | 8 - tests/S3/S3UriParserTest.php | 3 - tests/S3/SSECMiddlewareTest.php | 7 +- tests/S3/StreamWrapperPathStyleTest.php | 9 +- tests/S3/StreamWrapperTest.php | 9 +- tests/S3/StreamWrapperV2ExistenceTest.php | 3 +- tests/S3/TransferTest.php | 3 - .../ConfigurationProviderTest.php | 5 +- tests/S3/UseArnRegion/ConfigurationTest.php | 3 - .../S3/ValidateResponseChecksumParserTest.php | 3 - tests/S3Control/EndpointArnMiddlewareTest.php | 3 - tests/S3Control/S3ControlClientTest.php | 4 +- tests/SdkTest.php | 5 +- tests/Signature/AnonymousSignatureTest.php | 3 - tests/Signature/DpopSignatureTest.php | 3 - tests/Signature/S3ExpressSignatureTest.php | 3 - tests/Signature/S3SignatureV4Test.php | 3 - tests/Signature/SignatureProviderTest.php | 3 - tests/Signature/SignatureV4Test.php | 15 +- tests/Sqs/SqsClientTest.php | 6 +- tests/Ssm/SsmClientTest.php | 3 - tests/StreamRequestPayloadMiddlewareTest.php | 5 +- .../ConfigurationProviderTest.php | 2 +- .../RegionalEndpoints/ConfigurationTest.php | 3 - tests/Sts/StsClientTest.php | 5 +- tests/Token/BearerTokenAuthorizationTest.php | 8 +- tests/Token/BedrockTokenProviderTest.php | 482 ++++++++++++++++++ tests/Token/SsoTokenProviderTest.php | 218 +++++++- tests/Token/TokenProviderTest.php | 27 +- tests/Token/TokenTest.php | 64 ++- tests/Token/token_hack.php | 26 + tests/TraceMiddlewareTest.php | 3 - tests/UserAgentMiddlewareTest.php | 2 - tests/WaiterTest.php | 9 +- tests/WrappedHttpHandlerTest.php | 3 - 199 files changed, 967 insertions(+), 681 deletions(-) diff --git a/tests/AbstractConfigurationProviderTest.php b/tests/AbstractConfigurationProviderTest.php index 3c33baf92b..d130c6c02b 100644 --- a/tests/AbstractConfigurationProviderTest.php +++ b/tests/AbstractConfigurationProviderTest.php @@ -10,9 +10,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\AbstractConfigurationProvider::class)] class AbstractConfigurationProviderTest extends TestCase { diff --git a/tests/Api/ApiProviderTest.php b/tests/Api/ApiProviderTest.php index f0efa27c64..1737c99c7e 100644 --- a/tests/Api/ApiProviderTest.php +++ b/tests/Api/ApiProviderTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ApiProvider::class)] class ApiProviderTest extends TestCase { @@ -27,7 +24,9 @@ private function getTestApiProvider($useManifest = true) public function testCanResolveProvider() { - $p = function ($a, $b, $c) {return [];}; + $p = function ($a, $b, $c) {return []; + + $this->assertTrue(true);}; $result = ['metadata'=> ['serviceIdentifier' => 's']]; $this->assertEquals($result, ApiProvider::resolve($p, 't', 's', 'v')); diff --git a/tests/Api/DateTimeResultTest.php b/tests/Api/DateTimeResultTest.php index 9d59661944..7bca1a54ce 100644 --- a/tests/Api/DateTimeResultTest.php +++ b/tests/Api/DateTimeResultTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\DateTimeResult::class)] class DateTimeResultTest extends TestCase { diff --git a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php index 4815d16462..91417642ec 100644 --- a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php +++ b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\ErrorParser\JsonRpcErrorParser::class)] #[CoversClass(\Aws\Api\ErrorParser\JsonParserTrait::class)] class JsonRpcErrorParserTest extends TestCase diff --git a/tests/Api/ErrorParser/RestJsonErrorParserTest.php b/tests/Api/ErrorParser/RestJsonErrorParserTest.php index 86c8d41361..a7616b9329 100644 --- a/tests/Api/ErrorParser/RestJsonErrorParserTest.php +++ b/tests/Api/ErrorParser/RestJsonErrorParserTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\ErrorParser\RestJsonErrorParser::class)] #[CoversClass(\Aws\Api\ErrorParser\JsonParserTrait::class)] class RestJsonErrorParserTest extends TestCase diff --git a/tests/Api/ErrorParser/XmlErrorParserTest.php b/tests/Api/ErrorParser/XmlErrorParserTest.php index b6f679e7ce..90c3a9bc33 100644 --- a/tests/Api/ErrorParser/XmlErrorParserTest.php +++ b/tests/Api/ErrorParser/XmlErrorParserTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(XmlErrorParser::class)] class XmlErrorParserTest extends TestCase { diff --git a/tests/Api/ListShapeTest.php b/tests/Api/ListShapeTest.php index 2e1f0e4269..b4bf02df95 100644 --- a/tests/Api/ListShapeTest.php +++ b/tests/Api/ListShapeTest.php @@ -7,9 +7,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\ListShape::class)] class ListShapeTest extends TestCase { diff --git a/tests/Api/MapShapeTest.php b/tests/Api/MapShapeTest.php index 18274fba9d..b4699ed12b 100644 --- a/tests/Api/MapShapeTest.php +++ b/tests/Api/MapShapeTest.php @@ -7,9 +7,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\MapShape::class)] class MapShapeTest extends TestCase { diff --git a/tests/Api/OperationTest.php b/tests/Api/OperationTest.php index 8d6720a4d7..f55f3ed79c 100644 --- a/tests/Api/OperationTest.php +++ b/tests/Api/OperationTest.php @@ -7,9 +7,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\Operation::class)] class OperationTest extends TestCase { diff --git a/tests/Api/Parser/ComplianceTest.php b/tests/Api/Parser/ComplianceTest.php index 7d51c7ab0f..6a766c2653 100644 --- a/tests/Api/Parser/ComplianceTest.php +++ b/tests/Api/Parser/ComplianceTest.php @@ -14,9 +14,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\Parser\AbstractParser::class)] #[CoversClass(\Aws\Api\Parser\AbstractRestParser::class)] #[CoversClass(\Aws\Api\Parser\JsonRpcParser::class)] @@ -50,8 +47,7 @@ class ComplianceTest extends TestCase 'legacy query Flattened list with location name' => true ]; - /** @doesNotPerformAssertions */ - public static function testCaseProvider(): \Generator + public static function caseProvider(): \Generator { $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( @@ -119,7 +115,7 @@ public static function testCaseProvider(): \Generator * @param string|null $errorMessage */ - #[DataProvider('testCaseProvider')] + #[DataProvider('caseProvider')] public function testPassesComplianceTest( string $about, Service $service, @@ -155,6 +151,7 @@ public function testPassesComplianceTest( $this->fixTimestamps($result, $service->getOperation($name)->getOutput()); $this->assertEquals($expectedResult, $result); + $this->assertTrue(true); } private function fixTimestamps(mixed &$data, Shape $shape): void diff --git a/tests/Api/Parser/Crc32ValidatingParserTest.php b/tests/Api/Parser/Crc32ValidatingParserTest.php index f40321c75f..676a54a1ef 100644 --- a/tests/Api/Parser/Crc32ValidatingParserTest.php +++ b/tests/Api/Parser/Crc32ValidatingParserTest.php @@ -12,9 +12,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Crc32ValidatingParser::class)] class Crc32ValidatingParserTest extends TestCase { diff --git a/tests/Api/Parser/DecodingEventStreamIteratorTest.php b/tests/Api/Parser/DecodingEventStreamIteratorTest.php index e7fae0ff09..a4c03b61c9 100644 --- a/tests/Api/Parser/DecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/DecodingEventStreamIteratorTest.php @@ -10,9 +10,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(DecodingEventStreamIterator::class)] class DecodingEventStreamIteratorTest extends TestCase { diff --git a/tests/Api/Parser/EventParsingIteratorTest.php b/tests/Api/Parser/EventParsingIteratorTest.php index e5f3065fbf..bed3244f75 100644 --- a/tests/Api/Parser/EventParsingIteratorTest.php +++ b/tests/Api/Parser/EventParsingIteratorTest.php @@ -18,9 +18,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(EventParsingIterator::class)] class EventParsingIteratorTest extends TestCase { @@ -381,7 +378,6 @@ public function testHandleInitialResponse() * * @return void * - * */ #[DataProvider('handleEventWithExceptionsProvider')] diff --git a/tests/Api/Parser/Exception/ParserExceptionTest.php b/tests/Api/Parser/Exception/ParserExceptionTest.php index 7270bbe53e..d8bbaf6785 100644 --- a/tests/Api/Parser/Exception/ParserExceptionTest.php +++ b/tests/Api/Parser/Exception/ParserExceptionTest.php @@ -5,9 +5,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\Parser\Exception\ParserException::class)] class ParserExceptionTest extends TestCase { diff --git a/tests/Api/Parser/JsonRpcParserTest.php b/tests/Api/Parser/JsonRpcParserTest.php index d966b59258..361fe76103 100644 --- a/tests/Api/Parser/JsonRpcParserTest.php +++ b/tests/Api/Parser/JsonRpcParserTest.php @@ -17,12 +17,12 @@ class JsonRpcParserTest extends TestCase { - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanHandleNullResponses() { $operation = $this->getMockBuilder(Operation::class) ->disableOriginalConstructor() - ->setMethods(['getOutput']) + ->onlyMethods(['getOutput']) ->getMock(); $operation->expects($this->any()) ->method('getOutput') @@ -30,13 +30,13 @@ public function testCanHandleNullResponses() ->willReturn( $this->getMockBuilder(Shape::class) ->disableOriginalConstructor() - ->setMethods([]) + ->onlyMethods([]) ->getMock() ); $service = $this->getMockBuilder(Service::class) ->disableOriginalConstructor() - ->setMethods(['getOperation']) + ->onlyMethods(['getOperation']) ->getMock(); $service->expects($this->any()) ->method('getOperation') @@ -45,7 +45,7 @@ public function testCanHandleNullResponses() $parser = $this->getMockBuilder(JsonParser::class) ->disableOriginalConstructor() - ->setMethods(['parse']) + ->onlyMethods(['parse']) ->getMock(); $parser->expects($this->any()) ->method('parse') @@ -57,13 +57,14 @@ public function testCanHandleNullResponses() $this->getMockBuilder(CommandInterface::class)->getMock(), new Response(200, [], json_encode(null)) ); + $this->assertTrue(true); } public function testCanHandleEmptyResponses() { $operation = $this->getMockBuilder(Operation::class) ->disableOriginalConstructor() - ->setMethods(['offsetGet']) + ->onlyMethods(['offsetGet']) ->getMock(); $operation->expects($this->atLeastOnce()) ->method('offsetGet') @@ -72,7 +73,7 @@ public function testCanHandleEmptyResponses() $service = $this->getMockBuilder(Service::class) ->disableOriginalConstructor() - ->setMethods(['getOperation']) + ->onlyMethods(['getOperation']) ->getMock(); $service->expects($this->any()) ->method('getOperation') @@ -81,7 +82,7 @@ public function testCanHandleEmptyResponses() $parser = $this->getMockBuilder(JsonParser::class) ->disableOriginalConstructor() - ->setMethods(['parse']) + ->onlyMethods(['parse']) ->getMock(); $parser->expects($this->never()) ->method('parse'); @@ -97,11 +98,11 @@ public function testCanHandleNonStreamingResponses() { $service = $this->getMockBuilder(Service::class) -> disableOriginalConstructor() - -> setMethods(['getOperation']) + -> onlyMethods(['getOperation']) -> getMock(); $operation = $this->getMockBuilder(Operation::class) -> disableOriginalConstructor() - -> setMethods(['getOutput']) + -> onlyMethods(['getOutput']) -> getMock(); $outputShape = new StructureShape([ 'type' => 'structure', @@ -129,7 +130,7 @@ public function testCanHandleNonStreamingResponses() $jsonRPCParser = new JsonRpcParser($service); $command = $this->getMockBuilder(Command::class) -> disableOriginalConstructor() - -> setMethods(['getName']) + -> onlyMethods(['getName']) -> getMock(); $command->method('getName') ->willReturn('TestCommand'); @@ -155,11 +156,11 @@ public function testCanHandleStreamingResponses() { $service = $this->getMockBuilder(Service::class) -> disableOriginalConstructor() - -> setMethods(['getOperation']) + -> onlyMethods(['getOperation']) -> getMock(); $operation = $this->getMockBuilder(Operation::class) -> disableOriginalConstructor() - -> setMethods(['getOutput']) + -> onlyMethods(['getOutput']) -> getMock(); $outputShape = new StructureShape([ 'type' => 'structure', @@ -198,7 +199,7 @@ public function testCanHandleStreamingResponses() $jsonRPCParser = new JsonRpcParser($service); $command = $this->getMockBuilder(Command::class) -> disableOriginalConstructor() - -> setMethods(['getName']) + -> onlyMethods(['getName']) -> getMock(); $command->method('getName') ->willReturn('TestCommand'); diff --git a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php index 3bdc02b953..7c2b9a6953 100644 --- a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php @@ -78,7 +78,6 @@ public function testValidReturnsTrueOnEOF() * @param string $eventName * @param array $expected * - * * @return void */ diff --git a/tests/Api/Parser/RestJsonParserTest.php b/tests/Api/Parser/RestJsonParserTest.php index 9661847523..f7947a4e7c 100644 --- a/tests/Api/Parser/RestJsonParserTest.php +++ b/tests/Api/Parser/RestJsonParserTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(RestJsonParser::class)] class RestJsonParserTest extends TestCase { diff --git a/tests/Api/Parser/RestXmlParserTest.php b/tests/Api/Parser/RestXmlParserTest.php index 6789109ae4..302a66dfa5 100644 --- a/tests/Api/Parser/RestXmlParserTest.php +++ b/tests/Api/Parser/RestXmlParserTest.php @@ -9,9 +9,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(RestXmlParser::class)] class RestXmlParserTest extends TestCase { diff --git a/tests/Api/Serializer/ComplianceTest.php b/tests/Api/Serializer/ComplianceTest.php index e666423730..0f706d63a1 100644 --- a/tests/Api/Serializer/ComplianceTest.php +++ b/tests/Api/Serializer/ComplianceTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\Serializer\QuerySerializer::class)] #[CoversClass(\Aws\Api\Serializer\JsonRpcSerializer::class)] #[CoversClass(\Aws\Api\Serializer\RestSerializer::class)] @@ -42,8 +39,7 @@ class ComplianceTest extends TestCase 'HttpPayloadWithMemberXmlName' => true ]; - /** @doesNotPerformAssertions */ - public static function testCaseProvider(): \Generator + public static function caseProvider(): \Generator { $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( @@ -87,7 +83,7 @@ function () { return []; } /** */ - #[DataProvider('testCaseProvider')] + #[DataProvider('caseProvider')] public function testPassesComplianceTest( Service $service, $name, @@ -186,6 +182,7 @@ public function testPassesComplianceTest( $this->assertNotTrue($request->hasHeader($header)); } } + $this->assertTrue(true); } private function assertXmlEquals( diff --git a/tests/Api/Serializer/JsonBodyTest.php b/tests/Api/Serializer/JsonBodyTest.php index f2c6adf6d3..21a44b11db 100644 --- a/tests/Api/Serializer/JsonBodyTest.php +++ b/tests/Api/Serializer/JsonBodyTest.php @@ -10,9 +10,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(JsonBody::class)] class JsonBodyTest extends TestCase { diff --git a/tests/Api/Serializer/JsonRpcSerializerTest.php b/tests/Api/Serializer/JsonRpcSerializerTest.php index f2a593b571..373f835a39 100644 --- a/tests/Api/Serializer/JsonRpcSerializerTest.php +++ b/tests/Api/Serializer/JsonRpcSerializerTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(JsonRpcSerializer::class)] class JsonRpcSerializerTest extends TestCase { diff --git a/tests/Api/Serializer/QuerySerializerTest.php b/tests/Api/Serializer/QuerySerializerTest.php index 3fe4de91c6..176355d5ee 100644 --- a/tests/Api/Serializer/QuerySerializerTest.php +++ b/tests/Api/Serializer/QuerySerializerTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(QuerySerializer::class)] class QuerySerializerTest extends TestCase { diff --git a/tests/Api/Serializer/RestJsonSerializerTest.php b/tests/Api/Serializer/RestJsonSerializerTest.php index faf2bc38d5..6ea3eb6968 100644 --- a/tests/Api/Serializer/RestJsonSerializerTest.php +++ b/tests/Api/Serializer/RestJsonSerializerTest.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(RestJsonSerializer::class)] class RestJsonSerializerTest extends TestCase { @@ -257,7 +254,9 @@ public function testPreparesRequestsWithEndpointWithRequestUriAndPath(): void public function testPreparesRequestsWithJsonValueTraitString(): void { - $jsonValueArgs = '{"a":"b"}'; + $jsonValueArgs = '{"a":"b" + + $this->assertTrue(true);}'; $request = $this->getRequest('foobar', ['baz' => $jsonValueArgs]); $this->assertSame('IntcImFcIjpcImJcIn0i', $request->getHeaderLine('baz')); $this->assertSame('POST', $request->getMethod()); diff --git a/tests/Api/Serializer/RestXmlSerializerTest.php b/tests/Api/Serializer/RestXmlSerializerTest.php index c01c9478bf..5c899904f7 100644 --- a/tests/Api/Serializer/RestXmlSerializerTest.php +++ b/tests/Api/Serializer/RestXmlSerializerTest.php @@ -13,9 +13,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(RestXmlSerializer::class)] class RestXmlSerializerTest extends TestCase { diff --git a/tests/Api/ServiceTest.php b/tests/Api/ServiceTest.php index 11642c28a9..cd271bc5fc 100644 --- a/tests/Api/ServiceTest.php +++ b/tests/Api/ServiceTest.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\Service::class)] class ServiceTest extends TestCase { @@ -26,7 +23,9 @@ class ServiceTest extends TestCase public function testSetsDefaultValues() { - $s = new Service([], function () { return []; }); + $s = new Service([], function () { return []; + + $this->assertTrue(true);}); $this->assertSame([], $s['operations']); $this->assertSame([], $s['shapes']); } @@ -70,7 +69,9 @@ function () { return []; } public function testReturnsMetadata() { - $s = new Service([], function () { return []; }); + $s = new Service([], function () { return []; + + $this->assertTrue(true);}); $this->assertIsArray($s->getMetadata()); $s['metadata'] = [ 'serviceFullName' => 'foo', diff --git a/tests/Api/ShapeMapTest.php b/tests/Api/ShapeMapTest.php index 74d9e94428..420f5ebb0a 100644 --- a/tests/Api/ShapeMapTest.php +++ b/tests/Api/ShapeMapTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\ShapeMap::class)] class ShapeMapTest extends TestCase { diff --git a/tests/Api/ShapeTest.php b/tests/Api/ShapeTest.php index cc08469bb3..1a9685d6e4 100644 --- a/tests/Api/ShapeTest.php +++ b/tests/Api/ShapeTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Shape::class)] #[CoversClass(Shape::class)] class ShapeTest extends TestCase diff --git a/tests/Api/StructureShapeTest.php b/tests/Api/StructureShapeTest.php index e446897e82..8ec97bbbf4 100644 --- a/tests/Api/StructureShapeTest.php +++ b/tests/Api/StructureShapeTest.php @@ -7,9 +7,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\StructureShape::class)] class StructureShapeTest extends TestCase { diff --git a/tests/Api/TimestampShapeTest.php b/tests/Api/TimestampShapeTest.php index 34a4ac1239..66e872b3c6 100644 --- a/tests/Api/TimestampShapeTest.php +++ b/tests/Api/TimestampShapeTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Api\TimestampShape::class)] class TimestampShapeTest extends TestCase { diff --git a/tests/Api/ValidatorTest.php b/tests/Api/ValidatorTest.php index a114460d65..d0a25ba1f4 100644 --- a/tests/Api/ValidatorTest.php +++ b/tests/Api/ValidatorTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Validator::class)] class ValidatorTest extends TestCase { @@ -685,7 +682,7 @@ public function testValidatesMinByDefault() $validator->validate('Foo', $shape, ['foo' => '']); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testDoesNotValidateMaxByDefault() { $shape = Shape::create( @@ -697,9 +694,10 @@ public function testDoesNotValidateMaxByDefault() ); $validator = new Validator(); $validator->validate('Foo', $shape, ['foo' => '1234567890']); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testDoesNotValidatePatternsByDefault() { $validator = new Validator(); @@ -716,9 +714,10 @@ public function testDoesNotValidatePatternsByDefault() new ShapeMap([]) ); $validator->validate('Foo', $shape, ['caps' => 'abc']); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanDisableRequiredTrait() { $validator = new Validator(['required' => false]); @@ -731,5 +730,6 @@ public function testCanDisableRequiredTrait() new ShapeMap([]) ); $validator->validate('Foo', $shape, []); + $this->assertTrue(true); } } diff --git a/tests/Arn/AccessPointArnTest.php b/tests/Arn/AccessPointArnTest.php index 8af180fd2e..c53f7b070d 100644 --- a/tests/Arn/AccessPointArnTest.php +++ b/tests/Arn/AccessPointArnTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Arn\AccessPointArn::class)] class AccessPointArnTest extends TestCase { diff --git a/tests/Arn/ArnParserTest.php b/tests/Arn/ArnParserTest.php index 6f5cf127d0..baaf02bb37 100644 --- a/tests/Arn/ArnParserTest.php +++ b/tests/Arn/ArnParserTest.php @@ -12,9 +12,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Arn\ArnParser::class)] class ArnParserTest extends TestCase { diff --git a/tests/Arn/ArnTest.php b/tests/Arn/ArnTest.php index c7c9fd2368..6ed7b37eb7 100644 --- a/tests/Arn/ArnTest.php +++ b/tests/Arn/ArnTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Arn\Arn::class)] class ArnTest extends TestCase { diff --git a/tests/Arn/S3/AccessPointArnTest.php b/tests/Arn/S3/AccessPointArnTest.php index 666594eee6..c10ee62491 100644 --- a/tests/Arn/S3/AccessPointArnTest.php +++ b/tests/Arn/S3/AccessPointArnTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Arn\S3\AccessPointArn::class)] class AccessPointArnTest extends TestCase { diff --git a/tests/Arn/S3/OutpostsAccessPointArnTest.php b/tests/Arn/S3/OutpostsAccessPointArnTest.php index 0aa2d80d16..87c4c7c817 100644 --- a/tests/Arn/S3/OutpostsAccessPointArnTest.php +++ b/tests/Arn/S3/OutpostsAccessPointArnTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Arn\S3\OutpostsAccessPointArn::class)] class OutpostsAccessPointArnTest extends TestCase { diff --git a/tests/Arn/S3/OutpostsBucketArnTest.php b/tests/Arn/S3/OutpostsBucketArnTest.php index bbba2980d5..be4b8ba7dd 100644 --- a/tests/Arn/S3/OutpostsBucketArnTest.php +++ b/tests/Arn/S3/OutpostsBucketArnTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Arn\S3\OutpostsBucketArn::class)] class OutpostsBucketArnTest extends TestCase { diff --git a/tests/Auth/AuthSelectionMiddlewareTest.php b/tests/Auth/AuthSelectionMiddlewareTest.php index 616bc91d08..82e4b8cdda 100644 --- a/tests/Auth/AuthSelectionMiddlewareTest.php +++ b/tests/Auth/AuthSelectionMiddlewareTest.php @@ -317,7 +317,6 @@ function () { return []; } /** * Test auth select is done based on user's provided auth schemes. * - * * @param array $supportedAuthSchemes * @param array|null $serviceAuthSchemes * @param array|null $operationAuthSchemes diff --git a/tests/AwsClientTest.php b/tests/AwsClientTest.php index 9076eed1ee..2754402f3c 100644 --- a/tests/AwsClientTest.php +++ b/tests/AwsClientTest.php @@ -30,9 +30,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(AwsClient::class)] class AwsClientTest extends TestCase { @@ -283,22 +280,24 @@ public function testSignsRequestsUsingSigner() $this->assertStringContainsString('AWS4-HMAC-SHA256', $str); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testAllowsFactoryMethodForBc() { Ec2Client::factory([ 'region' => 'us-west-2', 'version' => 'latest' ]); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanInstantiateAliasedClients() { new SesClient([ 'region' => 'us-west-2', 'version' => 'latest' ]); + $this->assertTrue(true); } public function testCanGetSignatureProvider() @@ -620,7 +619,8 @@ public function testIsUseGlobalEndpoint() { ); } - /** @dataProvider configuredEndpointUrlProvider */ + #[DataProvider('configuredEndpointUrlProvider')] + public function testAppliesConfiguredEndpointUrl($ini, $env, $expected) { $dir = sys_get_temp_dir() . '/.aws'; @@ -651,7 +651,8 @@ public function testAppliesConfiguredEndpointUrl($ini, $env, $expected) } } - /** @dataProvider configuredEndpointUrlProvider */ + #[DataProvider('configuredEndpointUrlProvider')] + public function testDoesNotApplyConfiguredEndpointWhenConfiguredUrlsIgnored($ini, $env) { putenv('AWS_IGNORE_CONFIGURED_ENDPOINT_URLS=true'); diff --git a/tests/Build/Changelog/ChangelogBuilderTest.php b/tests/Build/Changelog/ChangelogBuilderTest.php index 79b3dc0778..f87f0ab8c5 100644 --- a/tests/Build/Changelog/ChangelogBuilderTest.php +++ b/tests/Build/Changelog/ChangelogBuilderTest.php @@ -5,9 +5,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ChangelogBuilder::class)] class ChangelogBuilderTest extends TestCase { @@ -50,13 +47,8 @@ public function testBuildChangelogInvalidChangelog() public function testBuildChangelogInvalidPathChangelog() { - if (PHP_VERSION_ID >= 80300) { - $this->expectException(\PHPUnit\Framework\Error\Deprecated::class); - } else { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid tag value'); - } - + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid tag value'); $params = []; $params['base_dir'] = self::$invalidResourceDir; $params['release_notes_output_dir'] = sys_get_temp_dir() . "/"; diff --git a/tests/Build/Changelog/CurrentChangesTest.php b/tests/Build/Changelog/CurrentChangesTest.php index 4fda017f65..df06aed3eb 100644 --- a/tests/Build/Changelog/CurrentChangesTest.php +++ b/tests/Build/Changelog/CurrentChangesTest.php @@ -12,7 +12,7 @@ private function getNameFromFilePath($filePath) return end($portions); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testVerifyDotChangesFolder() { $files = glob(__DIR__ . '/../../../.changes/*'); @@ -29,12 +29,14 @@ public function testVerifyDotChangesFolder() $this->fail('Files in `.changes` must be valid JSON.'); } } + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testVerifyNextreleaseContents() { if (!is_dir(__DIR__ . '/../../../.changes/nextrelease/')) { + $this->assertTrue(true); return; } @@ -70,5 +72,7 @@ public function testVerifyNextreleaseContents() . $name . '` changelog document.'); } } + + $this->assertTrue(true); } } diff --git a/tests/ClientResolverTest.php b/tests/ClientResolverTest.php index 51f2db1c43..64a350b719 100644 --- a/tests/ClientResolverTest.php +++ b/tests/ClientResolverTest.php @@ -25,9 +25,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ClientResolver::class)] class ClientResolverTest extends TestCase { @@ -41,7 +38,7 @@ public function testEnsuresRequiredArgumentsAreProvided() $r->resolve([], new HandlerList()); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testAddsValidationSubscriber() { $c = new DynamoDbClient([ @@ -55,9 +52,10 @@ public function testAddsValidationSubscriber() $this->fail('Did not validate'); } catch (\InvalidArgumentException $e) { } + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanDisableValidation() { $c = new DynamoDbClient([ @@ -69,9 +67,10 @@ public function testCanDisableValidation() $handler = \Aws\constantly(new Result([])); $command->getHandlerList()->setHandler($handler); $c->execute($command); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanDisableSpecificValidationConstraints() { $c = new DynamoDbClient([ @@ -87,6 +86,7 @@ public function testCanDisableSpecificValidationConstraints() $handler = \Aws\constantly(new Result([])); $command->getHandlerList()->setHandler($handler); $c->execute($command); + $this->assertTrue(true); } public function testAppliesLegacyDefaults() @@ -317,7 +317,7 @@ public function testCreatesFromArray() $this->assertSame($exp, $creds->getExpiration()); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanDisableRetries() { $r = new ClientResolver(ClientResolver::getDefaultArguments()); @@ -327,9 +327,10 @@ public function testCanDisableRetries() 'version' => 'latest', 'retries' => 0, ], new HandlerList()); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanEnableRetries() { $r = new ClientResolver(ClientResolver::getDefaultArguments()); @@ -339,9 +340,10 @@ public function testCanEnableRetries() 'version' => 'latest', 'retries' => 2, ], new HandlerList()); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanEnableRetriesStandardMode() { $r = new ClientResolver(ClientResolver::getDefaultArguments()); @@ -354,9 +356,10 @@ public function testCanEnableRetriesStandardMode() 'max_attempts' => 10, ] ], new HandlerList()); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanEnableRetriesAdaptivedMode() { $r = new ClientResolver(ClientResolver::getDefaultArguments()); @@ -369,6 +372,7 @@ public function testCanEnableRetriesAdaptivedMode() 'max_attempts' => 10, ] ], new HandlerList()); + $this->assertTrue(true); } public function testCanCreateNullCredentials() @@ -701,7 +705,7 @@ public static function s3EndpointCases() ]; } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testAddsLoggerWithDebugSettings() { $r = new ClientResolver(ClientResolver::getDefaultArguments()); @@ -712,9 +716,10 @@ public function testAddsLoggerWithDebugSettings() 'endpoint' => 'http://us-east-1.foo.amazonaws.com', 'version' => 'latest' ], new HandlerList()); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testAddsDebugListener() { $em = new HandlerList(); @@ -726,6 +731,7 @@ public function testAddsDebugListener() 'endpoint' => 'http://us-east-1.foo.amazonaws.com', 'version' => 'latest' ], $em); + $this->assertTrue(true); } public function canSetDebugToFalse() @@ -763,7 +769,7 @@ public function testCanAddConfigOptions() $this->assertTrue($c->getConfig('bucket_endpoint')); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testSkipsNonRequiredKeys() { $r = new ClientResolver([ @@ -773,6 +779,7 @@ public function testSkipsNonRequiredKeys() ] ]); $r->resolve([], new HandlerList()); + $this->assertTrue(true); } public function testAppliesLatestAsDefaultVersionWithoutSuppliedVersion() diff --git a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php index 23395435b5..50e5cea0f1 100644 --- a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php +++ b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ApiCallAttemptMonitoringMiddleware::class)] #[CoversClass(ApiCallAttemptMonitoringMiddleware::class)] class ApiCallAttemptMonitoringMiddlewareTest extends TestCase diff --git a/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php b/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php index d9cf9363c7..73949f6538 100644 --- a/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php +++ b/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php @@ -12,9 +12,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ApiCallMonitoringMiddleware::class)] #[CoversClass(ApiCallMonitoringMiddleware::class)] class ApiCallMonitoringMiddlewareTest extends TestCase diff --git a/tests/ClientSideMonitoring/ConfigurationProviderTest.php b/tests/ClientSideMonitoring/ConfigurationProviderTest.php index 4356bad747..a5be323735 100644 --- a/tests/ClientSideMonitoring/ConfigurationProviderTest.php +++ b/tests/ClientSideMonitoring/ConfigurationProviderTest.php @@ -14,9 +14,6 @@ use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -428,7 +425,7 @@ public function testCreatesFromCache() { $expected = new Configuration(true, '123.4.5.6', 555, 'FooApp'); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/ClientSideMonitoring/ConfigurationTest.php b/tests/ClientSideMonitoring/ConfigurationTest.php index 2dc3736318..c54ab2d68a 100644 --- a/tests/ClientSideMonitoring/ConfigurationTest.php +++ b/tests/ClientSideMonitoring/ConfigurationTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\ClientSideMonitoring\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/CloudFront/CloudFrontClientTest.php b/tests/CloudFront/CloudFrontClientTest.php index 5c8e74298a..10c6b4fff7 100644 --- a/tests/CloudFront/CloudFrontClientTest.php +++ b/tests/CloudFront/CloudFrontClientTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(CloudFrontClient::class)] class CloudFrontClientTest extends TestCase { @@ -31,7 +28,7 @@ public function testEnsuresKeysArePassed() $c->getSignedUrl([]); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCreatesSignedUrl() { $c = new CloudFrontClient([ @@ -45,9 +42,10 @@ public function testCreatesSignedUrl() 'url' => 'https://foo.bar.com', 'expires' => strtotime('+10 minutes'), ]); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCreatesSignedCookie() { $c = new CloudFrontClient([ @@ -61,5 +59,6 @@ public function testCreatesSignedCookie() 'url' => 'https://foo.bar.com', 'expires' => strtotime('+10 minutes'), ]); + $this->assertTrue(true); } } diff --git a/tests/CloudFront/UrlSignerTest.php b/tests/CloudFront/UrlSignerTest.php index c8783378c2..cb8cf0daf9 100644 --- a/tests/CloudFront/UrlSignerTest.php +++ b/tests/CloudFront/UrlSignerTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(UrlSigner::class)] class UrlSignerTest extends TestCase { diff --git a/tests/CloudSearchDomain/CloudSearchDomainTest.php b/tests/CloudSearchDomain/CloudSearchDomainTest.php index 1051a6de3f..37593f82e8 100644 --- a/tests/CloudSearchDomain/CloudSearchDomainTest.php +++ b/tests/CloudSearchDomain/CloudSearchDomainTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(CloudSearchDomainClient::class)] class CloudSearchDomainTest extends TestCase { diff --git a/tests/CloudTrail/LogFileIteratorTest.php b/tests/CloudTrail/LogFileIteratorTest.php index f9612321f0..5805abfcef 100644 --- a/tests/CloudTrail/LogFileIteratorTest.php +++ b/tests/CloudTrail/LogFileIteratorTest.php @@ -11,9 +11,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(LogFileIterator::class)] class LogFileIteratorTest extends TestCase { diff --git a/tests/CloudTrail/LogFileReaderTest.php b/tests/CloudTrail/LogFileReaderTest.php index 43ad3d4185..a845c81fcf 100644 --- a/tests/CloudTrail/LogFileReaderTest.php +++ b/tests/CloudTrail/LogFileReaderTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(LogFileReader::class)] class LogFileReaderTest extends TestCase { diff --git a/tests/CloudTrail/LogRecordIteratorTest.php b/tests/CloudTrail/LogRecordIteratorTest.php index 8ca9ecd6d7..58cafd3321 100644 --- a/tests/CloudTrail/LogRecordIteratorTest.php +++ b/tests/CloudTrail/LogRecordIteratorTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(LogRecordIterator::class)] class LogRecordIteratorTest extends TestCase { diff --git a/tests/CommandPoolTest.php b/tests/CommandPoolTest.php index fee7724dc7..0ddae6e12d 100644 --- a/tests/CommandPoolTest.php +++ b/tests/CommandPoolTest.php @@ -8,9 +8,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(CommandPool::class)] class CommandPoolTest extends TestCase { diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 2ac169d445..1ebe437498 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -7,9 +7,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Command::class)] #[CoversClass(Command::class)] class CommandTest extends TestCase diff --git a/tests/Credentials/AssumeRoleCredentialProviderTest.php b/tests/Credentials/AssumeRoleCredentialProviderTest.php index 580c5261fc..ae14776982 100644 --- a/tests/Credentials/AssumeRoleCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleCredentialProviderTest.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Credentials\AssumeRoleCredentialProvider::class)] class AssumeRoleCredentialProviderTest extends TestCase { diff --git a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php index 0a179a3c1e..1de2937125 100644 --- a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php @@ -17,9 +17,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(AssumeRoleWithWebIdentityCredentialProvider::class)] class AssumeRoleWithWebIdentityCredentialProviderTest extends TestCase { diff --git a/tests/Credentials/CredentialProviderTest.php b/tests/Credentials/CredentialProviderTest.php index 89f8495ad0..6c291ae2cb 100644 --- a/tests/Credentials/CredentialProviderTest.php +++ b/tests/Credentials/CredentialProviderTest.php @@ -24,9 +24,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(CredentialProvider::class)] class CredentialProviderTest extends TestCase { diff --git a/tests/Credentials/CredentialsTest.php b/tests/Credentials/CredentialsTest.php index 43fc2bab12..c3e1f1f067 100644 --- a/tests/Credentials/CredentialsTest.php +++ b/tests/Credentials/CredentialsTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Credentials\Credentials::class)] class CredentialsTest extends TestCase { diff --git a/tests/Credentials/CredentialsUtilsTest.php b/tests/Credentials/CredentialsUtilsTest.php index 5653a10ec9..0d269f2415 100644 --- a/tests/Credentials/CredentialsUtilsTest.php +++ b/tests/Credentials/CredentialsUtilsTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Credentials\CredentialsUtils::class)] class CredentialsUtilsTest extends TestCase { diff --git a/tests/Credentials/EcsCredentialProviderTest.php b/tests/Credentials/EcsCredentialProviderTest.php index 5647704e2c..47bd9645e6 100644 --- a/tests/Credentials/EcsCredentialProviderTest.php +++ b/tests/Credentials/EcsCredentialProviderTest.php @@ -20,9 +20,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Credentials\EcsCredentialProvider::class)] class EcsCredentialProviderTest extends TestCase { @@ -104,10 +101,11 @@ public function testLoadsCredentialsAndProfile() $this->assertSame($t, $c->getExpiration()); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testDoesNotRequireConfig() { new EcsCredentialProvider(); + $this->assertTrue(true); } public function testRequestHeaderWithAuthorisationKey() diff --git a/tests/Credentials/InstanceProfileProviderTest.php b/tests/Credentials/InstanceProfileProviderTest.php index 4f7575e47d..0d180e88d1 100644 --- a/tests/Credentials/InstanceProfileProviderTest.php +++ b/tests/Credentials/InstanceProfileProviderTest.php @@ -20,9 +20,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(InstanceProfileProvider::class)] class InstanceProfileProviderTest extends TestCase { @@ -948,13 +945,14 @@ public function testThrowsExceptionOnInvalidMetadata() )->wait(); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testDoesNotRequireConfig() { new InstanceProfileProvider(); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testEnvDisableFlag() { $flag = getenv(InstanceProfileProvider::ENV_DISABLE); @@ -974,6 +972,7 @@ public function testEnvDisableFlag() } finally { putenv(InstanceProfileProvider::ENV_DISABLE . '=' . $flag); } + $this->assertTrue(true); } public function testRetriesEnvVarIsUsed() diff --git a/tests/Credentials/LoginCredentialProviderTest.php b/tests/Credentials/LoginCredentialProviderTest.php index c0cf4ffbca..575a5ddffc 100644 --- a/tests/Credentials/LoginCredentialProviderTest.php +++ b/tests/Credentials/LoginCredentialProviderTest.php @@ -14,9 +14,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(LoginCredentialProvider::class)] class LoginCredentialProviderTest extends TestCase { diff --git a/tests/Crypto/AesEncryptingStreamTest.php b/tests/Crypto/AesEncryptingStreamTest.php index 9bf4471326..b8c5dc78ce 100644 --- a/tests/Crypto/AesEncryptingStreamTest.php +++ b/tests/Crypto/AesEncryptingStreamTest.php @@ -193,8 +193,7 @@ public function testDoesNotSupportSeekingFromEnd(CipherMethod $cipherMethod) /** * * @param CipherMethod $cipherMethod - - */ + */ #[DataProvider('seekableCipherMethodProvider')] public function testSupportsSeekingFromCurrentPosition( CipherMethod $cipherMethod diff --git a/tests/Crypto/AesEncryptionStreamTestTrait.php b/tests/Crypto/AesEncryptionStreamTestTrait.php index 36626ba4c7..300a457b2c 100644 --- a/tests/Crypto/AesEncryptionStreamTestTrait.php +++ b/tests/Crypto/AesEncryptionStreamTestTrait.php @@ -53,7 +53,7 @@ public function cipherMethodProvider() return $toReturn; } - public function seekableCipherMethodProvider() + public function seekableCipherMethodProvider(): array { return array_filter($this->cipherMethodProvider(), function (array $args) { return !($args[0] instanceof Cbc); diff --git a/tests/Crypto/AlgorithmSuiteTest.php b/tests/Crypto/AlgorithmSuiteTest.php index 93848d26e5..4fe039d3d8 100644 --- a/tests/Crypto/AlgorithmSuiteTest.php +++ b/tests/Crypto/AlgorithmSuiteTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Crypto\AlgorithmSuite::class)] class AlgorithmSuiteTest extends TestCase { diff --git a/tests/Crypto/EncryptionDecryptionTraitV3Test.php b/tests/Crypto/EncryptionDecryptionTraitV3Test.php index 61ba00dbe4..ed03ec7907 100644 --- a/tests/Crypto/EncryptionDecryptionTraitV3Test.php +++ b/tests/Crypto/EncryptionDecryptionTraitV3Test.php @@ -19,9 +19,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Crypto\EncryptionTraitV3::class)] #[CoversClass(\Aws\Crypto\DecryptionTraitV3::class)] class EncryptionDecryptionTraitV3Test extends TestCase diff --git a/tests/Crypto/KmsMaterialsProviderTest.php b/tests/Crypto/KmsMaterialsProviderTest.php index 58355e058b..3d7b4b297a 100644 --- a/tests/Crypto/KmsMaterialsProviderTest.php +++ b/tests/Crypto/KmsMaterialsProviderTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(KmsMaterialsProvider::class)] class KmsMaterialsProviderTest extends TestCase { diff --git a/tests/Crypto/KmsMaterialsProviderV2Test.php b/tests/Crypto/KmsMaterialsProviderV2Test.php index 704bfe2dea..82836c1ffe 100644 --- a/tests/Crypto/KmsMaterialsProviderV2Test.php +++ b/tests/Crypto/KmsMaterialsProviderV2Test.php @@ -9,9 +9,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Crypto\KmsMaterialsProviderV2::class)] class KmsMaterialsProviderV2Test extends TestCase { diff --git a/tests/Crypto/KmsMaterialsProviderV3Test.php b/tests/Crypto/KmsMaterialsProviderV3Test.php index cf25dc06e4..ae97f18e55 100644 --- a/tests/Crypto/KmsMaterialsProviderV3Test.php +++ b/tests/Crypto/KmsMaterialsProviderV3Test.php @@ -9,9 +9,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Crypto\KmsMaterialsProviderV3::class)] class KmsMaterialsProviderV3Test extends TestCase { diff --git a/tests/Crypto/MetadataEnvelopeTest.php b/tests/Crypto/MetadataEnvelopeTest.php index 50e7846512..cf52e17cc0 100644 --- a/tests/Crypto/MetadataEnvelopeTest.php +++ b/tests/Crypto/MetadataEnvelopeTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(MetadataEnvelope::class)] class MetadataEnvelopeTest extends TestCase { diff --git a/tests/DSQL/AuthTokenGeneratorTest.php b/tests/DSQL/AuthTokenGeneratorTest.php index b8353d15c7..4a4b6612da 100644 --- a/tests/DSQL/AuthTokenGeneratorTest.php +++ b/tests/DSQL/AuthTokenGeneratorTest.php @@ -10,9 +10,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(AuthTokenGenerator::class)] class AuthTokenGeneratorTest extends TestCase { diff --git a/tests/DefaultsMode/ConfigurationProviderTest.php b/tests/DefaultsMode/ConfigurationProviderTest.php index fcc3803673..37c7f23e01 100644 --- a/tests/DefaultsMode/ConfigurationProviderTest.php +++ b/tests/DefaultsMode/ConfigurationProviderTest.php @@ -12,9 +12,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\DefaultsMode\ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -338,7 +335,7 @@ public function testCreatesFromCache() { $expected = new Configuration('standard'); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/DefaultsMode/ConfigurationTest.php b/tests/DefaultsMode/ConfigurationTest.php index b0be72488c..9ab87fccb7 100644 --- a/tests/DefaultsMode/ConfigurationTest.php +++ b/tests/DefaultsMode/ConfigurationTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\DefaultsMode\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/DocDb/DocDbClientTest.php b/tests/DocDb/DocDbClientTest.php index 64f4743a61..e097a5eb62 100644 --- a/tests/DocDb/DocDbClientTest.php +++ b/tests/DocDb/DocDbClientTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Signature/sig_hack.php'; -/** - - */ #[CoversClass(DocDBClient::class)] class DocDbClientTest extends TestCase { diff --git a/tests/DynamoDb/DynamoDbClientTest.php b/tests/DynamoDb/DynamoDbClientTest.php index d1bd925e3e..9b139c7beb 100644 --- a/tests/DynamoDb/DynamoDbClientTest.php +++ b/tests/DynamoDb/DynamoDbClientTest.php @@ -16,9 +16,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\DynamoDb\DynamoDbClient::class)] class DynamoDbClientTest extends TestCase { diff --git a/tests/DynamoDb/LockingSessionConnectionTest.php b/tests/DynamoDb/LockingSessionConnectionTest.php index 3d711cb2d8..461a2a1932 100644 --- a/tests/DynamoDb/LockingSessionConnectionTest.php +++ b/tests/DynamoDb/LockingSessionConnectionTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(LockingSessionConnection::class)] class LockingSessionConnectionTest extends TestCase { diff --git a/tests/DynamoDb/SessionConnectionConfigTraitTest.php b/tests/DynamoDb/SessionConnectionConfigTraitTest.php index 57f6c3e691..2e06925e69 100644 --- a/tests/DynamoDb/SessionConnectionConfigTraitTest.php +++ b/tests/DynamoDb/SessionConnectionConfigTraitTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(SessionConnectionConfigTrait::class)] class SessionConnectionConfigTraitTest extends TestCase { diff --git a/tests/DynamoDb/SessionHandlerTest.php b/tests/DynamoDb/SessionHandlerTest.php index 5cfd77c0f3..26de646be7 100644 --- a/tests/DynamoDb/SessionHandlerTest.php +++ b/tests/DynamoDb/SessionHandlerTest.php @@ -9,9 +9,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(SessionHandler::class)] class SessionHandlerTest extends TestCase { diff --git a/tests/DynamoDb/StandardSessionConnectionTest.php b/tests/DynamoDb/StandardSessionConnectionTest.php index 1771c328a1..fdcb86fcbe 100644 --- a/tests/DynamoDb/StandardSessionConnectionTest.php +++ b/tests/DynamoDb/StandardSessionConnectionTest.php @@ -10,9 +10,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(StandardSessionConnection::class)] class StandardSessionConnectionTest extends TestCase { diff --git a/tests/DynamoDb/WriteRequestBatchTest.php b/tests/DynamoDb/WriteRequestBatchTest.php index d9f29d8d88..922972d88e 100644 --- a/tests/DynamoDb/WriteRequestBatchTest.php +++ b/tests/DynamoDb/WriteRequestBatchTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(WriteRequestBatch::class)] class WriteRequestBatchTest extends TestCase { diff --git a/tests/Ec2/Ec2ClientTest.php b/tests/Ec2/Ec2ClientTest.php index 7659decdc1..568e4a4706 100644 --- a/tests/Ec2/Ec2ClientTest.php +++ b/tests/Ec2/Ec2ClientTest.php @@ -11,9 +11,6 @@ use Psr\Http\Message\RequestInterface; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Ec2Client::class)] class Ec2ClientTest extends TestCase { diff --git a/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php b/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php index c408bb7abd..d4a62b3440 100644 --- a/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php +++ b/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php @@ -5,9 +5,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ElasticLoadBalancingV2Client::class)] class ElasticLoadBalancingV2ClientTest extends TestCase { diff --git a/tests/Endpoint/EndpointProviderTest.php b/tests/Endpoint/EndpointProviderTest.php index 8b50c6c72d..57f207b987 100644 --- a/tests/Endpoint/EndpointProviderTest.php +++ b/tests/Endpoint/EndpointProviderTest.php @@ -7,9 +7,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(EndpointProvider::class)] class EndpointProviderTest extends TestCase { diff --git a/tests/Endpoint/PartitionEndpointProviderTest.php b/tests/Endpoint/PartitionEndpointProviderTest.php index 89320efc19..9a5ac266ed 100644 --- a/tests/Endpoint/PartitionEndpointProviderTest.php +++ b/tests/Endpoint/PartitionEndpointProviderTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Endpoint\PartitionEndpointProvider::class)] class PartitionEndpointProviderTest extends TestCase { diff --git a/tests/Endpoint/PartitionTest.php b/tests/Endpoint/PartitionTest.php index 7cff1b7716..b040a595f1 100644 --- a/tests/Endpoint/PartitionTest.php +++ b/tests/Endpoint/PartitionTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Endpoint\Partition::class)] class PartitionTest extends TestCase { @@ -133,7 +130,8 @@ public function testReportsRegionMatches(array $definition) #[DataProvider('partitionDefinitionProvider')] public function testReportsRegionMatchesByPattern(array $definition) { - $definition['regionRegex'] = '^fo[\w]{1}'; + $definition['regionRegex'] = '^fo[\w]{1 + $this->assertTrue(true);}'; $partition = new Partition($definition); $this->assertTrue($partition->isRegionMatch('foo', 's3')); diff --git a/tests/Endpoint/PatternEndpointProviderTest.php b/tests/Endpoint/PatternEndpointProviderTest.php index ceda8bd6d7..450b278ae1 100644 --- a/tests/Endpoint/PatternEndpointProviderTest.php +++ b/tests/Endpoint/PatternEndpointProviderTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(PatternEndpointProvider::class)] class PatternEndpointProviderTest extends TestCase { diff --git a/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php b/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php index 79125a092a..17b5b428a9 100644 --- a/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php +++ b/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php @@ -12,9 +12,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -342,7 +339,7 @@ public function testCreatesFromCache() { $expected = new Configuration(true, "us-east-1"); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php index b6508e8c85..a14f0fa80c 100644 --- a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Endpoint\UseDualstackEndpoint\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php b/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php index e2c7a4112a..62cd4ab805 100644 --- a/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php +++ b/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php @@ -11,9 +11,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -349,7 +346,7 @@ public function testCreatesFromCache() { $expected = new Configuration(true); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php index 8cfefec8b2..04bc457f69 100644 --- a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Endpoint\UseFipsEndpoint\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/EndpointDiscovery/ConfigurationProviderTest.php b/tests/EndpointDiscovery/ConfigurationProviderTest.php index a160109047..183c1afd30 100644 --- a/tests/EndpointDiscovery/ConfigurationProviderTest.php +++ b/tests/EndpointDiscovery/ConfigurationProviderTest.php @@ -14,9 +14,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -393,7 +390,7 @@ public function testCreatesFromCache() { $expected = new Configuration(true, 3500); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/EndpointDiscovery/ConfigurationTest.php b/tests/EndpointDiscovery/ConfigurationTest.php index a856417e0e..eec10981b1 100644 --- a/tests/EndpointDiscovery/ConfigurationTest.php +++ b/tests/EndpointDiscovery/ConfigurationTest.php @@ -7,9 +7,6 @@ use Psr\Log\InvalidArgumentException; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\EndpointDiscovery\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php index b9024ecebb..b8ccab9c7e 100644 --- a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php +++ b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php @@ -24,9 +24,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(EndpointDiscoveryMiddleware::class)] class EndpointDiscoveryMiddlewareTest extends TestCase { diff --git a/tests/EndpointDiscovery/EndpointListTest.php b/tests/EndpointDiscovery/EndpointListTest.php index ad81722d2a..9a869feb6b 100644 --- a/tests/EndpointDiscovery/EndpointListTest.php +++ b/tests/EndpointDiscovery/EndpointListTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\EndpointDiscovery\EndpointList::class)] class EndpointListTest extends TestCase { diff --git a/tests/EndpointParameterMiddlewareTest.php b/tests/EndpointParameterMiddlewareTest.php index 08398e5b47..8a3aea7093 100644 --- a/tests/EndpointParameterMiddlewareTest.php +++ b/tests/EndpointParameterMiddlewareTest.php @@ -10,9 +10,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\EndpointParameterMiddleware::class)] class EndpointParameterMiddlewareTest extends TestCase { diff --git a/tests/EndpointV2/EndpointProviderV2Test.php b/tests/EndpointV2/EndpointProviderV2Test.php index 1bf6e58f3b..7ba6688adc 100644 --- a/tests/EndpointV2/EndpointProviderV2Test.php +++ b/tests/EndpointV2/EndpointProviderV2Test.php @@ -17,9 +17,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(EndpointProviderV2::class)] class EndpointProviderV2Test extends TestCase { @@ -358,7 +355,7 @@ public function testCachesEndpointObject() $endpointMock = $this->getMockBuilder(RulesetEndpoint::class) ->disableOriginalConstructor() - ->setMethods([]) + ->onlyMethods([]) ->getMock(); $rulesetMock = $this->getMockBuilder(Ruleset::class) diff --git a/tests/EndpointV2/EndpointV2SerializerTraitTest.php b/tests/EndpointV2/EndpointV2SerializerTraitTest.php index 688523adbc..25b83e478a 100644 --- a/tests/EndpointV2/EndpointV2SerializerTraitTest.php +++ b/tests/EndpointV2/EndpointV2SerializerTraitTest.php @@ -9,9 +9,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(EndpointV2SerializerTrait::class)] class EndpointV2SerializerTraitTest extends TestCase { diff --git a/tests/EndpointV2/RuleCreatorTest.php b/tests/EndpointV2/RuleCreatorTest.php index 477ae3d024..f530ac0231 100644 --- a/tests/EndpointV2/RuleCreatorTest.php +++ b/tests/EndpointV2/RuleCreatorTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\EndpointV2\Rule\RuleCreator::class)] class RuleCreatorTest extends TestCase { diff --git a/tests/EndpointV2/RulesetEndpointTest.php b/tests/EndpointV2/RulesetEndpointTest.php index ac0676b87a..977f9218d5 100644 --- a/tests/EndpointV2/RulesetEndpointTest.php +++ b/tests/EndpointV2/RulesetEndpointTest.php @@ -4,9 +4,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(RulesetEndpoint::class)] class RulesetEndpointTest extends TestCase { diff --git a/tests/EndpointV2/RulesetParameterTest.php b/tests/EndpointV2/RulesetParameterTest.php index 252a725c59..843428ccdc 100644 --- a/tests/EndpointV2/RulesetParameterTest.php +++ b/tests/EndpointV2/RulesetParameterTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(RulesetParameter::class)] class RulesetParameterTest extends TestCase { @@ -92,13 +89,14 @@ public function testGetDefault() } /** - * @doesNotPerformAssertions + #[CoversNothing] * */ #[DataProvider('validTypesProvider')] public function testRulesetCreationWithValidTypes($spec) { new RulesetParameter('FooParam', $spec); $this->assertTrue(true); + $this->assertTrue(true); } public static function validTypesProvider(): array diff --git a/tests/EndpointV2/RulesetStandardLibraryTest.php b/tests/EndpointV2/RulesetStandardLibraryTest.php index ef280fec0a..02dc8e2132 100644 --- a/tests/EndpointV2/RulesetStandardLibraryTest.php +++ b/tests/EndpointV2/RulesetStandardLibraryTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\EndpointV2\Ruleset\RulesetStandardLibrary::class)] class RulesetStandardLibraryTest extends TestCase { diff --git a/tests/Exception/AwsExceptionTest.php b/tests/Exception/AwsExceptionTest.php index e270a063ef..07f26f1c9d 100644 --- a/tests/Exception/AwsExceptionTest.php +++ b/tests/Exception/AwsExceptionTest.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(AwsException::class)] class AwsExceptionTest extends TestCase { diff --git a/tests/Exception/CouldNotCreateChecksumExceptionTest.php b/tests/Exception/CouldNotCreateChecksumExceptionTest.php index 4165868ba2..52079346fb 100644 --- a/tests/Exception/CouldNotCreateChecksumExceptionTest.php +++ b/tests/Exception/CouldNotCreateChecksumExceptionTest.php @@ -5,9 +5,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(CouldNotCreateChecksumException::class)] class CouldNotCreateChecksumExceptionTest extends TestCase { diff --git a/tests/Exception/EventStreamDataExceptionTest.php b/tests/Exception/EventStreamDataExceptionTest.php index d9ccdd36ae..012d5b3c60 100644 --- a/tests/Exception/EventStreamDataExceptionTest.php +++ b/tests/Exception/EventStreamDataExceptionTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(EventStreamDataException::class)] class EventStreamDataExceptionTest extends TestCase { diff --git a/tests/Exception/MultipartUploadExceptionTest.php b/tests/Exception/MultipartUploadExceptionTest.php index 46b284cbbe..69ff8065d4 100644 --- a/tests/Exception/MultipartUploadExceptionTest.php +++ b/tests/Exception/MultipartUploadExceptionTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(MultipartUploadException::class)] class MultipartUploadExceptionTest extends TestCase { diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index b725b7417b..d4b625d103 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -43,7 +43,9 @@ public function testCreatesNonRecursiveDirIterator() public function testComposesOrFunctions() { - $a = function ($a, $b) { return null; }; + $a = function ($a, $b) { return null; + + $this->assertTrue(true);}; $b = function ($a, $b) { return $a . $b; }; $c = function ($a, $b) { return 'C'; }; $comp = Aws\or_chain($a, $b, $c); diff --git a/tests/Glacier/GlacierClientTest.php b/tests/Glacier/GlacierClientTest.php index 9fbd14c16d..8328a9420b 100644 --- a/tests/Glacier/GlacierClientTest.php +++ b/tests/Glacier/GlacierClientTest.php @@ -11,9 +11,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(GlacierClient::class)] class GlacierClientTest extends TestCase { diff --git a/tests/Glacier/MultipartUploaderTest.php b/tests/Glacier/MultipartUploaderTest.php index fa00ea1dff..f0470e51fd 100644 --- a/tests/Glacier/MultipartUploaderTest.php +++ b/tests/Glacier/MultipartUploaderTest.php @@ -10,9 +10,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(MultipartUploader::class)] class MultipartUploaderTest extends TestCase { diff --git a/tests/Handler/Guzzle/HandlerTest.php b/tests/Handler/Guzzle/HandlerTest.php index 0db2a1c80e..e8477af940 100644 --- a/tests/Handler/Guzzle/HandlerTest.php +++ b/tests/Handler/Guzzle/HandlerTest.php @@ -13,9 +13,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(GuzzleHandler::class)] class HandlerTest extends TestCase { diff --git a/tests/HandlerListTest.php b/tests/HandlerListTest.php index 9e1567c974..624182a449 100644 --- a/tests/HandlerListTest.php +++ b/tests/HandlerListTest.php @@ -9,9 +9,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(HandlerList::class)] class HandlerListTest extends TestCase { @@ -25,7 +22,9 @@ public function testEnsuresHandlerIsSet() public function testHandlerCanBeSetInCtor() { - $handler = function () {}; + $handler = function () { + + $this->assertTrue(true);}; $list = new HandlerList($handler); $this->assertTrue($list->hasHandler()); $this->assertSame($handler, $list->resolve()); @@ -33,7 +32,9 @@ public function testHandlerCanBeSetInCtor() public function testHandlerCanBeSetInSetter() { - $handler = function () {}; + $handler = function () { + + $this->assertTrue(true);}; $list = new HandlerList(); $list->setHandler($handler); $this->assertTrue($list->hasHandler()); @@ -49,7 +50,9 @@ public function testCanPrependWithName() public function testCanRemoveByInstance() { - $handler = function () {}; + $handler = function () { + + $this->assertTrue(true);}; $list = new HandlerList($handler); $middleware = function () { return function () {}; }; $list->appendInit($middleware); @@ -60,16 +63,19 @@ public function testCanRemoveByInstance() $this->assertSame($handler, $list->resolve()); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testIgnoreWhenNameNotFound() { $list = new HandlerList(); $list->remove('foo'); + $this->assertTrue(true); } public function testCanRemoveByName() { - $handler = function () {}; + $handler = function () { + + $this->assertTrue(true);}; $list = new HandlerList($handler); $middleware = function () { return function () {}; }; $list->appendInit($middleware, 'foo'); @@ -179,7 +185,9 @@ public function testMustExistByNameToPrependOrAppend() public function testCanInterposeMiddleware() { - $list = new HandlerList(function () {}); + $list = new HandlerList(function () { + + $this->assertTrue(true);}); $list->appendInit(Middleware::tap(function () {}), 'a'); $list->appendValidate(Middleware::tap(function () {}), 'b'); $list->appendBuild(Middleware::tap(function () {}), 'c'); diff --git a/tests/HasMonitoringEventsTraitTest.php b/tests/HasMonitoringEventsTraitTest.php index 5e27a32b0c..07d8b0bc28 100644 --- a/tests/HasMonitoringEventsTraitTest.php +++ b/tests/HasMonitoringEventsTraitTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\HasMonitoringEventsTrait::class)] class HasMonitoringEventsTraitTest extends TestCase { diff --git a/tests/HashingStreamTest.php b/tests/HashingStreamTest.php index 0af14fec59..f092cc746d 100644 --- a/tests/HashingStreamTest.php +++ b/tests/HashingStreamTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(HashingStream::class)] class HashingStreamTest extends TestCase { diff --git a/tests/HistoryTest.php b/tests/HistoryTest.php index 657dc09388..bc3eaf5065 100644 --- a/tests/HistoryTest.php +++ b/tests/HistoryTest.php @@ -9,9 +9,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(History::class)] class HistoryTest extends TestCase { diff --git a/tests/IdempotencyTokenMiddlewareTest.php b/tests/IdempotencyTokenMiddlewareTest.php index 7f8aa5a43f..30d2a08cad 100644 --- a/tests/IdempotencyTokenMiddlewareTest.php +++ b/tests/IdempotencyTokenMiddlewareTest.php @@ -12,9 +12,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(IdempotencyTokenMiddleware::class)] class IdempotencyTokenMiddlewareTest extends TestCase { diff --git a/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php b/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php index 04e119df3d..7bfbe47c35 100644 --- a/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php +++ b/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php @@ -8,9 +8,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(S3ExpressIdentityProvider::class)] class S3ExpressIdentityProviderTest extends TestCase { diff --git a/tests/InputValidationMiddlewareTest.php b/tests/InputValidationMiddlewareTest.php index a2f1f07b71..a5eb771ec4 100644 --- a/tests/InputValidationMiddlewareTest.php +++ b/tests/InputValidationMiddlewareTest.php @@ -13,9 +13,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\InputValidationMiddleware::class)] class InputValidationMiddlewareTest extends TestCase { diff --git a/tests/JsonCompilerTest.php b/tests/JsonCompilerTest.php index 0d1324132e..3d8d706dc9 100644 --- a/tests/JsonCompilerTest.php +++ b/tests/JsonCompilerTest.php @@ -5,9 +5,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(JsonCompiler::class)] class JsonCompilerTest extends TestCase { diff --git a/tests/LexModelsV2/LexModelsV2ClientTest.php b/tests/LexModelsV2/LexModelsV2ClientTest.php index b22abf5755..c60ca0a949 100644 --- a/tests/LexModelsV2/LexModelsV2ClientTest.php +++ b/tests/LexModelsV2/LexModelsV2ClientTest.php @@ -10,9 +10,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(LexModelsV2Client::class)] class LexModelsV2ClientTest extends TestCase { diff --git a/tests/LruArrayCacheTest.php b/tests/LruArrayCacheTest.php index 9d6a0f0298..443a222c30 100644 --- a/tests/LruArrayCacheTest.php +++ b/tests/LruArrayCacheTest.php @@ -5,9 +5,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(LruArrayCache::class)] class LruArrayCacheTest extends TestCase { diff --git a/tests/MachineLearning/MachineLearningClientTest.php b/tests/MachineLearning/MachineLearningClientTest.php index 94c5f3670c..7a36dba003 100644 --- a/tests/MachineLearning/MachineLearningClientTest.php +++ b/tests/MachineLearning/MachineLearningClientTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(MachineLearningClient::class)] class MachineLearningClientTest extends TestCase { diff --git a/tests/MetricsBuilderTest.php b/tests/MetricsBuilderTest.php index 158f45304b..5caf0638a8 100644 --- a/tests/MetricsBuilderTest.php +++ b/tests/MetricsBuilderTest.php @@ -66,7 +66,9 @@ public function testGetMetricsBuilderFromCommand() public function testAppendMetricsCaptureMiddleware() { - $handlerList = new HandlerList(function (){}); + $handlerList = new HandlerList(function (){ + + $this->assertTrue(true);}); $metric = "Foo"; // It should be appended into the build step MetricsBuilder::appendMetricsCaptureMiddleware( @@ -99,7 +101,6 @@ function ( * @param array $args * @param string $expectedMetrics * - * * @return void */ @@ -173,7 +174,8 @@ public static function resolveAndAppendFromArgsProvider(): array * @return void */ public function testAppendMetricsCaptureMiddlewareJustOnce(): void { - $handlerList = new HandlerList(function (){}); + $handlerList = new HandlerList(function (){ + $this->assertTrue(true);}); MetricsBuilder::appendMetricsCaptureMiddleware( $handlerList, 'test' diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index 8b6c61c014..6e40bd9b48 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -24,9 +24,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Middleware::class)] class MiddlewareTest extends TestCase { diff --git a/tests/MockHandlerTest.php b/tests/MockHandlerTest.php index a438798315..be16dcff82 100644 --- a/tests/MockHandlerTest.php +++ b/tests/MockHandlerTest.php @@ -12,9 +12,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(MockHandler::class)] class MockHandlerTest extends TestCase { diff --git a/tests/Multipart/AbstractUploaderTest.php b/tests/Multipart/AbstractUploaderTest.php index 77d73b7e54..1901b6286b 100644 --- a/tests/Multipart/AbstractUploaderTest.php +++ b/tests/Multipart/AbstractUploaderTest.php @@ -13,9 +13,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(AbstractUploader::class)] class AbstractUploaderTest extends TestCase { diff --git a/tests/Multipart/UploadStateTest.php b/tests/Multipart/UploadStateTest.php index 88d665a6f0..f64f32e198 100644 --- a/tests/Multipart/UploadStateTest.php +++ b/tests/Multipart/UploadStateTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(UploadState::class)] class UploadStateTest extends TestCase { diff --git a/tests/Neptune/NeptuneClientTest.php b/tests/Neptune/NeptuneClientTest.php index 4e8b093e30..6eb68988c6 100644 --- a/tests/Neptune/NeptuneClientTest.php +++ b/tests/Neptune/NeptuneClientTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Signature/sig_hack.php'; -/** - - */ #[CoversClass(NeptuneClient::class)] class NeptuneClientTest extends TestCase { diff --git a/tests/PhpHashTest.php b/tests/PhpHashTest.php index 5cefe9d8b9..0acee2efe1 100644 --- a/tests/PhpHashTest.php +++ b/tests/PhpHashTest.php @@ -5,9 +5,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(PhpHash::class)] class PhpHashTest extends TestCase { diff --git a/tests/Polly/PollyClientTest.php b/tests/Polly/PollyClientTest.php index 182782d769..f4dceb8b57 100644 --- a/tests/Polly/PollyClientTest.php +++ b/tests/Polly/PollyClientTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(PollyClient::class)] class PollyClientTest extends TestCase { diff --git a/tests/PresignUrlMiddlewareTest.php b/tests/PresignUrlMiddlewareTest.php index 611f9d2891..00feeee8f8 100644 --- a/tests/PresignUrlMiddlewareTest.php +++ b/tests/PresignUrlMiddlewareTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(PresignUrlMiddleware::class)] class PresignUrlMiddlewareTest extends TestCase { @@ -110,7 +107,6 @@ public function testNoPreSignedUrlWhenDifferentSourceRegionRequired() * @param string $value * @param string $expected * - * * @return void */ diff --git a/tests/QueryCompatibleInputMiddlewareTest.php b/tests/QueryCompatibleInputMiddlewareTest.php index 18d1d22328..7f5a7d3334 100644 --- a/tests/QueryCompatibleInputMiddlewareTest.php +++ b/tests/QueryCompatibleInputMiddlewareTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\QueryCompatibleInputMiddleware::class)] class QueryCompatibleInputMiddlewareTest extends TestCase { diff --git a/tests/Rds/AuthTokenGeneratorTest.php b/tests/Rds/AuthTokenGeneratorTest.php index 7a587c594e..fdacfc117c 100644 --- a/tests/Rds/AuthTokenGeneratorTest.php +++ b/tests/Rds/AuthTokenGeneratorTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(AuthTokenGenerator::class)] class AuthTokenGeneratorTest extends TestCase { diff --git a/tests/Rds/RdsClientTest.php b/tests/Rds/RdsClientTest.php index cdade290eb..84853fcd30 100644 --- a/tests/Rds/RdsClientTest.php +++ b/tests/Rds/RdsClientTest.php @@ -12,9 +12,6 @@ use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/../Signature/sig_hack.php'; -/** - - */ #[CoversClass(RdsClient::class)] class RdsClientTest extends TestCase { diff --git a/tests/ResultPaginatorTest.php b/tests/ResultPaginatorTest.php index d6f21fd041..25a7b07644 100644 --- a/tests/ResultPaginatorTest.php +++ b/tests/ResultPaginatorTest.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ResultPaginator::class)] class ResultPaginatorTest extends TestCase { @@ -127,8 +124,7 @@ public function testNonIterator() /** * @return array Test data */ - public function getPaginatorIterationData() - { + public static function getPaginatorIterationData(): array { return [ // Single field token case [ diff --git a/tests/ResultTest.php b/tests/ResultTest.php index 9ba3958be8..44640aaf4d 100644 --- a/tests/ResultTest.php +++ b/tests/ResultTest.php @@ -5,9 +5,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Result::class)] class ResultTest extends TestCase { diff --git a/tests/Retry/ConfigurationProviderTest.php b/tests/Retry/ConfigurationProviderTest.php index e9d1510221..18f70500b4 100644 --- a/tests/Retry/ConfigurationProviderTest.php +++ b/tests/Retry/ConfigurationProviderTest.php @@ -12,9 +12,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Retry\ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -351,7 +348,7 @@ public function testCreatesFromCache() { $expected = new Configuration('adaptive', 54); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/Retry/ConfigurationTest.php b/tests/Retry/ConfigurationTest.php index cfed8aab7f..cb61172e95 100644 --- a/tests/Retry/ConfigurationTest.php +++ b/tests/Retry/ConfigurationTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Retry\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/Retry/QuotaManagerTest.php b/tests/Retry/QuotaManagerTest.php index d9ecbf8dfc..c04111fd51 100644 --- a/tests/Retry/QuotaManagerTest.php +++ b/tests/Retry/QuotaManagerTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Retry\QuotaManager::class)] class QuotaManagerTest extends TestCase { diff --git a/tests/Retry/RateLimiterTest.php b/tests/Retry/RateLimiterTest.php index a690ec35e3..0e30aa193b 100644 --- a/tests/Retry/RateLimiterTest.php +++ b/tests/Retry/RateLimiterTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Retry\RateLimiter::class)] class RateLimiterTest extends TestCase { diff --git a/tests/RetryMiddlewareTest.php b/tests/RetryMiddlewareTest.php index fa8a15aa8e..e77924b99a 100644 --- a/tests/RetryMiddlewareTest.php +++ b/tests/RetryMiddlewareTest.php @@ -18,9 +18,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(RetryMiddleware::class)] class RetryMiddlewareTest extends TestCase { diff --git a/tests/RetryMiddlewareV2Test.php b/tests/RetryMiddlewareV2Test.php index 4389897542..c57e53288c 100644 --- a/tests/RetryMiddlewareV2Test.php +++ b/tests/RetryMiddlewareV2Test.php @@ -22,9 +22,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\RetryMiddlewareV2::class)] class RetryMiddlewareV2Test extends TestCase { @@ -134,8 +131,7 @@ function() use ($expected, &$attempt, $quotaManager, &$errors, $command) { $this->assertCount($attempt, $queue); } - function standardModeTestCases() - { + public static function standardModeTestCases(): array { $command = new Command('foo'); $result200 = new Result([ '@metadata' => [ diff --git a/tests/Route53/RouteClient53Test.php b/tests/Route53/RouteClient53Test.php index 81c5bc0d2f..822b466438 100644 --- a/tests/Route53/RouteClient53Test.php +++ b/tests/Route53/RouteClient53Test.php @@ -5,9 +5,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Route53Client::class)] class RouteClient53Test extends TestCase { diff --git a/tests/S3/AmbiguousSuccessParserTest.php b/tests/S3/AmbiguousSuccessParserTest.php index 6037047be0..82aee6a2fd 100644 --- a/tests/S3/AmbiguousSuccessParserTest.php +++ b/tests/S3/AmbiguousSuccessParserTest.php @@ -56,7 +56,7 @@ public function testConvertsAmbiguousSuccessesToExceptions($operation) /** * @param string $operation - * @doesNotPerformAssertions + #[CoversNothing] */ #[DataProvider('opsWithoutAmbiguousSuccessesProvider')] #[CoversNothing] @@ -74,6 +74,7 @@ public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations(string $oper $instance = $this->instance; $instance($command, $response); $this->assertTrue(true); + $this->assertTrue(true); } /** diff --git a/tests/S3/ApplyChecksumMiddlewareTest.php b/tests/S3/ApplyChecksumMiddlewareTest.php index 8198d2cdff..6d1a69313b 100644 --- a/tests/S3/ApplyChecksumMiddlewareTest.php +++ b/tests/S3/ApplyChecksumMiddlewareTest.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ApplyChecksumMiddleware::class)] class ApplyChecksumMiddlewareTest extends TestCase { diff --git a/tests/S3/BatchDeleteTest.php b/tests/S3/BatchDeleteTest.php index 989db26c53..c8d31c871e 100644 --- a/tests/S3/BatchDeleteTest.php +++ b/tests/S3/BatchDeleteTest.php @@ -10,9 +10,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\S3\BatchDelete::class)] class BatchDeleteTest extends TestCase { diff --git a/tests/S3/BucketEndpointArnMiddlewareTest.php b/tests/S3/BucketEndpointArnMiddlewareTest.php index eb65488ed1..6db04d29d5 100644 --- a/tests/S3/BucketEndpointArnMiddlewareTest.php +++ b/tests/S3/BucketEndpointArnMiddlewareTest.php @@ -16,9 +16,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\S3\BucketEndpointMiddleware::class)] class BucketEndpointArnMiddlewareTest extends TestCase { diff --git a/tests/S3/BucketEndpointMiddlewareTest.php b/tests/S3/BucketEndpointMiddlewareTest.php index 449c6e513c..1e2e1a0348 100644 --- a/tests/S3/BucketEndpointMiddlewareTest.php +++ b/tests/S3/BucketEndpointMiddlewareTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(BucketEndpointMiddleware::class)] class BucketEndpointMiddlewareTest extends TestCase { diff --git a/tests/S3/Crypto/HeadersMetadataStrategyTest.php b/tests/S3/Crypto/HeadersMetadataStrategyTest.php index 9985f55c6e..9fd200a09c 100644 --- a/tests/S3/Crypto/HeadersMetadataStrategyTest.php +++ b/tests/S3/Crypto/HeadersMetadataStrategyTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(HeadersMetadataStrategy::class)] class HeadersMetadataStrategyTest extends TestCase { diff --git a/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php b/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php index 366d8273e4..28512b0ddf 100644 --- a/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php +++ b/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php @@ -11,9 +11,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(InstructionFileMetadataStrategy::class)] class InstructionFileMetadataStrategyTest extends TestCase { diff --git a/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php b/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php index 597a0daf9c..1e9f8c3e08 100644 --- a/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php +++ b/tests/S3/Exception/DeleteMultipleObjectsExceptionTest.php @@ -5,9 +5,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(DeleteMultipleObjectsException::class)] class DeleteMultipleObjectsExceptionTest extends TestCase { diff --git a/tests/S3/Exception/S3MultipartUploadExceptionTest.php b/tests/S3/Exception/S3MultipartUploadExceptionTest.php index 4ece8af3aa..cdad5a81dd 100644 --- a/tests/S3/Exception/S3MultipartUploadExceptionTest.php +++ b/tests/S3/Exception/S3MultipartUploadExceptionTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(S3MultipartUploadException::class)] class S3MultipartUploadExceptionTest extends TestCase { diff --git a/tests/S3/ExpiresParsingMiddlewareTest.php b/tests/S3/ExpiresParsingMiddlewareTest.php index dbcd7e0878..71a59b77c5 100644 --- a/tests/S3/ExpiresParsingMiddlewareTest.php +++ b/tests/S3/ExpiresParsingMiddlewareTest.php @@ -10,9 +10,6 @@ use Psr\Http\Message\RequestInterface; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ExpiresParsingMiddleware::class)] class ExpiresParsingMiddlewareTest extends TestCase { diff --git a/tests/S3/GetBucketLocationParserTest.php b/tests/S3/GetBucketLocationParserTest.php index bad995ce56..e3b92f293f 100644 --- a/tests/S3/GetBucketLocationParserTest.php +++ b/tests/S3/GetBucketLocationParserTest.php @@ -10,9 +10,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(GetBucketLocationParser::class)] class GetBucketLocationParserTest extends TestCase { diff --git a/tests/S3/MultipartUploaderTest.php b/tests/S3/MultipartUploaderTest.php index 1cbff61ece..a3eec379db 100644 --- a/tests/S3/MultipartUploaderTest.php +++ b/tests/S3/MultipartUploaderTest.php @@ -13,9 +13,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(MultipartUploader::class)] class MultipartUploaderTest extends TestCase { @@ -138,8 +135,7 @@ public function testCanUseCaseInsensitiveConfigKeys() $this->assertSame($configProp->getValue($classicMup), $configProp->getValue($putObjectMup)); } - /** @doesNotPerformAssertions */ - public static function testMultipartSuccessStreams() + public static function multipartSuccessStreams(): array { $size = 12 * self::MB; $data = str_repeat('.', $size); @@ -161,7 +157,7 @@ public static function testMultipartSuccessStreams() /** */ - #[DataProvider('testMultipartSuccessStreams')] + #[DataProvider('multipartSuccessStreams')] public function testS3MultipartUploadParams($stream, $size) { /** @var \Aws\S3\S3Client $client */ @@ -199,6 +195,7 @@ public function testS3MultipartUploadParams($stream, $size) $this->assertTrue($uploader->getState()->isCompleted()); $this->assertSame($url, $result['ObjectURL']); + $this->assertTrue(true); } public static function getContentTypeSettingTests() @@ -313,7 +310,7 @@ public function testAppliesAmbiguousSuccessParsing() /** */ - #[DataProvider('testMultipartSuccessStreams')] + #[DataProvider('multipartSuccessStreams')] public function testUploaderAddsFlexibleChecksums($stream, $size) { /** @var \Aws\S3\S3Client $client */ diff --git a/tests/S3/ObjectCopierTest.php b/tests/S3/ObjectCopierTest.php index 09f23b516d..337658665b 100644 --- a/tests/S3/ObjectCopierTest.php +++ b/tests/S3/ObjectCopierTest.php @@ -263,7 +263,7 @@ public function testCanCopyVersions() { $client = $this->getMockBuilder(S3Client::class) ->disableOriginalConstructor() - ->setMethods(['getCommand', 'executeAsync']) + ->onlyMethods(['getCommand', 'executeAsync']) ->getMock(); $headObjectCommand = new Command('HeadObject'); diff --git a/tests/S3/Parser/S3ParserTest.php b/tests/S3/Parser/S3ParserTest.php index 5c95c397eb..310658ff1d 100644 --- a/tests/S3/Parser/S3ParserTest.php +++ b/tests/S3/Parser/S3ParserTest.php @@ -255,7 +255,6 @@ public function __invoke( * @param StreamInterface $stream * @param bool $expectValidation * - * * @return void */ diff --git a/tests/S3/PermanentRedirectMiddlewareTest.php b/tests/S3/PermanentRedirectMiddlewareTest.php index 7cb9c48c0e..66a7f1153d 100644 --- a/tests/S3/PermanentRedirectMiddlewareTest.php +++ b/tests/S3/PermanentRedirectMiddlewareTest.php @@ -5,9 +5,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\S3\PermanentRedirectMiddleware::class)] class PermanentRedirectMiddlewareTest extends TestCase { @@ -22,11 +19,12 @@ public function testThrowsSpecificException() $s3->getObject(['Bucket' => 'test', 'Key' => 'key']); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testPassesThroughUntouched() { $s3 = $this->getTestClient('s3'); $this->addMockResults($s3, [['@metadata' => ['statusCode' => 200]]]); $s3->getObject(['Bucket' => 'test', 'Key' => 'key']); + $this->assertTrue(true); } } diff --git a/tests/S3/PostObjectTest.php b/tests/S3/PostObjectTest.php index bfc161706d..65dee486ad 100644 --- a/tests/S3/PostObjectTest.php +++ b/tests/S3/PostObjectTest.php @@ -9,9 +9,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(PostObject::class)] class PostObjectTest extends TestCase { diff --git a/tests/S3/PostObjectV4Test.php b/tests/S3/PostObjectV4Test.php index c72d99371e..2176002831 100644 --- a/tests/S3/PostObjectV4Test.php +++ b/tests/S3/PostObjectV4Test.php @@ -11,9 +11,6 @@ require_once __DIR__ . '/sig_hack.php'; -/** - - */ #[CoversClass(PostObjectV4::class)] class PostObjectV4Test extends TestCase { diff --git a/tests/S3/PutObjectUrlMiddlewareTest.php b/tests/S3/PutObjectUrlMiddlewareTest.php index e42d873c95..f14410a67d 100644 --- a/tests/S3/PutObjectUrlMiddlewareTest.php +++ b/tests/S3/PutObjectUrlMiddlewareTest.php @@ -1,13 +1,11 @@ getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/S3/RegionalEndpoint/ConfigurationTest.php b/tests/S3/RegionalEndpoint/ConfigurationTest.php index 1ad94f92ab..d51a4c19fb 100644 --- a/tests/S3/RegionalEndpoint/ConfigurationTest.php +++ b/tests/S3/RegionalEndpoint/ConfigurationTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\S3\RegionalEndpoint\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/S3/S3Transfer/MultipartUploaderTest.php b/tests/S3/S3Transfer/MultipartUploaderTest.php index 8507ac1248..210c61cad0 100644 --- a/tests/S3/S3Transfer/MultipartUploaderTest.php +++ b/tests/S3/S3Transfer/MultipartUploaderTest.php @@ -278,7 +278,6 @@ private function getMultipartUploadS3Client(): S3ClientInterface * @param int $partSize * @param bool $expectError * - * * @return void */ @@ -338,7 +337,6 @@ public static function validatePartSizeProvider(): array { * @param string|int $source * @param bool $expectError * - * * @return void */ @@ -538,7 +536,6 @@ public function testMultipartOperationsAreCalled(): void { * @param array $checksumConfig * @param array $expectedOperationHeaders * - * * @return void */ @@ -850,7 +847,6 @@ public function testTransferListenerNotifierWithEmptyListeners(): void * @param array $checksumConfig * @param bool $expectsError * - * * @return void */ diff --git a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php index 4ee05097ac..8eea6c875e 100644 --- a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php @@ -26,7 +26,6 @@ class PartGetMultipartDownloaderTest extends TestCase * @param int $objectSizeInBytes * @param int $targetPartSize * - * * @return void */ @@ -211,7 +210,6 @@ public function testComputeObjectDimensions(): void * @param int $targetPartSize * @param string $eTag * - * * @return void */ diff --git a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php index cc58481212..5b0839943a 100644 --- a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php +++ b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php @@ -32,7 +32,6 @@ public function testDefaultInitialization(): void * @param bool $clear * @param TransferProgressSnapshot $snapshot * - * * @return void */ @@ -90,7 +89,6 @@ public static function customInitializationProvider(): array * @param callable $eventInvoker * @param array $expectedOutputs * - * * @return void */ diff --git a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php index c063ed9c31..4d22fafabe 100644 --- a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php @@ -27,7 +27,6 @@ class RangeGetMultipartDownloaderTest extends TestCase * @param int $objectSizeInBytes * @param int $targetPartSize * - * * @return void */ @@ -261,7 +260,6 @@ public function testNextCommandIncludesIfMatchWhenETagPresent(): void * @param int $targetPartSize * @param string $eTag * - * * @return void */ diff --git a/tests/S3/S3Transfer/S3TransferManagerTest.php b/tests/S3/S3Transfer/S3TransferManagerTest.php index b4132cb6a9..9067c1a0f8 100644 --- a/tests/S3/S3Transfer/S3TransferManagerTest.php +++ b/tests/S3/S3Transfer/S3TransferManagerTest.php @@ -380,7 +380,6 @@ public function testUploadUsesTransferManagerConfigDefaultMupThreshold(): void * @param int $expectedPartSize * @param bool $isMultipartUpload * - * * @return void */ @@ -550,7 +549,6 @@ public function testUploadUsesDefaultChecksumAlgorithm(): void /** * @param string $checksumAlgorithm * - * * @return void */ @@ -635,7 +633,6 @@ private function testUploadResolvedChecksum( * @param string $directory * @param bool $isDirectoryValid * - * * @return void */ @@ -1804,7 +1801,6 @@ public static function downloadAppliesChecksumProvider(): array * @param string $multipartDownloadType * @param string $expectedParameter * - * * @return void */ @@ -1869,7 +1865,6 @@ public static function downloadChoosesMultipartDownloadTypeProvider(): array * * @return void * - * */ #[DataProvider('rangeGetMultipartDownloadMinimumPartSizeProvider')] @@ -2014,7 +2009,6 @@ public function testDownloadDirectoryCreatesDestinationDirectory(): void * @param array $config * @param string $expectedS3Prefix * - * * @return void */ @@ -2304,7 +2298,6 @@ public function testDownloadDirectoryUsesFailurePolicy(): void * @param array $objectList * @param array $expectedObjectList * - * * @return void */ @@ -2622,7 +2615,6 @@ public function testDownloadDirectoryGetObjectRequestCallbackWorks(): void * @param array $listObjectsContent * @param array $expectedFileKeys * - * * @return void */ diff --git a/tests/S3/S3UriParserTest.php b/tests/S3/S3UriParserTest.php index 86b60e95e7..b128cfc5cb 100644 --- a/tests/S3/S3UriParserTest.php +++ b/tests/S3/S3UriParserTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(S3UriParser::class)] class S3UriParserTest extends TestCase { diff --git a/tests/S3/SSECMiddlewareTest.php b/tests/S3/SSECMiddlewareTest.php index 391f2e8273..7dc6901aaa 100644 --- a/tests/S3/SSECMiddlewareTest.php +++ b/tests/S3/SSECMiddlewareTest.php @@ -3,14 +3,12 @@ use Aws\Middleware; use Aws\Result; +use Aws\S3\SSECMiddleware; use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(SSECMiddleware::class)] class SSECMiddlewareTest extends TestCase { @@ -89,11 +87,12 @@ public function testCannotUseWithoutHttps() ]); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanUseWithoutHttpsForNonSse() { $client = $this->getTestClient('s3', ['scheme' => 'http']); $this->addMockResults($client, [new Result()]); $client->listBuckets(); + $this->assertTrue(true); } } diff --git a/tests/S3/StreamWrapperPathStyleTest.php b/tests/S3/StreamWrapperPathStyleTest.php index 54d381f3b0..6d224716b4 100644 --- a/tests/S3/StreamWrapperPathStyleTest.php +++ b/tests/S3/StreamWrapperPathStyleTest.php @@ -15,9 +15,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(StreamWrapper::class)] class StreamWrapperPathStyleTest extends TestCase { @@ -80,7 +77,7 @@ public function testValidatesXMode() fopen('s3://bucket/key', 'x'); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testSuccessfulXMode() { $this->addMockResults( @@ -94,6 +91,7 @@ function ($cmd, $request) { ); $r = fopen('s3://bucket/key', 'x'); fclose($r); + $this->assertTrue(true); } public function testOpensNonSeekableReadStream() @@ -776,7 +774,7 @@ public function testProvidesDirectoriesForS3() closedir($r); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanSetDelimiterStreamContext() { $this->addMockResults($this->client, [ @@ -802,6 +800,7 @@ public function testCanSetDelimiterStreamContext() $context = stream_context_create(['s3' => ['delimiter' => '']]); $r = opendir('s3://bucket', $context); closedir($r); + $this->assertTrue(true); } public function testCachesReaddirs() diff --git a/tests/S3/StreamWrapperTest.php b/tests/S3/StreamWrapperTest.php index b7eb831123..689006d541 100644 --- a/tests/S3/StreamWrapperTest.php +++ b/tests/S3/StreamWrapperTest.php @@ -16,9 +16,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(StreamWrapper::class)] class StreamWrapperTest extends TestCase { @@ -117,7 +114,7 @@ public function testValidatesArn() } } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testSuccessfulXMode() { $this->addMockResults( @@ -131,6 +128,7 @@ function ($cmd, $request) { ); $r = fopen('s3://bucket/key', 'x'); fclose($r); + $this->assertTrue(true); } public function testOpensNonSeekableReadStream() @@ -1040,7 +1038,7 @@ public function testProvidesDirectoriesForS3() closedir($r); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanSetDelimiterStreamContext() { $this->addMockResults($this->client, [ @@ -1066,6 +1064,7 @@ public function testCanSetDelimiterStreamContext() $context = stream_context_create(['s3' => ['delimiter' => '']]); $r = opendir('s3://bucket', $context); closedir($r); + $this->assertTrue(true); } public function testCachesReaddirs() diff --git a/tests/S3/StreamWrapperV2ExistenceTest.php b/tests/S3/StreamWrapperV2ExistenceTest.php index 27a34cdb39..0a6461114b 100644 --- a/tests/S3/StreamWrapperV2ExistenceTest.php +++ b/tests/S3/StreamWrapperV2ExistenceTest.php @@ -44,7 +44,7 @@ public function tear_down() } /** - * @doesNotPerformAssertions + #[CoversNothing] */ public function testSuccessfulXMode() { @@ -63,6 +63,7 @@ function ($cmd, $request) { ); $r = fopen('s3://bucket/key', 'x'); fclose($r); + $this->assertTrue(true); } public function testOpensNonSeekableReadStream() diff --git a/tests/S3/TransferTest.php b/tests/S3/TransferTest.php index ee41229e18..184236fb43 100644 --- a/tests/S3/TransferTest.php +++ b/tests/S3/TransferTest.php @@ -16,9 +16,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Transfer::class)] class TransferTest extends TestCase { diff --git a/tests/S3/UseArnRegion/ConfigurationProviderTest.php b/tests/S3/UseArnRegion/ConfigurationProviderTest.php index ab945f102e..f54aca36d9 100644 --- a/tests/S3/UseArnRegion/ConfigurationProviderTest.php +++ b/tests/S3/UseArnRegion/ConfigurationProviderTest.php @@ -11,9 +11,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { @@ -340,7 +337,7 @@ public function testCreatesFromCache() { $expected = new Configuration(true); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/S3/UseArnRegion/ConfigurationTest.php b/tests/S3/UseArnRegion/ConfigurationTest.php index 7b8daec011..5a365c0537 100644 --- a/tests/S3/UseArnRegion/ConfigurationTest.php +++ b/tests/S3/UseArnRegion/ConfigurationTest.php @@ -6,9 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\S3\UseArnRegion\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/S3/ValidateResponseChecksumParserTest.php b/tests/S3/ValidateResponseChecksumParserTest.php index 6a05178a18..124f7fe9da 100644 --- a/tests/S3/ValidateResponseChecksumParserTest.php +++ b/tests/S3/ValidateResponseChecksumParserTest.php @@ -13,9 +13,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(ValidateResponseChecksumParser::class)] class ValidateResponseChecksumParserTest extends TestCase { diff --git a/tests/S3Control/EndpointArnMiddlewareTest.php b/tests/S3Control/EndpointArnMiddlewareTest.php index 0c1294b5cf..6a75ae2715 100644 --- a/tests/S3Control/EndpointArnMiddlewareTest.php +++ b/tests/S3Control/EndpointArnMiddlewareTest.php @@ -13,9 +13,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\S3Control\EndpointArnMiddleware::class)] class EndpointArnMiddlewareTest extends TestCase { diff --git a/tests/S3Control/S3ControlClientTest.php b/tests/S3Control/S3ControlClientTest.php index f8d994c640..ba798e7f39 100644 --- a/tests/S3Control/S3ControlClientTest.php +++ b/tests/S3Control/S3ControlClientTest.php @@ -2,15 +2,13 @@ namespace Aws\Test\S3Control; use Aws\Endpoint\PartitionEndpointProvider; +use Aws\S3Control\S3ControlClient; use GuzzleHttp\Promise; use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(S3ControlClient::class)] class S3ControlClientTest extends TestCase { diff --git a/tests/SdkTest.php b/tests/SdkTest.php index 560e3664ef..a990012ee4 100644 --- a/tests/SdkTest.php +++ b/tests/SdkTest.php @@ -8,9 +8,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(Sdk::class)] class SdkTest extends TestCase { @@ -24,7 +21,7 @@ public function testEnsuresMissingMethodThrowsException() public function testHasMagicMethods() { $sdk = $this->getMockBuilder(Sdk::class) - ->setMethods(['createClient']) + ->onlyMethods(['createClient']) ->getMock(); $sdk->expects($this->once()) ->method('createClient') diff --git a/tests/Signature/AnonymousSignatureTest.php b/tests/Signature/AnonymousSignatureTest.php index 46a8a49123..15a913b603 100644 --- a/tests/Signature/AnonymousSignatureTest.php +++ b/tests/Signature/AnonymousSignatureTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(AnonymousSignature::class)] class AnonymousSignatureTest extends TestCase { diff --git a/tests/Signature/DpopSignatureTest.php b/tests/Signature/DpopSignatureTest.php index b75cbf01e6..dbc9fd2c1c 100644 --- a/tests/Signature/DpopSignatureTest.php +++ b/tests/Signature/DpopSignatureTest.php @@ -6,9 +6,6 @@ use GuzzleHttp\Psr7\Request; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(DpopSignature::class)] class DpopSignatureTest extends TestCase { diff --git a/tests/Signature/S3ExpressSignatureTest.php b/tests/Signature/S3ExpressSignatureTest.php index 4288466672..90436af315 100644 --- a/tests/Signature/S3ExpressSignatureTest.php +++ b/tests/Signature/S3ExpressSignatureTest.php @@ -10,9 +10,6 @@ require_once __DIR__ . '/sig_hack.php'; -/** - - */ #[CoversClass(S3ExpressSignature::class)] class S3ExpressSignatureTest extends TestCase { diff --git a/tests/Signature/S3SignatureV4Test.php b/tests/Signature/S3SignatureV4Test.php index 50c70d5672..4d0b803c8e 100644 --- a/tests/Signature/S3SignatureV4Test.php +++ b/tests/Signature/S3SignatureV4Test.php @@ -8,9 +8,6 @@ use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/sig_hack.php'; -/** - - */ #[CoversClass(S3SignatureV4::class)] class S3SignatureV4Test extends TestCase { diff --git a/tests/Signature/SignatureProviderTest.php b/tests/Signature/SignatureProviderTest.php index 94a7884b80..f2be70df94 100644 --- a/tests/Signature/SignatureProviderTest.php +++ b/tests/Signature/SignatureProviderTest.php @@ -12,9 +12,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(SignatureProvider::class)] class SignatureProviderTest extends TestCase { diff --git a/tests/Signature/SignatureV4Test.php b/tests/Signature/SignatureV4Test.php index 7ae13b13ee..166b7bd8dd 100644 --- a/tests/Signature/SignatureV4Test.php +++ b/tests/Signature/SignatureV4Test.php @@ -12,9 +12,6 @@ require_once __DIR__ . '/sig_hack.php'; -/** - - */ #[CoversClass(SignatureV4::class)] class SignatureV4Test extends TestCase { @@ -397,8 +394,7 @@ public function testEnsuresContentSha256CanBeCalculatedWhenSeekFails() $signature->signRequest($request, $credentials); } - /** @doesNotPerformAssertions */ - public static function testUnsignedPayloadProvider() + public static function unsignedPayloadProvider() { return [ // POST headers should be signed. @@ -455,7 +451,7 @@ public static function testUnsignedPayloadProvider() /** */ - #[DataProvider('testUnsignedPayloadProvider')] + #[DataProvider('unsignedPayloadProvider')] public function testSignRequestUnsignedPayload($req, $sreq, $creq) { $_SERVER['aws_time'] = '20110909T233600Z'; @@ -471,10 +467,10 @@ public function testSignRequestUnsignedPayload($req, $sreq, $creq) $ctx = $contextFn->invoke($signature, $parsed, $payload); $this->assertEquals($creq, $ctx['creq']); $this->assertSame($sreq, Psr7\Message::toString($signature->signRequest($request, $credentials))); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ - public static function testProvider() + public static function provider() { return [ // POST headers should be signed. @@ -579,7 +575,7 @@ public static function testProvider() /** */ - #[DataProvider('testProvider')] + #[DataProvider('provider')] public function testSignsRequests($req, $sreq, $creq) { $_SERVER['aws_time'] = '20110909T233600Z'; @@ -594,6 +590,7 @@ public function testSignsRequests($req, $sreq, $creq) $ctx = $contextFn->invoke($signature, $parsed, $payload); $this->assertEquals($creq, $ctx['creq']); $this->assertSame($sreq, Psr7\Message::toString($signature->signRequest($request, $credentials))); + $this->assertTrue(true); } public function testRemovesIllegalV4aHeadersBeforeSigning() diff --git a/tests/Sqs/SqsClientTest.php b/tests/Sqs/SqsClientTest.php index 7b1e4fa651..ee21ea778e 100644 --- a/tests/Sqs/SqsClientTest.php +++ b/tests/Sqs/SqsClientTest.php @@ -8,9 +8,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(SqsClient::class)] class SqsClientTest extends TestCase { @@ -157,7 +154,7 @@ public function testValidatesMessageAttributesExistWithMd5() ]); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testSkipsCommandsThatAreNotReceiveMessage() { $client = new SqsClient([ @@ -166,6 +163,7 @@ public function testSkipsCommandsThatAreNotReceiveMessage() ]); $this->addMockResults($client, [new Result()]); $client->listQueues(); + $this->assertTrue(true); } public function testDoesNotValidateEmptyMessageAttributes() diff --git a/tests/Ssm/SsmClientTest.php b/tests/Ssm/SsmClientTest.php index 7bbf734e92..f61125eca6 100644 --- a/tests/Ssm/SsmClientTest.php +++ b/tests/Ssm/SsmClientTest.php @@ -7,9 +7,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(SsmClient::class)] class SsmClientTest extends TestCase { diff --git a/tests/StreamRequestPayloadMiddlewareTest.php b/tests/StreamRequestPayloadMiddlewareTest.php index 80245b662e..130c2a3d51 100644 --- a/tests/StreamRequestPayloadMiddlewareTest.php +++ b/tests/StreamRequestPayloadMiddlewareTest.php @@ -17,9 +17,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\StreamRequestPayloadMiddleware::class)] class StreamRequestPayloadMiddlewareTest extends TestCase { @@ -137,7 +134,7 @@ public function testThrowsExceptionOnIncalculableSize() ->willReturn(null); $requestMock = $this->getMockBuilder(Request::class) ->setConstructorArgs(['POST', 'https://foo.com']) - ->setMethods(['getBody']) + ->onlyMethods(['getBody']) ->getMock(); $requestMock->expects($this->any()) ->method('getBody') diff --git a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php index c7f4e0971a..99505a6254 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php @@ -339,7 +339,7 @@ public function testCreatesFromCache() { $expected = new Configuration('regional'); $cacheBuilder = $this->getMockBuilder(CacheInterface::class); - $cacheBuilder->setMethods(['get', 'set', 'remove']); + $cacheBuilder->onlyMethods(['get', 'set', 'remove']); $cache = $cacheBuilder->getMock(); $cache->expects($this->any()) ->method('get') diff --git a/tests/Sts/RegionalEndpoints/ConfigurationTest.php b/tests/Sts/RegionalEndpoints/ConfigurationTest.php index 5ad7c96e5d..c87bfd3759 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationTest.php @@ -6,9 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(\Aws\Sts\RegionalEndpoints\Configuration::class)] class ConfigurationTest extends TestCase { diff --git a/tests/Sts/StsClientTest.php b/tests/Sts/StsClientTest.php index c689879c8a..7932f32841 100644 --- a/tests/Sts/StsClientTest.php +++ b/tests/Sts/StsClientTest.php @@ -18,9 +18,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(StsClient::class)] class StsClientTest extends TestCase { @@ -437,7 +434,7 @@ private function getTestStsClient($operation, $response) { $stsClient = $this->getMockBuilder(StsClient::class) -> disableOriginalConstructor() - -> setMethods(['__call']) + -> onlyMethods(['__call']) -> getMock(); $stsClient->method('__call') -> willReturnCallback(function ($callOperation) use ($operation, $response) { diff --git a/tests/Token/BearerTokenAuthorizationTest.php b/tests/Token/BearerTokenAuthorizationTest.php index 166eb4cd1f..730febd449 100644 --- a/tests/Token/BearerTokenAuthorizationTest.php +++ b/tests/Token/BearerTokenAuthorizationTest.php @@ -1,15 +1,13 @@ originalEnv = [ + 'AWS_BEARER_TOKEN_BEDROCK' => getenv('AWS_BEARER_TOKEN_BEDROCK'), + 'AWS_BEARER_TOKEN_BEDROCKS' => getenv('AWS_BEARER_TOKEN_BEDROCKS'), + 'AWS_BEARER_TOKEN_BEDROCK_AGENT' => getenv('AWS_BEARER_TOKEN_BEDROCK_AGENT'), + 'AWS_AUTH_SCHEME_PREFERENCE' => getenv('AWS_AUTH_SCHEME_PREFERENCE'), + 'AWS_CONFIG_FILE' => getenv('AWS_CONFIG_FILE') + ]; + } + + protected function tearDown(): void + { + parent::tearDown(); + + // Restore original environment values + foreach ($this->originalEnv as $key => $value) { + if ($value !== false) { + putenv("{$key}={$value}"); + } else { + putenv("{$key}="); + } + } + + // Clean up temp files + if ($this->tempConfigFile && file_exists($this->tempConfigFile)) { + unlink($this->tempConfigFile); + } + if ($this->tempDir && is_dir($this->tempDir)) { + rmdir($this->tempDir); + } + + $this->tempConfigFile = null; + $this->tempDir = null; + } + + /** + * Test defaultProvider creates a memoized chain with env provider + */ + public function testDefaultProvider(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK=test-token-123'); + + $provider = BedrockTokenProvider::defaultProvider(); + + $promise = $provider(); + $this->assertInstanceOf(Promise\PromiseInterface::class, $promise); + + $token = $promise->wait(); + $this->assertInstanceOf(TokenInterface::class, $token); + $this->assertEquals('test-token-123', $token->getToken()); + $this->assertNull($token->getExpiration()); + $this->assertFalse($token->isExpired()); + } + + /** + * Test defaultProvider when environment variable is not set + */ + public function testDefaultProviderNoEnvVar(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK'); + + $provider = BedrockTokenProvider::defaultProvider(); + $promise = $provider(); + + // The memoize wrapper converts rejections to null + $result = $promise->wait(); + $this->assertNull($result); + } + + /** + * Test env() method creates proper provider + */ + public function testEnvMethod(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK=env-test-token'); + + $provider = BedrockTokenProvider::env('bearer_token_bedrock'); + $promise = $provider(); + $token = $promise->wait(); + + $this->assertInstanceOf(Token::class, $token); + $this->assertEquals('env-test-token', $token->getToken()); + $this->assertNull($token->getExpiration()); + } + + /** + * Test env() method when environment variable is empty + */ + public function testEnvMethodEmptyValue(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK='); + + $provider = BedrockTokenProvider::env('bearer_token_bedrock'); + $promise = $provider(); + + try { + $promise->wait(); + $this->fail('Expected TokenException was not thrown'); + } catch (TokenException $e) { + $this->assertStringContainsString( + 'No token found in environment variable AWS_BEARER_TOKEN_BEDROCK', + $e->getMessage() + ); + } + } + + /** + * Test fromTokenValue() method + */ + public function testFromTokenValue(): void + { + $tokenValue = 'static-token-value'; + $provider = BedrockTokenProvider::fromTokenValue($tokenValue); + $promise = $provider(); + $token = $promise->wait(); + + $this->assertInstanceOf(Token::class, $token); + $this->assertEquals($tokenValue, $token->getToken()); + $this->assertNull($token->getExpiration()); + $this->assertFalse($token->isExpired()); + } + + /** + * Test createIfAvailable() when conditions are met + */ + public function testCreateIfAvailableSuccess(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK=bedrock-token-456'); + + $args = ['config' => ['auth_scheme_preference' => ['some-other-auth']]]; + + $provider = BedrockTokenProvider::createIfAvailable($args); + + $this->assertNotNull($provider); + // Check auth_scheme_preference was modified + $this->assertCount(2, $args['config']['auth_scheme_preference']); + $this->assertEquals( + BedrockTokenProvider::BEARER_AUTH, + $args['config']['auth_scheme_preference'][0] + ); + $this->assertEquals( + 'some-other-auth', + $args['config']['auth_scheme_preference'][1] + ); + + // Verify the provider works + $promise = $provider(); + $token = $promise->wait(); + $this->assertEquals('bedrock-token-456', $token->getToken()); + } + + /** + * Test createIfAvailable() when auth_scheme_preference is not set + */ + public function testCreateIfAvailableNoAuthSchemePreference(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK=bedrock-token-789'); + + $args = [ + 'config' => ['signing_name' => 'bedrock'] + ]; + $provider = BedrockTokenProvider::createIfAvailable($args); + + $this->assertNotNull($provider); + + // Check auth_scheme_preference was created + $this->assertArrayHasKey('auth_scheme_preference', $args['config']); + $this->assertCount(1, $args['config']['auth_scheme_preference']); + $this->assertEquals( + BedrockTokenProvider::BEARER_AUTH, + $args['config']['auth_scheme_preference'][0] + ); + } + + /** + * Test createIfAvailable() when token is not available + */ + public function testCreateIfAvailableNoToken(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK'); + + $args = []; + $provider = BedrockTokenProvider::createIfAvailable($args); + + $this->assertNull($provider); + $this->assertArrayNotHasKey('auth_scheme_preference', $args); + } + + /** + * Test memoization behavior - token should be cached + */ + public function testMemoization(): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK=memoized-token'); + + $provider = BedrockTokenProvider::defaultProvider(); + + // First call + $token1 = $provider()->wait(); + + // Change the environment variable + putenv('AWS_BEARER_TOKEN_BEDROCK=different-token'); + + // Second call should return the same token due to memoization + $token2 = $provider()->wait(); + + $this->assertEquals($token1->getToken(), $token2->getToken()); + $this->assertEquals('memoized-token', $token2->getToken()); + } + + /** + * Test integration with Bedrock Clients + * + * @param $serviceName + * @param $envVars + * @param $clientArgs + * @param $expectations + * @param $iniConfig + * + + */ + #[DataProvider('integrationWithClientProvider')] + public function testIntegrationWithClient( + $serviceName, + $envVars, + $clientArgs, + $expectations, + $iniConfig = null + ): void + { + foreach ($envVars as $key => $value) { + putenv("{$key}={$value}"); + } + + if ($iniConfig !== null) { + $this->tempDir = sys_get_temp_dir() . '/bedrock-token-test-' . uniqid() . '/'; + $this->tempConfigFile = $this->tempDir . 'config'; + + if (!is_dir($this->tempDir)) { + mkdir($this->tempDir, 0777, true); + } + + $configContent = "[default]\n"; + foreach ($iniConfig as $key => $value) { + $configContent .= "{$key}={$value}\n"; + } + + file_put_contents($this->tempConfigFile, $configContent); + putenv("AWS_CONFIG_FILE={$this->tempConfigFile}"); + } + + $args = array_merge([ + 'region' => 'us-east-1', + 'version' => 'latest', + 'credentials' => [ + 'key' => 'key', + 'secret' => 'secret' + ] + ], $clientArgs); + + $client = $this->getTestClient($serviceName, $args); + $promise = $client->getToken(); + $token = $promise->wait(); + + // Check token value + if ($expectations['token'] !== null) { + $this->assertEquals($expectations['token'], $token->getToken()); + + if (isset($envVars['AWS_BEARER_TOKEN_BEDROCK']) + && !isset($clientArgs['token']) + ) { + $this->assertEquals( + TokenSource::BEARER_SERVICE_ENV_VARS->value, + $token->getSource() + ); + } else { + $this->assertNull($token->getSource()); + } + } else { + $this->assertNull($token); + } + + // Check auth scheme preference + if (isset($expectations['auth_scheme_preference'])) { + $this->assertEquals( + $expectations['auth_scheme_preference'], + $client->getConfig('auth_scheme_preference')[0] + ); + } + } + + public static function integrationWithClientProvider(): \Generator + { + static $services = [ + 'bedrock', + 'bedrock-agent', + 'bedrock-agent-runtime', + 'bedrock-data-automation', + 'bedrock-data-automation-runtime' + ]; + + foreach ($services as $service) { + // Valid env var + yield "{$service}_valid_env" => [ + 'service' => $service, + 'env_vars' => ['AWS_BEARER_TOKEN_BEDROCK' => 'test-token'], + 'client_args' => [], + 'expectations' => [ + 'token' => 'test-token', + 'auth_scheme_preference' => BedrockTokenProvider::BEARER_AUTH + ] + ]; + + // Similar but invalid env var + yield "{$service}_invalid_env" => [ + 'service' => $service, + 'env_vars' => [ + 'AWS_BEARER_TOKEN_BEDROCKS' => 'wrong-token', + 'AWS_BEARER_TOKEN_BEDROCK_AGENT' => 'wrong-token' + ], + 'client_args' => [], + 'expectations' => [ + 'token' => null + ] + ]; + + // AWS_AUTH_SCHEME_PREFERENCE set + yield "{$service}_auth_scheme_env" => [ + 'service' => $service, + 'env_vars' => [ + 'AWS_BEARER_TOKEN_BEDROCK' => 'test-token', + 'AWS_AUTH_SCHEME_PREFERENCE' => 'aws.auth#sigv4,smithy.api#noAuth' + ], + 'client_args' => [], + 'expectations' => [ + 'token' => 'test-token', + 'auth_scheme_preference' => BedrockTokenProvider::BEARER_AUTH + ] + ]; + + // auth_scheme_preference from INI file + yield "{$service}_auth_scheme_ini" => [ + 'service' => $service, + 'env_vars' => ['AWS_BEARER_TOKEN_BEDROCK' => 'test-token'], + 'client_args' => [], + 'expectations' => [ + 'token' => 'test-token', + 'auth_scheme_preference' => BedrockTokenProvider::BEARER_AUTH + ], + 'ini_config' => [ + 'auth_scheme_preference' => 'aws.auth#sigv4,smithy.api#noAuth' + ] + ]; + + // Client config token takes precedence + yield "{$service}_client_token_precedence" => [ + 'service' => $service, + 'env_vars' => ['AWS_BEARER_TOKEN_BEDROCK' => 'env-token'], + 'client_args' => [ + 'token' => TokenProvider::fromToken(new Token('config-token')) + ], + 'expectations' => [ + 'token' => 'config-token' + ] + ]; + } + } + + /** + * Test that token source is added to user agent header + * + + */ + #[DataProvider('tokenSourceUserAgentProvider')] + public function testTokenSourceInUserAgent( + string $service, + string $operation, + array $args + ): void + { + putenv('AWS_BEARER_TOKEN_BEDROCK=foo-token'); + + $client = $this->getTestClient($service, [ + 'region' => 'us-east-1', + 'version' => 'latest', + 'credentials' => [ + 'key' => 'key', + 'secret' => 'secret' + ] + ]); + + $this->assertEquals( + BedrockTokenProvider::BEARER_AUTH, + $client->getConfig('auth_scheme_preference')[0] + ); + + $client->getHandlerList()->appendSign( + function (callable $handler) { + return function ($command, $request) use ($handler, &$assertionMade) { + $this->assertStringEndsWith( + MetricsBuilder::BEARER_SERVICE_ENV_VARS, + $request->getHeaderLine('user-agent') + ); + + return $handler($command, $request); + }; + }, + 'test-token-source' + ); + + $this->addMockResults($client, [ + new Result([]) + ]); + + $client->{$operation}($args); + } + + public static function tokenSourceUserAgentProvider(): \Generator + { + yield 'bedrock' => [ + 'service' => 'bedrock', + 'operation' => 'listCustomModelDeployments', + 'args' => [] + ]; + + //TODO enable tests when these services support bearer auth +// yield 'bedrock-data-automation' => [ +// 'service' => 'bedrock-data-automation', +// 'operation' => 'listBlueprints', +// 'args' => [] +// ]; +// +// yield 'bedrock-agent-runtime' => [ +// 'service' => 'bedrock-agent-runtime', +// 'operation' => 'listFlowExecutions', +// 'args' => ['flowIdentifier' => 'dummy-flow-id'] +// ]; +// +// yield 'bedrock-data-automation-runtime' => [ +// 'service' => 'bedrock-data-automation-runtime', +// 'operation' => 'listTagsForResource', +// 'args' => ['resourceArn' => 'arn:aws:bedrock:us-east-1:123456789012:dummy'] +// ]; +// +// yield 'bedrock-agent' => [ +// 'service' => 'bedrock-agent', +// 'operation' => 'listAgentActionGroups', +// 'args' => [ +// 'agentId' => 'dummy-agent-id', +// 'agentVersion' => 'dummy-version' +// ] +// ]; + } +} diff --git a/tests/Token/SsoTokenProviderTest.php b/tests/Token/SsoTokenProviderTest.php index 142f283006..e187fafc39 100644 --- a/tests/Token/SsoTokenProviderTest.php +++ b/tests/Token/SsoTokenProviderTest.php @@ -12,9 +12,223 @@ require_once __DIR__ . '/../Token/token_hack.php'; -/** +#[CoversClass(\Aws\Token\SsoTokenProvider::class)] +class SsoTokenProviderTest extends TestCase +{ + use UsesServiceTrait; + + private $home; + private $homedrive; + private $homepath; + + private function clearEnv() { + putenv('AWS_SHARED_CREDENTIALS_FILE'); + putenv('HOME'); + putenv('AWS_PROFILE'); + unset($_SERVER['AWS_SHARED_CREDENTIALS_FILE']); + unset($_SERVER['HOME']); + unset($_SERVER['AWS_PROFILE']); + + $dir = sys_get_temp_dir() . '/.aws'; + + if (!is_dir($dir)) { + mkdir($dir, 0777, true); + } + + return $dir; + } + + public function set_up() + { + $this->home = getenv('HOME'); + $this->homedrive = getenv('HOMEDRIVE'); + $this->homepath = getenv('HOMEPATH'); + } + + public function tear_down() + { + putenv('HOME=' . $this->home); + putenv('HOMEDRIVE=' . $this->homedrive); + putenv('HOMEPATH=' . $this->homepath); + } + + + public function testSsoTokenProviderSuccess() + { + $dir = $this->clearEnv(); + $expiration = time() + 1000; + $ini = << [ + 'accessKeyId' => 'foo', + 'secretAccessKey' => 'assumedSecret', + 'sessionToken' => null, + 'expiration' => $expiration + ], + ]; + $sso = $this->getTestClient('SsoOidc', ['credentials' => false]); + $this->addMockResults($sso, [ + new Result($result) + ]); + + try { + $token = call_user_func(TokenProvider::sso( + 'default', + $configFilename, + ['ssoClient' => $sso] + ))->wait(); + $this->assertSame('token', $token->getToken()); + $this->assertSame(strtotime('2500-12-25T21:30:00Z'), $token->getExpiration()); + $this->assertNull($token->getRegistrationExpiresAt()); + + } finally { + unlink($dir . '/config'); + unlink($tokenLocation); + rmdir(dirname($tokenLocation)); + } + } + + public function testThrowsExceptionWithOnlyStartUrl() + { + $dir = $this->clearEnv(); + $ssoSessionName = "admin"; + $ini = <<expectException(TokenException::class); + $this->expectExceptionMessage("Sso session `{$ssoSessionName}` in {$configFilename} is missing the required property `sso_region`"); + try { + $tokenProvider = new SsoTokenProvider('test', $dir . '/config'); + $tokenProvider()->wait(); + } finally { + unlink($dir . '/config'); + } + } + + public function testThrowsExceptionWithOnlySsoRegion() + { + $dir = $this->clearEnv(); + $ssoSessionName = "admin"; + $ini = <<expectException(TokenException::class); + $this->expectExceptionMessage("Sso session `{$ssoSessionName}` in {$configFilename} is missing the required property `sso_start_url`"); + try { + $tokenProvider = new SsoTokenProvider('test', $dir . '/config'); + $tokenProvider()->wait(); + } finally { + unlink($configFilename); + } + } + + public function testThrowsExceptionWithNonExistingSession() + { + $dir = $this->clearEnv(); + $ini = <<expectException(TokenException::class); + $this->expectExceptionMessage("Sso session `admin` does not exist in {$configFilename}"); + try { + $tokenProvider = new SsoTokenProvider('test', $dir . '/config'); + $tokenProvider()->wait(); + } finally { + unlink($dir . '/config'); + } + } + + public function testSsoSessionUnspecified() + { + $dir = $this->clearEnv(); + $ini = <<wait(); + $this->assertNull($token); + } catch (\Exception $e) { + throw $e; + } finally { + unlink($dir . '/config'); + } + } +} + $token, 'refreshMethod' => function () use ($ssoTokenProvider) { @@ -400,8 +398,7 @@ public static function tokenProviderFailureCases(): array } /** - - */ + */ #[DataProvider('tokenProviderFailureCases')] public function testTokenProviderFailureCases($cachedToken, $expectedException) { @@ -439,7 +436,7 @@ public function testCacheWritesAndReadsCorrectFormat() $token = new Token('test-token', strtotime('+1 hour')); $providerCallCount = 0; - $provider = function() use ($token, &$providerCallCount) { + $provider = function () use ($token, &$providerCallCount) { $providerCallCount++; return Promise\Create::promiseFor($token); }; @@ -462,4 +459,4 @@ public function testCacheWritesAndReadsCorrectFormat() $this->assertEquals(1, $providerCallCount, 'Provider should not be called again'); $this->assertEquals('test-token', $result2->getToken()); } -} +} \ No newline at end of file diff --git a/tests/Token/TokenTest.php b/tests/Token/TokenTest.php index 23918e7a60..597be42b9b 100644 --- a/tests/Token/TokenTest.php +++ b/tests/Token/TokenTest.php @@ -8,9 +8,69 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -/** +#[CoversClass(Token::class)] +class TokenTest extends TestCase +{ + public function testHasGetters() + { + $exp = time() + 500; + $token = new Token('foo', $exp); + $this->assertSame('foo', $token->getToken()); + $this->assertSame($exp, $token->getExpiration()); + $this->assertEquals([ + 'token' => 'foo', + 'expires' => $exp, + 'source' => null + ], $token->toArray()); + } + + public function testDeterminesIfExpired() + { + $this->assertFalse((new Token('foo'))->isExpired()); + $this->assertFalse( + (new Token('foo', time() + 100))->isExpired() + ); + $this->assertTrue( + (new Token('foo', time() - 1000))->isExpired() + ); + } + + public function testSerialization() + { + $token = new Token('token-value'); + $actual = unserialize(serialize($token))->toArray(); + $this->assertEquals([ + 'token' => 'token-value', + 'expires' => null, + 'source' => null + ], $actual); + + $token = new Token('token-value', 10); + $actual = unserialize(serialize($token))->toArray(); + + $this->assertEquals([ + 'token' => 'token-value', + 'expires' => 10, + 'source' => null + ], $actual); + } + + public function testIsInstanceOfIdentity() + { + $token = new Token('token-value'); + $this->assertInstanceOf(BearerTokenIdentity::class, $token); + } +} +waitUntil('TableExists', [ 'TableName' => 'table', ]); + $this->assertTrue(true); } - /** @doesNotPerformAssertions */ + #[CoversNothing] public function testCanCancel() { $client = $this->getTestClient('DynamoDb'); @@ -107,6 +105,7 @@ public function testCanCancel() '@http' => ['debug' => true] ])->promise()->cancel(); sleep(1); + $this->assertTrue(true); } public function testCanWait() diff --git a/tests/WrappedHttpHandlerTest.php b/tests/WrappedHttpHandlerTest.php index 05455a423b..7dae072295 100644 --- a/tests/WrappedHttpHandlerTest.php +++ b/tests/WrappedHttpHandlerTest.php @@ -19,9 +19,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - - */ #[CoversClass(WrappedHttpHandler::class)] class WrappedHttpHandlerTest extends TestCase { From 063e1c3fafd6a21c0bebf41140b435dd1f1623b4 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 03:21:21 -0800 Subject: [PATCH 11/19] fix: code duplication --- tests/Token/BedrockTokenProviderTest.php | 484 ----------------------- tests/Token/SsoTokenProviderTest.php | 217 ---------- tests/Token/TokenTest.php | 63 --- tests/Token/token_hack.php | 26 -- 4 files changed, 790 deletions(-) diff --git a/tests/Token/BedrockTokenProviderTest.php b/tests/Token/BedrockTokenProviderTest.php index 503c7848b3..18a69104c4 100644 --- a/tests/Token/BedrockTokenProviderTest.php +++ b/tests/Token/BedrockTokenProviderTest.php @@ -244,491 +244,7 @@ public function testMemoization(): void * @param $clientArgs * @param $expectations * @param $iniConfig - * - - */ - #[DataProvider('integrationWithClientProvider')] - public function testIntegrationWithClient( - $serviceName, - $envVars, - $clientArgs, - $expectations, - $iniConfig = null - ): void - { - foreach ($envVars as $key => $value) { - putenv("{$key}={$value}"); - } - - if ($iniConfig !== null) { - $this->tempDir = sys_get_temp_dir() . '/bedrock-token-test-' . uniqid() . '/'; - $this->tempConfigFile = $this->tempDir . 'config'; - - if (!is_dir($this->tempDir)) { - mkdir($this->tempDir, 0777, true); - } - - $configContent = "[default]\n"; - foreach ($iniConfig as $key => $value) { - $configContent .= "{$key}={$value}\n"; - } - - file_put_contents($this->tempConfigFile, $configContent); - putenv("AWS_CONFIG_FILE={$this->tempConfigFile}"); - } - - $args = array_merge([ - 'region' => 'us-east-1', - 'version' => 'latest', - 'credentials' => [ - 'key' => 'key', - 'secret' => 'secret' - ] - ], $clientArgs); - - $client = $this->getTestClient($serviceName, $args); - $promise = $client->getToken(); - $token = $promise->wait(); - - // Check token value - if ($expectations['token'] !== null) { - $this->assertEquals($expectations['token'], $token->getToken()); - - if (isset($envVars['AWS_BEARER_TOKEN_BEDROCK']) - && !isset($clientArgs['token']) - ) { - $this->assertEquals( - TokenSource::BEARER_SERVICE_ENV_VARS->value, - $token->getSource() - ); - } else { - $this->assertNull($token->getSource()); - } - } else { - $this->assertNull($token); - } - - // Check auth scheme preference - if (isset($expectations['auth_scheme_preference'])) { - $this->assertEquals( - $expectations['auth_scheme_preference'], - $client->getConfig('auth_scheme_preference')[0] - ); - } - } - - public static function integrationWithClientProvider(): \Generator - { - static $services = [ - 'bedrock', - 'bedrock-agent', - 'bedrock-agent-runtime', - 'bedrock-data-automation', - 'bedrock-data-automation-runtime' - ]; - - foreach ($services as $service) { - // Valid env var - yield "{$service}_valid_env" => [ - 'service' => $service, - 'env_vars' => ['AWS_BEARER_TOKEN_BEDROCK' => 'test-token'], - 'client_args' => [], - 'expectations' => [ - 'token' => 'test-token', - 'auth_scheme_preference' => BedrockTokenProvider::BEARER_AUTH - ] - ]; - - // Similar but invalid env var - yield "{$service}_invalid_env" => [ - 'service' => $service, - 'env_vars' => [ - 'AWS_BEARER_TOKEN_BEDROCKS' => 'wrong-token', - 'AWS_BEARER_TOKEN_BEDROCK_AGENT' => 'wrong-token' - ], - 'client_args' => [], - 'expectations' => [ - 'token' => null - ] - ]; - - // AWS_AUTH_SCHEME_PREFERENCE set - yield "{$service}_auth_scheme_env" => [ - 'service' => $service, - 'env_vars' => [ - 'AWS_BEARER_TOKEN_BEDROCK' => 'test-token', - 'AWS_AUTH_SCHEME_PREFERENCE' => 'aws.auth#sigv4,smithy.api#noAuth' - ], - 'client_args' => [], - 'expectations' => [ - 'token' => 'test-token', - 'auth_scheme_preference' => BedrockTokenProvider::BEARER_AUTH - ] - ]; - - // auth_scheme_preference from INI file - yield "{$service}_auth_scheme_ini" => [ - 'service' => $service, - 'env_vars' => ['AWS_BEARER_TOKEN_BEDROCK' => 'test-token'], - 'client_args' => [], - 'expectations' => [ - 'token' => 'test-token', - 'auth_scheme_preference' => BedrockTokenProvider::BEARER_AUTH - ], - 'ini_config' => [ - 'auth_scheme_preference' => 'aws.auth#sigv4,smithy.api#noAuth' - ] - ]; - - // Client config token takes precedence - yield "{$service}_client_token_precedence" => [ - 'service' => $service, - 'env_vars' => ['AWS_BEARER_TOKEN_BEDROCK' => 'env-token'], - 'client_args' => [ - 'token' => TokenProvider::fromToken(new Token('config-token')) - ], - 'expectations' => [ - 'token' => 'config-token' - ] - ]; - } - } - - /** - * Test that token source is added to user agent header - * - - */ - #[DataProvider('tokenSourceUserAgentProvider')] - public function testTokenSourceInUserAgent( - string $service, - string $operation, - array $args - ): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK=foo-token'); - - $client = $this->getTestClient($service, [ - 'region' => 'us-east-1', - 'version' => 'latest', - 'credentials' => [ - 'key' => 'key', - 'secret' => 'secret' - ] - ]); - - $this->assertEquals( - BedrockTokenProvider::BEARER_AUTH, - $client->getConfig('auth_scheme_preference')[0] - ); - - $client->getHandlerList()->appendSign( - function (callable $handler) { - return function ($command, $request) use ($handler, &$assertionMade) { - $this->assertStringEndsWith( - MetricsBuilder::BEARER_SERVICE_ENV_VARS, - $request->getHeaderLine('user-agent') - ); - - return $handler($command, $request); - }; - }, - 'test-token-source' - ); - - $this->addMockResults($client, [ - new Result([]) - ]); - - $client->{$operation}($args); - } - - public static function tokenSourceUserAgentProvider(): \Generator - { - yield 'bedrock' => [ - 'service' => 'bedrock', - 'operation' => 'listCustomModelDeployments', - 'args' => [] - ]; - - //TODO enable tests when these services support bearer auth -// yield 'bedrock-data-automation' => [ -// 'service' => 'bedrock-data-automation', -// 'operation' => 'listBlueprints', -// 'args' => [] -// ]; -// -// yield 'bedrock-agent-runtime' => [ -// 'service' => 'bedrock-agent-runtime', -// 'operation' => 'listFlowExecutions', -// 'args' => ['flowIdentifier' => 'dummy-flow-id'] -// ]; -// -// yield 'bedrock-data-automation-runtime' => [ -// 'service' => 'bedrock-data-automation-runtime', -// 'operation' => 'listTagsForResource', -// 'args' => ['resourceArn' => 'arn:aws:bedrock:us-east-1:123456789012:dummy'] -// ]; -// -// yield 'bedrock-agent' => [ -// 'service' => 'bedrock-agent', -// 'operation' => 'listAgentActionGroups', -// 'args' => [ -// 'agentId' => 'dummy-agent-id', -// 'agentVersion' => 'dummy-version' -// ] -// ]; - } -} -originalEnv = [ - 'AWS_BEARER_TOKEN_BEDROCK' => getenv('AWS_BEARER_TOKEN_BEDROCK'), - 'AWS_BEARER_TOKEN_BEDROCKS' => getenv('AWS_BEARER_TOKEN_BEDROCKS'), - 'AWS_BEARER_TOKEN_BEDROCK_AGENT' => getenv('AWS_BEARER_TOKEN_BEDROCK_AGENT'), - 'AWS_AUTH_SCHEME_PREFERENCE' => getenv('AWS_AUTH_SCHEME_PREFERENCE'), - 'AWS_CONFIG_FILE' => getenv('AWS_CONFIG_FILE') - ]; - } - - protected function tearDown(): void - { - parent::tearDown(); - - // Restore original environment values - foreach ($this->originalEnv as $key => $value) { - if ($value !== false) { - putenv("{$key}={$value}"); - } else { - putenv("{$key}="); - } - } - - // Clean up temp files - if ($this->tempConfigFile && file_exists($this->tempConfigFile)) { - unlink($this->tempConfigFile); - } - if ($this->tempDir && is_dir($this->tempDir)) { - rmdir($this->tempDir); - } - - $this->tempConfigFile = null; - $this->tempDir = null; - } - - /** - * Test defaultProvider creates a memoized chain with env provider - */ - public function testDefaultProvider(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK=test-token-123'); - - $provider = BedrockTokenProvider::defaultProvider(); - - $promise = $provider(); - $this->assertInstanceOf(Promise\PromiseInterface::class, $promise); - - $token = $promise->wait(); - $this->assertInstanceOf(TokenInterface::class, $token); - $this->assertEquals('test-token-123', $token->getToken()); - $this->assertNull($token->getExpiration()); - $this->assertFalse($token->isExpired()); - } - - /** - * Test defaultProvider when environment variable is not set - */ - public function testDefaultProviderNoEnvVar(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK'); - - $provider = BedrockTokenProvider::defaultProvider(); - $promise = $provider(); - - // The memoize wrapper converts rejections to null - $result = $promise->wait(); - $this->assertNull($result); - } - - /** - * Test env() method creates proper provider - */ - public function testEnvMethod(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK=env-test-token'); - - $provider = BedrockTokenProvider::env('bearer_token_bedrock'); - $promise = $provider(); - $token = $promise->wait(); - - $this->assertInstanceOf(Token::class, $token); - $this->assertEquals('env-test-token', $token->getToken()); - $this->assertNull($token->getExpiration()); - } - - /** - * Test env() method when environment variable is empty - */ - public function testEnvMethodEmptyValue(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK='); - - $provider = BedrockTokenProvider::env('bearer_token_bedrock'); - $promise = $provider(); - - try { - $promise->wait(); - $this->fail('Expected TokenException was not thrown'); - } catch (TokenException $e) { - $this->assertStringContainsString( - 'No token found in environment variable AWS_BEARER_TOKEN_BEDROCK', - $e->getMessage() - ); - } - } - - /** - * Test fromTokenValue() method */ - public function testFromTokenValue(): void - { - $tokenValue = 'static-token-value'; - $provider = BedrockTokenProvider::fromTokenValue($tokenValue); - $promise = $provider(); - $token = $promise->wait(); - - $this->assertInstanceOf(Token::class, $token); - $this->assertEquals($tokenValue, $token->getToken()); - $this->assertNull($token->getExpiration()); - $this->assertFalse($token->isExpired()); - } - - /** - * Test createIfAvailable() when conditions are met - */ - public function testCreateIfAvailableSuccess(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK=bedrock-token-456'); - - $args = ['config' => ['auth_scheme_preference' => ['some-other-auth']]]; - - $provider = BedrockTokenProvider::createIfAvailable($args); - - $this->assertNotNull($provider); - // Check auth_scheme_preference was modified - $this->assertCount(2, $args['config']['auth_scheme_preference']); - $this->assertEquals( - BedrockTokenProvider::BEARER_AUTH, - $args['config']['auth_scheme_preference'][0] - ); - $this->assertEquals( - 'some-other-auth', - $args['config']['auth_scheme_preference'][1] - ); - - // Verify the provider works - $promise = $provider(); - $token = $promise->wait(); - $this->assertEquals('bedrock-token-456', $token->getToken()); - } - - /** - * Test createIfAvailable() when auth_scheme_preference is not set - */ - public function testCreateIfAvailableNoAuthSchemePreference(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK=bedrock-token-789'); - - $args = [ - 'config' => ['signing_name' => 'bedrock'] - ]; - $provider = BedrockTokenProvider::createIfAvailable($args); - - $this->assertNotNull($provider); - - // Check auth_scheme_preference was created - $this->assertArrayHasKey('auth_scheme_preference', $args['config']); - $this->assertCount(1, $args['config']['auth_scheme_preference']); - $this->assertEquals( - BedrockTokenProvider::BEARER_AUTH, - $args['config']['auth_scheme_preference'][0] - ); - } - - /** - * Test createIfAvailable() when token is not available - */ - public function testCreateIfAvailableNoToken(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK'); - - $args = []; - $provider = BedrockTokenProvider::createIfAvailable($args); - - $this->assertNull($provider); - $this->assertArrayNotHasKey('auth_scheme_preference', $args); - } - - /** - * Test memoization behavior - token should be cached - */ - public function testMemoization(): void - { - putenv('AWS_BEARER_TOKEN_BEDROCK=memoized-token'); - - $provider = BedrockTokenProvider::defaultProvider(); - - // First call - $token1 = $provider()->wait(); - - // Change the environment variable - putenv('AWS_BEARER_TOKEN_BEDROCK=different-token'); - - // Second call should return the same token due to memoization - $token2 = $provider()->wait(); - - $this->assertEquals($token1->getToken(), $token2->getToken()); - $this->assertEquals('memoized-token', $token2->getToken()); - } - - /** - * Test integration with Bedrock Clients - * - * @param $serviceName - * @param $envVars - * @param $clientArgs - * @param $expectations - * @param $iniConfig - * - - */ #[DataProvider('integrationWithClientProvider')] public function testIntegrationWithClient( $serviceName, diff --git a/tests/Token/SsoTokenProviderTest.php b/tests/Token/SsoTokenProviderTest.php index e187fafc39..1374bc5b01 100644 --- a/tests/Token/SsoTokenProviderTest.php +++ b/tests/Token/SsoTokenProviderTest.php @@ -215,220 +215,3 @@ public function testSsoSessionUnspecified() } } } -home = getenv('HOME'); - $this->homedrive = getenv('HOMEDRIVE'); - $this->homepath = getenv('HOMEPATH'); - } - - public function tear_down() - { - putenv('HOME=' . $this->home); - putenv('HOMEDRIVE=' . $this->homedrive); - putenv('HOMEPATH=' . $this->homepath); - } - - - public function testSsoTokenProviderSuccess() - { - $dir = $this->clearEnv(); - $expiration = time() + 1000; - $ini = << [ - 'accessKeyId' => 'foo', - 'secretAccessKey' => 'assumedSecret', - 'sessionToken' => null, - 'expiration' => $expiration - ], - ]; - $sso = $this->getTestClient('SsoOidc', ['credentials' => false]); - $this->addMockResults($sso, [ - new Result($result) - ]); - - try { - $token = call_user_func(TokenProvider::sso( - 'default', - $configFilename, - ['ssoClient' => $sso] - ))->wait(); - $this->assertSame('token', $token->getToken()); - $this->assertSame(strtotime('2500-12-25T21:30:00Z'), $token->getExpiration()); - $this->assertNull($token->getRegistrationExpiresAt()); - - } finally { - unlink($dir . '/config'); - unlink($tokenLocation); - rmdir(dirname($tokenLocation)); - } - } - - public function testThrowsExceptionWithOnlyStartUrl() - { - $dir = $this->clearEnv(); - $ssoSessionName = "admin"; - $ini = <<expectException(TokenException::class); - $this->expectExceptionMessage("Sso session `{$ssoSessionName}` in {$configFilename} is missing the required property `sso_region`"); - try { - $tokenProvider = new SsoTokenProvider('test', $dir . '/config'); - $tokenProvider()->wait(); - } finally { - unlink($dir . '/config'); - } - } - - public function testThrowsExceptionWithOnlySsoRegion() - { - $dir = $this->clearEnv(); - $ssoSessionName = "admin"; - $ini = <<expectException(TokenException::class); - $this->expectExceptionMessage("Sso session `{$ssoSessionName}` in {$configFilename} is missing the required property `sso_start_url`"); - try { - $tokenProvider = new SsoTokenProvider('test', $dir . '/config'); - $tokenProvider()->wait(); - } finally { - unlink($configFilename); - } - } - - public function testThrowsExceptionWithNonExistingSession() - { - $dir = $this->clearEnv(); - $ini = <<expectException(TokenException::class); - $this->expectExceptionMessage("Sso session `admin` does not exist in {$configFilename}"); - try { - $tokenProvider = new SsoTokenProvider('test', $dir . '/config'); - $tokenProvider()->wait(); - } finally { - unlink($dir . '/config'); - } - } - - public function testSsoSessionUnspecified() - { - $dir = $this->clearEnv(); - $ini = <<wait(); - $this->assertNull($token); - } catch (\Exception $e) { - throw $e; - } finally { - unlink($dir . '/config'); - } - } -} diff --git a/tests/Token/TokenTest.php b/tests/Token/TokenTest.php index 597be42b9b..b72ada235f 100644 --- a/tests/Token/TokenTest.php +++ b/tests/Token/TokenTest.php @@ -61,66 +61,3 @@ public function testIsInstanceOfIdentity() $this->assertInstanceOf(BearerTokenIdentity::class, $token); } } -assertSame('foo', $token->getToken()); - $this->assertSame($exp, $token->getExpiration()); - $this->assertEquals([ - 'token' => 'foo', - 'expires' => $exp, - 'source' => null - ], $token->toArray()); - } - - public function testDeterminesIfExpired() - { - $this->assertFalse((new Token('foo'))->isExpired()); - $this->assertFalse( - (new Token('foo', time() + 100))->isExpired() - ); - $this->assertTrue( - (new Token('foo', time() - 1000))->isExpired() - ); - } - - public function testSerialization() - { - $token = new Token('token-value'); - $actual = unserialize(serialize($token))->toArray(); - $this->assertEquals([ - 'token' => 'token-value', - 'expires' => null, - 'source' => null - ], $actual); - - $token = new Token('token-value', 10); - $actual = unserialize(serialize($token))->toArray(); - - $this->assertEquals([ - 'token' => 'token-value', - 'expires' => 10, - 'source' => null - ], $actual); - } - - public function testIsInstanceOfIdentity() - { - $token = new Token('token-value'); - $this->assertInstanceOf(BearerTokenIdentity::class, $token); - } -} diff --git a/tests/Token/token_hack.php b/tests/Token/token_hack.php index 242461cf9e..375b84267d 100644 --- a/tests/Token/token_hack.php +++ b/tests/Token/token_hack.php @@ -24,29 +24,3 @@ function strtotime($string) return \strtotime($string); } - Date: Fri, 30 Jan 2026 11:40:47 -0800 Subject: [PATCH 12/19] chore: bulk tests fix --- tests/AbstractConfigurationProviderTest.php | 3 +- tests/Api/ApiProviderTest.php | 6 +- tests/Api/DateTimeResultTest.php | 9 +- .../ErrorParser/JsonRpcErrorParserTest.php | 13 +- .../ErrorParser/RestJsonErrorParserTest.php | 13 +- tests/Api/ErrorParser/XmlErrorParserTest.php | 4 +- tests/Api/ListShapeTest.php | 4 +- tests/Api/MapShapeTest.php | 4 +- tests/Api/OperationTest.php | 4 +- tests/Api/Parser/ComplianceTest.php | 36 ++-- .../Api/Parser/Crc32ValidatingParserTest.php | 2 +- .../DecodingEventStreamIteratorTest.php | 3 - tests/Api/Parser/EventParsingIteratorTest.php | 23 +-- .../Parser/Exception/ParserExceptionTest.php | 2 +- tests/Api/Parser/JsonParserTest.php | 18 +- tests/Api/Parser/JsonRpcParserTest.php | 51 ++--- ...eStreamDecodingEventStreamIteratorTest.php | 16 +- tests/Api/Parser/RestJsonParserTest.php | 9 +- tests/Api/Parser/RestXmlParserTest.php | 2 +- tests/Api/Parser/XmlParserTest.php | 18 +- tests/Api/Serializer/ComplianceTest.php | 32 +-- tests/Api/Serializer/JsonBodyTest.php | 15 +- .../Api/Serializer/RestJsonSerializerTest.php | 39 +--- .../Api/Serializer/RestXmlSerializerTest.php | 30 +-- tests/Api/ServiceTest.php | 30 +-- tests/Api/ShapeMapTest.php | 2 +- tests/Api/ShapeTest.php | 1 - tests/Api/StructureShapeTest.php | 4 +- tests/Api/SupportedProtocolsTest.php | 8 +- tests/Api/TimestampShapeTest.php | 7 +- tests/Api/ValidatorTest.php | 6 +- tests/Arn/AccessPointArnTest.php | 19 +- tests/Arn/ArnParserTest.php | 18 +- tests/Arn/ArnTest.php | 20 +- tests/Arn/S3/AccessPointArnTest.php | 10 +- tests/Arn/S3/OutpostsAccessPointArnTest.php | 19 +- tests/Arn/S3/OutpostsBucketArnTest.php | 19 +- tests/Auth/AuthSchemeResolverTest.php | 10 +- tests/Auth/AuthSelectionMiddlewareTest.php | 46 +---- tests/AwsClientTest.php | 21 +- .../Build/Changelog/ChangelogBuilderTest.php | 2 +- tests/Build/Changelog/CurrentChangesTest.php | 1 + tests/Build/Docs/CodeSnippetGeneratorTest.php | 14 +- tests/ClientResolverTest.php | 2 +- ...ApiCallAttemptMonitoringMiddlewareTest.php | 12 +- .../ApiCallMonitoringMiddlewareTest.php | 11 +- .../ConfigurationProviderTest.php | 13 +- .../ConfigurationTest.php | 4 +- tests/CloudFront/CloudFrontClientTest.php | 1 + tests/CloudFront/CookieSignerTest.php | 6 +- tests/CloudFront/SignerTest.php | 21 +- tests/CloudFront/UrlSignerTest.php | 8 +- tests/CloudTrail/LogFileIteratorTest.php | 2 +- tests/CloudTrail/LogFileReaderTest.php | 5 +- .../CloudWatchLogsClientTest.php | 2 + .../CognitoIdentityProviderTest.php | 12 +- tests/CognitoSync/CognitoSyncClientTest.php | 3 + tests/CommandPoolTest.php | 26 +-- tests/CommandTest.php | 3 +- tests/ConfigurationResolverTest.php | 86 +++++--- .../AssumeRoleCredentialProviderTest.php | 13 +- ...eWithWebIdentityCredentialProviderTest.php | 8 - tests/Credentials/CredentialsTest.php | 2 +- tests/Credentials/CredentialsUtilsTest.php | 11 +- .../Credentials/EcsCredentialProviderTest.php | 20 +- .../LoginCredentialProviderTest.php | 9 - tests/Crypto/AesDecryptingStreamTest.php | 32 +-- tests/Crypto/AesEncryptingStreamTest.php | 51 +---- tests/Crypto/AesGcmDecryptingStreamTest.php | 14 +- tests/Crypto/AesGcmEncryptingStreamTest.php | 13 +- tests/Crypto/AlgorithmSuiteTest.php | 19 +- tests/Crypto/Cipher/CbcTest.php | 4 +- .../EncryptionDecryptionTraitV3Test.php | 22 +- tests/Crypto/HkdfKatTest.php | 4 +- tests/Crypto/KmsMaterialsProviderV2Test.php | 2 +- tests/Crypto/KmsMaterialsProviderV3Test.php | 2 +- tests/Crypto/MetadataEnvelopeTest.php | 12 +- tests/Crypto/UsesCryptoParamsTrait.php | 2 +- tests/Crypto/UsesMetadataEnvelopeTrait.php | 71 +++---- tests/DSQL/AuthTokenGeneratorTest.php | 41 +--- .../ConfigurationProviderTest.php | 10 +- tests/DefaultsMode/ConfigurationTest.php | 2 +- tests/DocDb/DocDbClientTest.php | 12 +- tests/DoctrineCacheAdapterTest.php | 2 + tests/DynamoDb/DynamoDbClientTest.php | 14 +- tests/DynamoDb/MarshalerTest.php | 5 +- tests/DynamoDb/WriteRequestBatchTest.php | 5 +- tests/Ec2/Ec2ClientTest.php | 1 - .../ElasticLoadBalancingV2ClientTest.php | 1 + .../PartitionEndpointProviderTest.php | 19 +- tests/Endpoint/PartitionTest.php | 125 +----------- .../Endpoint/PatternEndpointProviderTest.php | 5 +- .../ConfigurationProviderTest.php | 2 - .../ConfigurationTest.php | 10 +- .../ConfigurationProviderTest.php | 1 - .../UseFipsEndpoint/ConfigurationTest.php | 10 +- .../ConfigurationProviderTest.php | 14 +- tests/EndpointDiscovery/ConfigurationTest.php | 3 +- .../EndpointDiscoveryMiddlewareTest.php | 35 +--- tests/EndpointDiscovery/EndpointListTest.php | 2 +- tests/EndpointParameterMiddlewareTest.php | 5 +- .../EndpointDefinitionProviderTest.php | 13 +- tests/EndpointV2/EndpointProviderV2Test.php | 14 +- tests/EndpointV2/EndpointV2MiddlewareTest.php | 29 +-- .../EndpointV2SerializerTraitTest.php | 2 +- tests/EndpointV2/RuleCreatorTest.php | 15 +- tests/EndpointV2/RulesetEndpointTest.php | 2 +- tests/EndpointV2/RulesetParameterTest.php | 15 +- .../EndpointV2/RulesetStandardLibraryTest.php | 95 +++------ tests/EventBridge/EventBridgeClientTest.php | 35 +--- tests/Exception/AwsExceptionTest.php | 3 - .../MultipartUploadExceptionTest.php | 5 +- tests/FunctionsTest.php | 50 ++--- tests/Glacier/MultipartUploaderTest.php | 5 +- tests/Handler/GuzzleV6/HandlerTest.php | 3 + tests/HandlerListTest.php | 23 ++- tests/HasMonitoringEventsTraitTest.php | 7 +- tests/HistoryTest.php | 2 +- .../S3ExpressIdentityProviderTest.php | 5 +- tests/InputValidationMiddlewareTest.php | 23 +-- tests/Integ/GuzzleStreamHandlerTest.php | 2 + tests/Lambda/LambdaClientTest.php | 6 +- tests/MetricsBuilderTest.php | 15 +- tests/MiddlewareTest.php | 7 - tests/MultiRegionClientTest.php | 18 +- tests/Multipart/AbstractUploaderTest.php | 10 +- tests/Multipart/UploadStateTest.php | 18 +- tests/Neptune/NeptuneClientTest.php | 12 +- tests/PresignUrlMiddlewareTest.php | 16 +- tests/Psr16CacheAdapterTest.php | 24 +-- tests/PsrCacheAdapterTest.php | 21 +- tests/QueryCompatibleInputMiddlewareTest.php | 15 -- tests/Rds/AuthTokenGeneratorTest.php | 14 +- tests/Rds/RdsClientTest.php | 14 +- .../RequestCompressionMiddlewareTest.php | 66 ++---- tests/ResultPaginatorTest.php | 15 +- tests/Retry/ConfigurationProviderTest.php | 9 +- tests/Retry/ConfigurationTest.php | 2 +- tests/Retry/QuotaManagerTest.php | 2 +- tests/Retry/RateLimiterTest.php | 10 +- tests/RetryMiddlewareTest.php | 6 +- tests/RetryMiddlewareV2Test.php | 15 +- tests/S3/AmbiguousSuccessParserTest.php | 17 +- tests/S3/ApplyChecksumMiddlewareTest.php | 10 +- tests/S3/BatchDeleteTest.php | 6 +- tests/S3/BucketEndpointArnMiddlewareTest.php | 25 +-- tests/S3/BucketEndpointMiddlewareTest.php | 6 +- .../S3/Crypto/HeadersMetadataStrategyTest.php | 6 - .../InstructionFileMetadataStrategyTest.php | 21 +- tests/S3/Crypto/S3EncryptionClientTest.php | 22 +- tests/S3/Crypto/S3EncryptionClientV2Test.php | 20 +- tests/S3/Crypto/S3EncryptionClientV3Test.php | 191 +++++++++--------- .../S3EncryptionMultipartUploaderTest.php | 20 +- .../S3EncryptionMultipartUploaderV2Test.php | 20 +- tests/S3/GetBucketLocationParserTest.php | 5 +- tests/S3/MultipartCopyTest.php | 7 +- tests/S3/MultipartUploaderTest.php | 18 +- tests/S3/ObjectCopierTest.php | 25 +-- tests/S3/ObjectUploaderTest.php | 24 +-- .../GetBucketLocationResultMutatorTest.php | 9 +- tests/S3/Parser/S3ParserTest.php | 17 +- ...idateResponseChecksumResultMutatorTest.php | 15 +- tests/S3/PermanentRedirectMiddlewareTest.php | 4 +- tests/S3/PostObjectTest.php | 9 +- tests/S3/PostObjectV4Test.php | 18 +- .../ConfigurationProviderTest.php | 9 +- .../S3/RegionalEndpoint/ConfigurationTest.php | 6 +- .../RetryableMalformedResponseParserTest.php | 5 +- tests/S3/S3EndpointMiddlewareTest.php | 71 +------ tests/S3/S3MultiRegionClientTest.php | 13 +- .../AbstractMultipartDownloaderTest.php | 2 + tests/S3/S3Transfer/MultipartUploaderTest.php | 91 +-------- .../PartGetMultipartDownloaderTest.php | 17 +- .../AbstractProgressBarFormatTest.php | 15 +- .../Progress/ConsoleProgressBarTest.php | 8 +- .../Progress/MultiProgressTrackerTest.php | 16 +- .../Progress/SingleProgressTrackerTest.php | 28 +-- .../Progress/TransferListenerNotifierTest.php | 8 +- .../Progress/TransferProgressSnapshotTest.php | 17 +- .../RangeGetMultipartDownloaderTest.php | 11 +- tests/S3/S3UriParserTest.php | 5 +- tests/S3/SSECMiddlewareTest.php | 10 +- tests/S3/StreamWrapperPathStyleTest.php | 9 +- tests/S3/StreamWrapperTest.php | 14 +- tests/S3/StreamWrapperV2ExistenceTest.php | 13 +- tests/S3/TransferTest.php | 16 +- .../ConfigurationProviderTest.php | 7 +- tests/S3/UseArnRegion/ConfigurationTest.php | 10 +- .../S3/ValidateResponseChecksumParserTest.php | 5 +- tests/S3Control/EndpointArnMiddlewareTest.php | 29 +-- tests/Script/ComposerTest.php | 24 +-- tests/SdkTest.php | 1 - tests/Ses/SesClientTest.php | 2 + tests/Signature/DpopSignatureTest.php | 15 -- tests/Signature/S3SignatureV4Test.php | 1 + tests/Signature/SignatureProviderTest.php | 5 +- tests/Signature/SignatureV4Test.php | 22 +- tests/Sqs/SqsClientTest.php | 1 + tests/StreamRequestPayloadMiddlewareTest.php | 10 +- .../ConfigurationProviderTest.php | 12 +- .../RegionalEndpoints/ConfigurationTest.php | 2 +- tests/Sts/StsClientTest.php | 14 -- tests/Token/BearerTokenAuthorizationTest.php | 26 +-- tests/Token/BedrockTokenProviderTest.php | 14 +- tests/Token/SsoTokenProviderTest.php | 4 +- tests/Token/TokenProviderTest.php | 8 +- tests/TraceMiddlewareTest.php | 9 +- tests/WaiterTest.php | 11 +- tests/WrappedHttpHandlerTest.php | 10 - 209 files changed, 906 insertions(+), 2363 deletions(-) diff --git a/tests/AbstractConfigurationProviderTest.php b/tests/AbstractConfigurationProviderTest.php index d130c6c02b..32c13f523c 100644 --- a/tests/AbstractConfigurationProviderTest.php +++ b/tests/AbstractConfigurationProviderTest.php @@ -2,6 +2,7 @@ namespace Aws\Test; +use Aws\AbstractConfigurationProvider; use Aws\LruArrayCache; use Aws\Result; use Aws\ResultInterface; @@ -10,7 +11,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\AbstractConfigurationProvider::class)] +#[CoversClass(AbstractConfigurationProvider::class)] class AbstractConfigurationProviderTest extends TestCase { /** @var MockObject */ diff --git a/tests/Api/ApiProviderTest.php b/tests/Api/ApiProviderTest.php index 1737c99c7e..5212137986 100644 --- a/tests/Api/ApiProviderTest.php +++ b/tests/Api/ApiProviderTest.php @@ -24,9 +24,9 @@ private function getTestApiProvider($useManifest = true) public function testCanResolveProvider() { - $p = function ($a, $b, $c) {return []; - - $this->assertTrue(true);}; + $p = function ($a, $b, $c) { + return []; + }; $result = ['metadata'=> ['serviceIdentifier' => 's']]; $this->assertEquals($result, ApiProvider::resolve($p, 't', 's', 'v')); diff --git a/tests/Api/DateTimeResultTest.php b/tests/Api/DateTimeResultTest.php index 7bca1a54ce..53eba9cb8c 100644 --- a/tests/Api/DateTimeResultTest.php +++ b/tests/Api/DateTimeResultTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\DateTimeResult::class)] +#[CoversClass(DateTimeResult::class)] class DateTimeResultTest extends TestCase { public function testCreatesFromEpoch() @@ -50,11 +50,6 @@ public function testJsonSerialzesAsIso8601() $this->assertSame('"' . gmdate('c', $t). '"', json_encode($d)); } - /** - * @return void - * - - */ #[DataProvider('nanosecondPrecisionProvider')] public function testIso8601NanosecondPrecision($timestamp, $expected) { @@ -62,7 +57,7 @@ public function testIso8601NanosecondPrecision($timestamp, $expected) $this->assertEquals($expected, (string) $parsed); } - public static function nanosecondPrecisionProvider() + public static function nanosecondPrecisionProvider(): array { return [ ['2024-07-31T19:05:47.1234567Z', '2024-07-31T19:05:47+00:00'], diff --git a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php index 91417642ec..97048c801d 100644 --- a/tests/Api/ErrorParser/JsonRpcErrorParserTest.php +++ b/tests/Api/ErrorParser/JsonRpcErrorParserTest.php @@ -2,26 +2,19 @@ namespace Aws\Test\Api\ErrorParser; use Aws\Api\ErrorParser\JsonRpcErrorParser; +use Aws\Api\ErrorParser\JsonParserTrait; use Aws\Test\TestServiceTrait; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\ErrorParser\JsonRpcErrorParser::class)] -#[CoversClass(\Aws\Api\ErrorParser\JsonParserTrait::class)] +#[CoversClass(JsonRpcErrorParser::class)] +#[CoversClass(JsonParserTrait::class)] class JsonRpcErrorParserTest extends TestCase { use TestServiceTrait; - /** - * - * @param string $response - * @param string|null $commandName - * @param bool $parserWithService - * @param array $expected - - */ #[DataProvider('errorResponsesProvider')] public function testParsesClientErrorResponses( string $response, diff --git a/tests/Api/ErrorParser/RestJsonErrorParserTest.php b/tests/Api/ErrorParser/RestJsonErrorParserTest.php index a7616b9329..3ab86c6371 100644 --- a/tests/Api/ErrorParser/RestJsonErrorParserTest.php +++ b/tests/Api/ErrorParser/RestJsonErrorParserTest.php @@ -2,26 +2,19 @@ namespace Aws\Test\Api\ErrorParser; use Aws\Api\ErrorParser\RestJsonErrorParser; +use Aws\Api\ErrorParser\JsonParserTrait; use Aws\Test\TestServiceTrait; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\ErrorParser\RestJsonErrorParser::class)] -#[CoversClass(\Aws\Api\ErrorParser\JsonParserTrait::class)] +#[CoversClass(RestJsonErrorParser::class)] +#[CoversClass(JsonParserTrait::class)] class RestJsonErrorParserTest extends TestCase { use TestServiceTrait; - /** - * - * @param string $response - * @param string|null $commandName - * @param bool $parserWithService - * @param array $expected - - */ #[DataProvider('errorResponsesProvider')] public function testParsesClientErrorResponses( string $response, diff --git a/tests/Api/ErrorParser/XmlErrorParserTest.php b/tests/Api/ErrorParser/XmlErrorParserTest.php index 90c3a9bc33..7c86b40b13 100644 --- a/tests/Api/ErrorParser/XmlErrorParserTest.php +++ b/tests/Api/ErrorParser/XmlErrorParserTest.php @@ -16,7 +16,6 @@ class XmlErrorParserTest extends TestCase use TestServiceTrait; /** - * * @param string $response * @param string $protocol * @param string $parser @@ -24,8 +23,7 @@ class XmlErrorParserTest extends TestCase * @param string|null $expectedParsedType * * @throws \Exception - - */ + */ #[DataProvider('errorResponsesProvider')] public function testParsesClientErrorResponses( string $response, diff --git a/tests/Api/ListShapeTest.php b/tests/Api/ListShapeTest.php index b4bf02df95..ff46e07fe7 100644 --- a/tests/Api/ListShapeTest.php +++ b/tests/Api/ListShapeTest.php @@ -4,10 +4,10 @@ use Aws\Api\Shape; use Aws\Api\ShapeMap; use Aws\Api\ListShape; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\ListShape::class)] +#[CoversClass(ListShape::class)] class ListShapeTest extends TestCase { public function testReturnsMember() diff --git a/tests/Api/MapShapeTest.php b/tests/Api/MapShapeTest.php index b4699ed12b..f78fea4e2d 100644 --- a/tests/Api/MapShapeTest.php +++ b/tests/Api/MapShapeTest.php @@ -4,10 +4,10 @@ use Aws\Api\Shape; use Aws\Api\ShapeMap; use Aws\Api\MapShape; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\MapShape::class)] +#[CoversClass(MapShape::class)] class MapShapeTest extends TestCase { public function testReturnsValue() diff --git a/tests/Api/OperationTest.php b/tests/Api/OperationTest.php index f55f3ed79c..aa6e505c84 100644 --- a/tests/Api/OperationTest.php +++ b/tests/Api/OperationTest.php @@ -4,10 +4,10 @@ use Aws\Api\Shape; use Aws\Api\ShapeMap; use Aws\Api\Operation; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\Operation::class)] +#[CoversClass(Operation::class)] class OperationTest extends TestCase { public function testCreatesDefaultMethodAndUri() diff --git a/tests/Api/Parser/ComplianceTest.php b/tests/Api/Parser/ComplianceTest.php index 6a766c2653..f6aae88950 100644 --- a/tests/Api/Parser/ComplianceTest.php +++ b/tests/Api/Parser/ComplianceTest.php @@ -13,15 +13,23 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use Aws\Api\Parser\AbstractParser; +use Aws\Api\Parser\AbstractRestParser; +use Aws\Api\Parser\JsonRpcParser; +use Aws\Api\Parser\JsonParser; +use Aws\Api\Parser\RestJsonParser; +use Aws\Api\Parser\RestXmlParser; +use Aws\Api\Parser\QueryParser; +use Aws\Api\Parser\XmlParser; -#[CoversClass(\Aws\Api\Parser\AbstractParser::class)] -#[CoversClass(\Aws\Api\Parser\AbstractRestParser::class)] -#[CoversClass(\Aws\Api\Parser\JsonRpcParser::class)] -#[CoversClass(\Aws\Api\Parser\JsonParser::class)] -#[CoversClass(\Aws\Api\Parser\RestJsonParser::class)] -#[CoversClass(\Aws\Api\Parser\RestXmlParser::class)] -#[CoversClass(\Aws\Api\Parser\QueryParser::class)] -#[CoversClass(\Aws\Api\Parser\XmlParser::class)] +#[CoversClass(AbstractParser::class)] +#[CoversClass(AbstractRestParser::class)] +#[CoversClass(JsonRpcParser::class)] +#[CoversClass(JsonParser::class)] +#[CoversClass(RestJsonParser::class)] +#[CoversClass(RestXmlParser::class)] +#[CoversClass(QueryParser::class)] +#[CoversClass(XmlParser::class)] class ComplianceTest extends TestCase { use UsesServiceTrait; @@ -104,17 +112,6 @@ public static function caseProvider(): \Generator } } - /** - * - * @param $about - * @param Service $service - * @param $name - * @param array $expectedResult - * @param $res - * @param string|null $errorCode - * @param string|null $errorMessage - - */ #[DataProvider('caseProvider')] public function testPassesComplianceTest( string $about, @@ -151,7 +148,6 @@ public function testPassesComplianceTest( $this->fixTimestamps($result, $service->getOperation($name)->getOutput()); $this->assertEquals($expectedResult, $result); - $this->assertTrue(true); } private function fixTimestamps(mixed &$data, Shape $shape): void diff --git a/tests/Api/Parser/Crc32ValidatingParserTest.php b/tests/Api/Parser/Crc32ValidatingParserTest.php index 676a54a1ef..29c817bc5e 100644 --- a/tests/Api/Parser/Crc32ValidatingParserTest.php +++ b/tests/Api/Parser/Crc32ValidatingParserTest.php @@ -9,7 +9,7 @@ use Aws\Exception\AwsException; use Aws\ResultInterface; use GuzzleHttp\Psr7\Response; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(Crc32ValidatingParser::class)] diff --git a/tests/Api/Parser/DecodingEventStreamIteratorTest.php b/tests/Api/Parser/DecodingEventStreamIteratorTest.php index a4c03b61c9..7c078e802b 100644 --- a/tests/Api/Parser/DecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/DecodingEventStreamIteratorTest.php @@ -37,9 +37,6 @@ public static function complianceTests(): \Generator } } - /** - - */ #[DataProvider('complianceTests')] public function testPassesComplianceTest( Stream $encodedData, diff --git a/tests/Api/Parser/EventParsingIteratorTest.php b/tests/Api/Parser/EventParsingIteratorTest.php index bed3244f75..8f1db82c98 100644 --- a/tests/Api/Parser/EventParsingIteratorTest.php +++ b/tests/Api/Parser/EventParsingIteratorTest.php @@ -67,7 +67,7 @@ class EventParsingIteratorTest extends TestCase * * @return \Generator */ - public static function iteratorDataProvider() + public static function iteratorDataProvider(): \Generator { foreach (self::$eventCases as $eventCase) { $shape = self::loadEventStreamShapeFromJson($eventCase['shape']); @@ -95,9 +95,7 @@ public static function iteratorDataProvider() * this unique element against the expected output, otherwise we evaluate the whole array * against the expected output. The reason for this is to test parsing either single or multiple * events. - * - - */ + */ #[DataProvider('iteratorDataProvider')] public function testParsedEventsMatchExpectedOutput($iterator, $expectedOutput) { @@ -116,9 +114,7 @@ public function testParsedEventsMatchExpectedOutput($iterator, $expectedOutput) /** * This method tests for whether the deserialized event members match the equivalent * shape member types. - * - - */ + */ #[DataProvider('iteratorDataProvider')] public function testParsedEventsMatchExpectedType($iterator) { @@ -296,7 +292,7 @@ private static function loadEventStreamShapeFromJson($jsonFilePath): StructureSh * This method creates an instance of a RestParser class based on the protocol provided. * * @param $protocol - * + * * @return AbstractRestParser */ private static function createRestParser($protocol): AbstractRestParser @@ -372,14 +368,6 @@ public function testHandleInitialResponse() $this->assertEquals(['initial-response' => []], $iterator->current()); } - /** - * @param array $eventStreams - * @param string $expectedExceptionMessage - * - * @return void - * - - */ #[DataProvider('handleEventWithExceptionsProvider')] public function testHandleEventWithExceptions( array $eventStreams, @@ -413,7 +401,8 @@ public function testHandleEventWithExceptions( /** * @return array[] */ - public static function handleEventWithExceptionsProvider(): array { + public static function handleEventWithExceptionsProvider(): array + { return [ 'handle_event_with_exceptions_1' => [ 'event_streams' => diff --git a/tests/Api/Parser/Exception/ParserExceptionTest.php b/tests/Api/Parser/Exception/ParserExceptionTest.php index d8bbaf6785..76d63e86e6 100644 --- a/tests/Api/Parser/Exception/ParserExceptionTest.php +++ b/tests/Api/Parser/Exception/ParserExceptionTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\Parser\Exception\ParserException::class)] +#[CoversClass(ParserException::class)] class ParserExceptionTest extends TestCase { public function testExtractsContext() diff --git a/tests/Api/Parser/JsonParserTest.php b/tests/Api/Parser/JsonParserTest.php index ee3987b79d..b4128d3a9f 100644 --- a/tests/Api/Parser/JsonParserTest.php +++ b/tests/Api/Parser/JsonParserTest.php @@ -2,6 +2,8 @@ namespace Aws\Test\Api\Parser; use Aws\Api\Parser\Exception\ParserException; +use Aws\Api\Parser\JsonRpcParser; +use Aws\Api\Parser\JsonParser; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; @@ -9,15 +11,14 @@ /** * This class tests the custom functionality of the JsonParser; * generic testing is done in ComplianceTest.php - */ -#[CoversClass(\Aws\Api\Parser\JsonRpcParser::class)] -#[CoversClass(\Aws\Api\Parser\JsonParser::class)] +#[CoversClass(JsonRpcParser::class)] +#[CoversClass(JsonParser::class)] class JsonParserTest extends TestCase { use ParserTestServiceTrait; - public static function timeStampModelProvider() + public static function timeStampModelProvider(): array { return [ [932169600, "ParseIso8601", "1999-07-17T00:00:00+00:00"], @@ -62,7 +63,7 @@ public static function timeStampModelProvider() ]; } - public static function timeStampExceptionModelProvider() + public static function timeStampExceptionModelProvider(): array { return [ ["this text is not a date", "ParseIso8601", ParserException::class, "Invalid timestamp value passed to DateTimeResult::fromTimestamp"], @@ -95,9 +96,6 @@ public static function timeStampExceptionModelProvider() ]; } - /** - - */ #[DataProvider('timeStampModelProvider')] public function testHandlesTimeStamps( $timestamp, @@ -117,9 +115,6 @@ public function testHandlesTimeStamps( self::assertEquals($expectedValue, $result); } - /** - - */ #[DataProvider('timeStampExceptionModelProvider')] public function testTimeStampExceptions( $timestamp, @@ -140,4 +135,3 @@ public function testTimeStampExceptions( $handler($command)->wait(); } } - diff --git a/tests/Api/Parser/JsonRpcParserTest.php b/tests/Api/Parser/JsonRpcParserTest.php index 361fe76103..a289e4ed80 100644 --- a/tests/Api/Parser/JsonRpcParserTest.php +++ b/tests/Api/Parser/JsonRpcParserTest.php @@ -13,8 +13,11 @@ use Aws\CommandInterface; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\TestCase; +#[CoversClass(JsonRpcParser::class)] class JsonRpcParserTest extends TestCase { #[CoversNothing] @@ -97,13 +100,13 @@ public function testCanHandleEmptyResponses() public function testCanHandleNonStreamingResponses() { $service = $this->getMockBuilder(Service::class) - -> disableOriginalConstructor() - -> onlyMethods(['getOperation']) - -> getMock(); + ->disableOriginalConstructor() + ->onlyMethods(['getOperation']) + ->getMock(); $operation = $this->getMockBuilder(Operation::class) - -> disableOriginalConstructor() - -> onlyMethods(['getOutput']) - -> getMock(); + ->disableOriginalConstructor() + ->onlyMethods(['getOutput']) + ->getMock(); $outputShape = new StructureShape([ 'type' => 'structure', 'members' => [ @@ -122,16 +125,16 @@ public function testCanHandleNonStreamingResponses() ] ], new ShapeMap([])); $operation->method('getOutput') - -> willReturn($outputShape); + ->willReturn($outputShape); $operation['output'] = $outputShape; $service->method('getOperation') - -> withAnyParameters() - -> willReturn($operation); + ->withAnyParameters() + ->willReturn($operation); $jsonRPCParser = new JsonRpcParser($service); $command = $this->getMockBuilder(Command::class) - -> disableOriginalConstructor() - -> onlyMethods(['getName']) - -> getMock(); + ->disableOriginalConstructor() + ->onlyMethods(['getName']) + ->getMock(); $command->method('getName') ->willReturn('TestCommand'); $body = json_encode([ @@ -155,13 +158,13 @@ public function testCanHandleNonStreamingResponses() public function testCanHandleStreamingResponses() { $service = $this->getMockBuilder(Service::class) - -> disableOriginalConstructor() - -> onlyMethods(['getOperation']) - -> getMock(); + ->disableOriginalConstructor() + ->onlyMethods(['getOperation']) + ->getMock(); $operation = $this->getMockBuilder(Operation::class) - -> disableOriginalConstructor() - -> onlyMethods(['getOutput']) - -> getMock(); + ->disableOriginalConstructor() + ->onlyMethods(['getOutput']) + ->getMock(); $outputShape = new StructureShape([ 'type' => 'structure', 'members' => [ @@ -191,16 +194,16 @@ public function testCanHandleStreamingResponses() ] ], new ShapeMap([])); $operation->method('getOutput') - -> willReturn($outputShape); + ->willReturn($outputShape); $operation['output'] = $outputShape; $service->method('getOperation') - -> withAnyParameters() - -> willReturn($operation); + ->withAnyParameters() + ->willReturn($operation); $jsonRPCParser = new JsonRpcParser($service); $command = $this->getMockBuilder(Command::class) - -> disableOriginalConstructor() - -> onlyMethods(['getName']) - -> getMock(); + ->disableOriginalConstructor() + ->onlyMethods(['getName']) + ->getMock(); $command->method('getName') ->willReturn('TestCommand'); $expectedResult = [ diff --git a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php index 7c2b9a6953..9da889679f 100644 --- a/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php +++ b/tests/Api/Parser/NonSeekableStreamDecodingEventStreamIteratorTest.php @@ -6,10 +6,12 @@ use GuzzleHttp\Psr7\NoSeekStream; use GuzzleHttp\Psr7\StreamDecoratorTrait; use GuzzleHttp\Psr7\Utils; -use Psr\Http\Message\StreamInterface; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\TestCase; +use Psr\Http\Message\StreamInterface; +#[CoversClass(NonSeekableStreamDecodingEventStreamIterator::class)] class NonSeekableStreamDecodingEventStreamIteratorTest extends TestCase { const EVENT_STREAMS_DIR = __DIR__ . '/event-streams/'; @@ -74,13 +76,6 @@ public function testValidReturnsTrueOnEOF() $this->assertFalse($iterator->valid()); } - /** - * @param string $eventName - * @param array $expected - * - * @return void - - */ #[DataProvider('readAndHashBytesHandlesPartialReadsProvider')] public function testReadAndHashBytesHandlesPartialReads( string $eventName, @@ -124,9 +119,6 @@ public function testReadAndHashBytesHandlesPartialReads( ); } - /** - * @return \Generator - */ public static function readAndHashBytesHandlesPartialReadsProvider(): \Generator { $cases = json_decode( diff --git a/tests/Api/Parser/RestJsonParserTest.php b/tests/Api/Parser/RestJsonParserTest.php index f7947a4e7c..a0e64d4a89 100644 --- a/tests/Api/Parser/RestJsonParserTest.php +++ b/tests/Api/Parser/RestJsonParserTest.php @@ -7,7 +7,7 @@ use Aws\CommandInterface; use Aws\Test\Api\Parser\ParserTestServiceTrait; use GuzzleHttp\Psr7\Response; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; @@ -16,13 +16,6 @@ class RestJsonParserTest extends TestCase { use ParserTestServiceTrait; - /** - * @param string|array $value - * @param array $expected - * - * @return void - - */ #[DataProvider('parsesDocumentTypePayloadProvider')] public function testParsesDocumentTypePayload( string $value, diff --git a/tests/Api/Parser/RestXmlParserTest.php b/tests/Api/Parser/RestXmlParserTest.php index 302a66dfa5..431d347dfc 100644 --- a/tests/Api/Parser/RestXmlParserTest.php +++ b/tests/Api/Parser/RestXmlParserTest.php @@ -6,7 +6,7 @@ use Aws\Api\Service; use Aws\CommandInterface; use GuzzleHttp\Psr7\Response; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(RestXmlParser::class)] diff --git a/tests/Api/Parser/XmlParserTest.php b/tests/Api/Parser/XmlParserTest.php index 9899d7b86d..c4ddaf1983 100644 --- a/tests/Api/Parser/XmlParserTest.php +++ b/tests/Api/Parser/XmlParserTest.php @@ -2,6 +2,8 @@ namespace Aws\Test\Api\Parser; use Aws\Api\Parser\Exception\ParserException; +use Aws\Api\Parser\RestXmlParser; +use Aws\Api\Parser\XmlParser; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; @@ -9,15 +11,14 @@ /** * This class tests the custom functionality of the XmlParser; * generic testing is done in ComplianceTest.php - */ -#[CoversClass(\Aws\Api\Parser\RestXmlParser::class)] -#[CoversClass(\Aws\Api\Parser\XmlParser::class)] +#[CoversClass(RestXmlParser::class)] +#[CoversClass(XmlParser::class)] class XmlParserTest extends TestCase { use ParserTestServiceTrait; - public static function timeStampModelProvider() + public static function timeStampModelProvider(): array { return [ [932169600, "ParseIso8601", "1999-07-17T00:00:00+00:00"], @@ -65,7 +66,7 @@ public static function timeStampModelProvider() ]; } - public static function timeStampExceptionModelProvider() + public static function timeStampExceptionModelProvider(): array { return [ ["this text is not a date", "ParseIso8601", ParserException::class, "Invalid timestamp value passed to DateTimeResult::fromTimestamp"], @@ -92,9 +93,6 @@ public static function timeStampExceptionModelProvider() ]; } - /** - - */ #[DataProvider('timeStampModelProvider')] public function testTimeStamps($timestamp, $commandName, $expectedValue) { @@ -111,10 +109,6 @@ public function testTimeStamps($timestamp, $commandName, $expectedValue) self::assertEquals($expectedValue, $result); } - - /** - - */ #[DataProvider('timeStampExceptionModelProvider')] public function testExceptionTimeStamps( $timestamp, diff --git a/tests/Api/Serializer/ComplianceTest.php b/tests/Api/Serializer/ComplianceTest.php index 0f706d63a1..7934c280de 100644 --- a/tests/Api/Serializer/ComplianceTest.php +++ b/tests/Api/Serializer/ComplianceTest.php @@ -8,16 +8,25 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; - -#[CoversClass(\Aws\Api\Serializer\QuerySerializer::class)] -#[CoversClass(\Aws\Api\Serializer\JsonRpcSerializer::class)] -#[CoversClass(\Aws\Api\Serializer\RestSerializer::class)] -#[CoversClass(\Aws\Api\Serializer\RestJsonSerializer::class)] -#[CoversClass(\Aws\Api\Serializer\RestXmlSerializer::class)] -#[CoversClass(\Aws\Api\Serializer\JsonBody::class)] -#[CoversClass(\Aws\Api\Serializer\XmlBody::class)] -#[CoversClass(\Aws\Api\Serializer\Ec2ParamBuilder::class)] -#[CoversClass(\Aws\Api\Serializer\QueryParamBuilder::class)] +use Aws\Api\Serializer\QuerySerializer; +use Aws\Api\Serializer\JsonRpcSerializer; +use Aws\Api\Serializer\RestSerializer; +use Aws\Api\Serializer\RestJsonSerializer; +use Aws\Api\Serializer\RestXmlSerializer; +use Aws\Api\Serializer\JsonBody; +use Aws\Api\Serializer\XmlBody; +use Aws\Api\Serializer\Ec2ParamBuilder; +use Aws\Api\Serializer\QueryParamBuilder; + +#[CoversClass(QuerySerializer::class)] +#[CoversClass(JsonRpcSerializer::class)] +#[CoversClass(RestSerializer::class)] +#[CoversClass(RestJsonSerializer::class)] +#[CoversClass(RestXmlSerializer::class)] +#[CoversClass(JsonBody::class)] +#[CoversClass(XmlBody::class)] +#[CoversClass(Ec2ParamBuilder::class)] +#[CoversClass(QueryParamBuilder::class)] class ComplianceTest extends TestCase { use UsesServiceTrait; @@ -80,9 +89,6 @@ function () { return []; } } } - /** - - */ #[DataProvider('caseProvider')] public function testPassesComplianceTest( Service $service, diff --git a/tests/Api/Serializer/JsonBodyTest.php b/tests/Api/Serializer/JsonBodyTest.php index 21a44b11db..5f070c56ec 100644 --- a/tests/Api/Serializer/JsonBodyTest.php +++ b/tests/Api/Serializer/JsonBodyTest.php @@ -24,7 +24,7 @@ public function testUsesEmptyHashByDefault(): void ); } - public static function formatProvider() + public static function formatProvider(): iterable { yield [['type' => 'string'], ['foo' => 'bar'], '{"foo":"bar"}']; yield [['type' => 'integer'], ['foo' => 1], '{"foo":1}']; @@ -144,9 +144,6 @@ public static function formatProvider() ]; } - /** - - */ #[DataProvider('formatProvider')] public function testFormatsJson(array $def, array $args, string $result): void { @@ -193,9 +190,6 @@ public static function formatNoReferencesProvider(): iterable ]; } - /** - - */ #[DataProvider('formatNoReferencesProvider')] public function testFormatsJsonDoesNotCreateReferences( array $def, @@ -213,13 +207,6 @@ public function testFormatsJsonDoesNotCreateReferences( $this->assertEquals($result, $builtShape); } - /** - * @param string|array $args - * @param string $expected - * - * @return void - - */ #[DataProvider('buildsDocTypesProvider')] public function testBuildsDocTypes(string|array $args, string $expected): void { diff --git a/tests/Api/Serializer/RestJsonSerializerTest.php b/tests/Api/Serializer/RestJsonSerializerTest.php index 6ea3eb6968..092676cbc9 100644 --- a/tests/Api/Serializer/RestJsonSerializerTest.php +++ b/tests/Api/Serializer/RestJsonSerializerTest.php @@ -309,8 +309,7 @@ public function testPreparesRequestsWithStructPayload(): void /** * @param $input * @param $expectedOutput - - */ + */ #[DataProvider('doctypeTestProvider')] public function testHandlesDoctype($input, $expectedOutput): void { @@ -324,7 +323,6 @@ public function testHandlesDoctype($input, $expectedOutput): void ); } - public static function doctypeTestProvider(): iterable { return [ @@ -359,12 +357,10 @@ public static function doctypeTestProvider(): iterable ]; } - /** * @param string $operation * @param array $input - - */ + */ #[DataProvider('restJsonContentTypeProvider')] public function testRestJsonContentTypeNoPayload( string $operation, @@ -381,7 +377,6 @@ public function testRestJsonContentTypeNoPayload( self::assertEmpty($request->getHeader("Content-length")); } - public static function restJsonContentTypeProvider(): iterable { return [ @@ -397,8 +392,7 @@ public static function restJsonContentTypeProvider(): iterable /** * @param bool $arg * @param string $expected - - */ + */ #[DataProvider('boolProvider')] public function testSerializesHeaderValueToBoolString( bool $arg, @@ -429,10 +423,7 @@ public function testDoesNotOverrideScheme(): void /** * @param string|array $input * @param string $expectedOutput - * - * @return void - - */ + */ #[DataProvider('handlesDocTypeAsPayloadProvider')] public function testHandlesDocTypeAsPayload( string|array $input, @@ -492,10 +483,7 @@ public static function handlesDocTypeAsPayloadProvider(): \Generator /** * @param array|string $input - * - * @return void - - */ + */ #[DataProvider('rejectsInvalidJsonAsPayloadProvider')] public function testRejectsInvalidJsonAsPayload(array|string $input): void { @@ -526,10 +514,7 @@ public static function rejectsInvalidJsonAsPayloadProvider(): iterable * @param array $queryParams * @param string $expected * @param string $description - * - * @return void - - */ + */ #[DataProvider('endpointResolutionProvider')] public function testEndpointResolution( string $endpoint, @@ -553,9 +538,6 @@ public function testEndpointResolution( ); } - /** - - */ #[DataProvider('endpointResolutionProvider')] public function testEndpointV2Resolution( string $endpoint, @@ -580,9 +562,6 @@ public function testEndpointV2Resolution( ); } - /** - - */ #[DataProvider('geoServiceEndpointResolutionProvider')] public function testGeoServiceEndpointResolution( string $endpoint, @@ -605,9 +584,6 @@ public function testGeoServiceEndpointResolution( ); } - /** - - */ #[DataProvider('geoServiceEndpointResolutionProvider')] public function testGeoServiceEndpointV2Resolution( string $endpoint, @@ -867,9 +843,6 @@ public static function geoServiceEndpointResolutionProvider(): \Generator ]; } - /** - - */ #[DataProvider('geoServiceE2EProvider')] public function testGeoServiceEndpointResolutionE2E( string $service, diff --git a/tests/Api/Serializer/RestXmlSerializerTest.php b/tests/Api/Serializer/RestXmlSerializerTest.php index 5c899904f7..6bd3dde2b6 100644 --- a/tests/Api/Serializer/RestXmlSerializerTest.php +++ b/tests/Api/Serializer/RestXmlSerializerTest.php @@ -85,8 +85,7 @@ public function testPreparesRequestsWithStructurePayloadXmlContentType() /** * @param bool $arg * @param string $expected - - */ + */ #[DataProvider('boolProvider')] public function testSerializesHeaderValueToBoolString($arg, $expected) { @@ -102,7 +101,8 @@ public function testSerializesHeaderValueToBoolString($arg, $expected) ); } - public static function boolProvider() { + public static function boolProvider(): array + { return [ [true, 'true'], [false, 'false'] @@ -119,9 +119,6 @@ public function testDoesNotOverrideScheme() $this->assertSame('http://foo.com/', (string) $request->getUri()); } - /** - - */ #[DataProvider('s3EndpointResolutionProvider')] public function testS3EndpointResolution( string $endpoint, @@ -144,9 +141,6 @@ public function testS3EndpointResolution( ); } - /** - - */ #[DataProvider('s3EndpointResolutionProvider')] public function testS3EndpointV2Resolution( string $endpoint, @@ -170,9 +164,6 @@ public function testS3EndpointV2Resolution( ); } - /** - - */ #[DataProvider('s3DotSegmentProvider')] public function testS3DotSegmentPreservation( string $endpoint, @@ -195,9 +186,6 @@ public function testS3DotSegmentPreservation( ); } - /** - - */ #[DataProvider('s3DotSegmentProvider')] public function testS3DotSegmentV2Preservation( string $endpoint, @@ -221,9 +209,6 @@ public function testS3DotSegmentV2Preservation( ); } - /** - - */ #[DataProvider('restXmlEndpointResolutionProvider')] public function testRestXmlEndpointResolution( string $endpoint, @@ -247,9 +232,6 @@ public function testRestXmlEndpointResolution( ); } - /** - - */ #[DataProvider('restXmlEndpointResolutionProvider')] public function testRestXmlEndpointV2Resolution( string $endpoint, @@ -496,9 +478,6 @@ public static function restXmlEndpointResolutionProvider(): \Generator ]; } - /** - - */ #[DataProvider('s3E2EProvider')] public function testS3EndpointResolutionE2E( string $region, @@ -533,9 +512,6 @@ public function testS3EndpointResolutionE2E( $client->getObject(['Bucket' => $bucket, 'Key' => $key]); } - /** - - */ #[DataProvider('s3E2EProvider')] public function testS3EndpointResolutionE2ELegacyProvider( string $region, diff --git a/tests/Api/ServiceTest.php b/tests/Api/ServiceTest.php index cd271bc5fc..bf69a325e2 100644 --- a/tests/Api/ServiceTest.php +++ b/tests/Api/ServiceTest.php @@ -15,7 +15,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\Service::class)] +#[CoversClass(Service::class)] class ServiceTest extends TestCase { use UsesServiceTrait; @@ -23,9 +23,7 @@ class ServiceTest extends TestCase public function testSetsDefaultValues() { - $s = new Service([], function () { return []; - - $this->assertTrue(true);}); + $s = new Service([], function () { return []; }); $this->assertSame([], $s['operations']); $this->assertSame([], $s['shapes']); } @@ -69,9 +67,7 @@ function () { return []; } public function testReturnsMetadata() { - $s = new Service([], function () { return []; - - $this->assertTrue(true);}); + $s = new Service([], function () { return []; }); $this->assertIsArray($s->getMetadata()); $s['metadata'] = [ 'serviceFullName' => 'foo', @@ -148,7 +144,7 @@ public function testLoadWaiterConfigs() $api->getWaiterConfig('Fizz'); } - public static function errorParserProvider() + public static function errorParserProvider(): array { return [ ['json', ErrorParser\JsonRpcErrorParser::class], @@ -158,9 +154,6 @@ public static function errorParserProvider() ]; } - /** - - */ #[DataProvider('errorParserProvider')] public function testCreatesRelevantErrorParsers($p, $cl) { @@ -173,7 +166,7 @@ public function testThrowsOnUnexpectedProtocol() Service::createErrorParser('undefined_protocol'); } - public static function serializerDataProvider() + public static function serializerDataProvider(): array { return [ ['json', Serializer\JsonRpcSerializer::class], @@ -184,9 +177,6 @@ public static function serializerDataProvider() ]; } - /** - - */ #[DataProvider('serializerDataProvider')] public function testCreatesSerializer($type, $cl) { @@ -202,7 +192,7 @@ function () { return []; } $this->assertInstanceOf($cl, $serializer); } - public static function parserDataProvider() + public static function parserDataProvider(): array { return [ ['json', Parser\JsonRpcParser::class], @@ -213,9 +203,6 @@ public static function parserDataProvider() ]; } - /** - - */ #[DataProvider('parserDataProvider')] public function testCreatesParsers($type, $cl) { @@ -313,9 +300,6 @@ function () { return []; } ); } - /** - - */ #[DataProvider('selectsProtocolProvider')] public function testSelectsProtocol($protocols, $expected) { @@ -360,7 +344,7 @@ function () { return []; } $this->assertEquals($expected, $protocol); } - public static function selectsProtocolProvider() + public static function selectsProtocolProvider(): array { return [ [['smithy-rpc-v2-cbor', 'json'], 'json'], diff --git a/tests/Api/ShapeMapTest.php b/tests/Api/ShapeMapTest.php index 420f5ebb0a..6aa33be110 100644 --- a/tests/Api/ShapeMapTest.php +++ b/tests/Api/ShapeMapTest.php @@ -6,7 +6,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\ShapeMap::class)] +#[CoversClass(ShapeMap::class)] class ShapeMapTest extends TestCase { private $shapeDefinitions; diff --git a/tests/Api/ShapeTest.php b/tests/Api/ShapeTest.php index 1a9685d6e4..7ad17bd5a4 100644 --- a/tests/Api/ShapeTest.php +++ b/tests/Api/ShapeTest.php @@ -6,7 +6,6 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(Shape::class)] #[CoversClass(Shape::class)] class ShapeTest extends TestCase { diff --git a/tests/Api/StructureShapeTest.php b/tests/Api/StructureShapeTest.php index 8ec97bbbf4..e2624cbd14 100644 --- a/tests/Api/StructureShapeTest.php +++ b/tests/Api/StructureShapeTest.php @@ -4,10 +4,10 @@ use Aws\Api\Shape; use Aws\Api\ShapeMap; use Aws\Api\StructureShape; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\StructureShape::class)] +#[CoversClass(StructureShape::class)] class StructureShapeTest extends TestCase { public function testReturnsWhenMembersAreEmpty() diff --git a/tests/Api/SupportedProtocolsTest.php b/tests/Api/SupportedProtocolsTest.php index 57e0bb77aa..6a70aba830 100644 --- a/tests/Api/SupportedProtocolsTest.php +++ b/tests/Api/SupportedProtocolsTest.php @@ -4,22 +4,18 @@ use Aws\Api\SupportedProtocols; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(SupportedProtocols::class)] class SupportedProtocolsTest extends TestCase { - /** - - */ #[DataProvider('validProtocolsProvider')] public function testIsSupportedReturnsTrueForValidProtocols(string $protocol) { $this->assertTrue(SupportedProtocols::isSupported($protocol)); } - /** - - */ #[DataProvider('invalidProtocolsProvider')] public function testIsSupportedReturnsFalseForInvalidProtocols(string $protocol) { diff --git a/tests/Api/TimestampShapeTest.php b/tests/Api/TimestampShapeTest.php index 66e872b3c6..68dd2967ef 100644 --- a/tests/Api/TimestampShapeTest.php +++ b/tests/Api/TimestampShapeTest.php @@ -7,10 +7,10 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Api\TimestampShape::class)] +#[CoversClass(TimestampShape::class)] class TimestampShapeTest extends TestCase { - public static function formatProvider() + public static function formatProvider(): array { $t = strtotime('january 5, 1999'); @@ -29,9 +29,6 @@ public static function formatProvider() ]; } - /** - - */ #[DataProvider('formatProvider')] public function testFormatsData($value, $format, $result) { diff --git a/tests/Api/ValidatorTest.php b/tests/Api/ValidatorTest.php index d0a25ba1f4..00dc23022f 100644 --- a/tests/Api/ValidatorTest.php +++ b/tests/Api/ValidatorTest.php @@ -8,11 +8,12 @@ use GuzzleHttp\Psr7; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; #[CoversClass(Validator::class)] class ValidatorTest extends TestCase { - public static function validationProvider() + public static function validationProvider(): array { return [ [ @@ -638,9 +639,6 @@ public static function validationProvider() ]; } - /** - - */ #[DataProvider('validationProvider')] public function testValidatesInput($shape, $input, $result) { diff --git a/tests/Arn/AccessPointArnTest.php b/tests/Arn/AccessPointArnTest.php index c53f7b070d..1504344f13 100644 --- a/tests/Arn/AccessPointArnTest.php +++ b/tests/Arn/AccessPointArnTest.php @@ -7,16 +7,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Arn\AccessPointArn::class)] +#[CoversClass(AccessPointArn::class)] class AccessPointArnTest extends TestCase { - /** - * - * @param $string - * @param $expected - * @param $expectedString - - */ #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { @@ -32,7 +25,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public static function parsedArnProvider() + public static function parsedArnProvider(): array { return [ // All components @@ -86,12 +79,6 @@ public static function parsedArnProvider() ]; } - /** - * - * @param $string - * @param $message - - */ #[DataProvider('invalidArnCases')] public function testThrowsOnInvalidArn($string, $message) { @@ -103,7 +90,7 @@ public function testThrowsOnInvalidArn($string, $message) } } - public static function invalidArnCases() + public static function invalidArnCases(): array { return [ [ diff --git a/tests/Arn/ArnParserTest.php b/tests/Arn/ArnParserTest.php index baaf02bb37..f0d5f594f6 100644 --- a/tests/Arn/ArnParserTest.php +++ b/tests/Arn/ArnParserTest.php @@ -12,23 +12,17 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Arn\ArnParser::class)] +#[CoversClass(ArnParser::class)] class ArnParserTest extends TestCase { - /** - * - * @param $string - * @param $expected - - */ #[DataProvider('isArnCases')] public function testDeterminesShouldAttemptToParseAsArn($string, $expected) { $this->assertEquals($expected, ArnParser::isArn($string)); } - public static function isArnCases() + public static function isArnCases(): array { return [ [ @@ -58,19 +52,13 @@ public static function isArnCases() ]; } - /** - * - * @param $string - * @param $expected - - */ #[DataProvider('parsedArnCases')] public function testCorrectlyChoosesArnClass($string, $expected) { $this->assertTrue(ArnParser::parse($string) instanceof $expected); } - public static function parsedArnCases() + public static function parsedArnCases(): array { return [ [ diff --git a/tests/Arn/ArnTest.php b/tests/Arn/ArnTest.php index 6ed7b37eb7..5ebd3c99cd 100644 --- a/tests/Arn/ArnTest.php +++ b/tests/Arn/ArnTest.php @@ -8,17 +8,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Arn\Arn::class)] +#[CoversClass(Arn::class)] class ArnTest extends TestCase { - - /** - * - * @param $string - * @param $expected - * @param $expectedString - - */ #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { @@ -33,7 +25,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public static function parsedArnProvider() + public static function parsedArnProvider(): array { return [ // All components @@ -117,12 +109,6 @@ public static function parsedArnProvider() ]; } - /** - * - * @param $string - * @param $message - - */ #[DataProvider('invalidArnCases')] public function testThrowsOnInvalidArn($string, $message) { @@ -134,7 +120,7 @@ public function testThrowsOnInvalidArn($string, $message) } } - public static function invalidArnCases() + public static function invalidArnCases(): array { return [ [ diff --git a/tests/Arn/S3/AccessPointArnTest.php b/tests/Arn/S3/AccessPointArnTest.php index c10ee62491..cf26035b05 100644 --- a/tests/Arn/S3/AccessPointArnTest.php +++ b/tests/Arn/S3/AccessPointArnTest.php @@ -7,15 +7,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Arn\S3\AccessPointArn::class)] +#[CoversClass(AccessPointArn::class)] class AccessPointArnTest extends TestCase { - /** - * - * @param $string - * @param $message - - */ #[DataProvider('invalidArnCases')] public function testThrowsOnInvalidArn($string, $message) { @@ -27,7 +21,7 @@ public function testThrowsOnInvalidArn($string, $message) } } - public static function invalidArnCases() + public static function invalidArnCases(): array { return [ [ diff --git a/tests/Arn/S3/OutpostsAccessPointArnTest.php b/tests/Arn/S3/OutpostsAccessPointArnTest.php index 87c4c7c817..a9afddd08c 100644 --- a/tests/Arn/S3/OutpostsAccessPointArnTest.php +++ b/tests/Arn/S3/OutpostsAccessPointArnTest.php @@ -8,16 +8,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Arn\S3\OutpostsAccessPointArn::class)] +#[CoversClass(OutpostsAccessPointArn::class)] class OutpostsAccessPointArnTest extends TestCase { - /** - * - * @param $string - * @param $expected - * @param $expectedString - - */ #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { @@ -36,7 +29,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public static function parsedArnProvider() + public static function parsedArnProvider(): array { return [ // Colon delimiters @@ -114,12 +107,6 @@ public static function parsedArnProvider() ]; } - /** - * - * @param $string - * @param \Exception $expected - - */ #[DataProvider('badArnProvider')] public function testThrowsForBadArn($string, \Exception $expected) { @@ -135,7 +122,7 @@ public function testThrowsForBadArn($string, \Exception $expected) } } - public static function badArnProvider() + public static function badArnProvider(): array { return [ [ diff --git a/tests/Arn/S3/OutpostsBucketArnTest.php b/tests/Arn/S3/OutpostsBucketArnTest.php index be4b8ba7dd..02c6769bff 100644 --- a/tests/Arn/S3/OutpostsBucketArnTest.php +++ b/tests/Arn/S3/OutpostsBucketArnTest.php @@ -9,16 +9,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Arn\S3\OutpostsBucketArn::class)] +#[CoversClass(OutpostsBucketArn::class)] class OutpostsBucketArnTest extends TestCase { - /** - * - * @param $string - * @param $expected - * @param $expectedString - - */ #[DataProvider('parsedArnProvider')] public function testParsesArnString($string, $expected, $expectedString) { @@ -37,7 +30,7 @@ public function testParsesArnString($string, $expected, $expectedString) $this->assertEquals($expectedString, (string) $arn); } - public static function parsedArnProvider() + public static function parsedArnProvider(): array { return [ // Colon delimiters @@ -115,12 +108,6 @@ public static function parsedArnProvider() ]; } - /** - * - * @param $string - * @param \Exception $expected - - */ #[DataProvider('badArnProvider')] public function testThrowsForBadArn($string, \Exception $expected) { @@ -136,7 +123,7 @@ public function testThrowsForBadArn($string, \Exception $expected) } } - public static function badArnProvider() + public static function badArnProvider(): array { return [ [ diff --git a/tests/Auth/AuthSchemeResolverTest.php b/tests/Auth/AuthSchemeResolverTest.php index ee279a0c12..0ae046ca69 100644 --- a/tests/Auth/AuthSchemeResolverTest.php +++ b/tests/Auth/AuthSchemeResolverTest.php @@ -8,8 +8,10 @@ use Aws\Identity\BearerTokenIdentity; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(AuthSchemeResolver::class)] class AuthSchemeResolverTest extends TestCase { public function testUsesDefaultSchemeMapWhenNoneProvided() @@ -35,9 +37,6 @@ public function testAcceptsCustomSchemeMap() $this->assertEquals('v4', $resolver->selectAuthScheme(['custom.auth#example'])); } - /** - - */ #[DataProvider('schemeForIdentityProvider')] public function testSelectAuthSchemeReturnsCorrectSchemeForIdentity( $authScheme, @@ -64,7 +63,7 @@ public function testSelectAuthSchemeReturnsCorrectSchemeForIdentity( $this->assertEquals($expectedSignatureVersion, $resolver->selectAuthScheme($authScheme, $args)); } - public static function schemeForIdentityProvider() + public static function schemeForIdentityProvider(): array { return [ [ @@ -191,9 +190,6 @@ public function testUnmetV4aRequirementsThrows() $resolver->selectAuthScheme(['aws.auth#sigv4a']); } - /** - - */ #[DataProvider('fallsBackWhenIdentityNotAvailableProvider')] public function testFallsBackWhenIdentityNotAvailable( string $credentialIdentityClass, diff --git a/tests/Auth/AuthSelectionMiddlewareTest.php b/tests/Auth/AuthSelectionMiddlewareTest.php index 82e4b8cdda..a7c91579de 100644 --- a/tests/Auth/AuthSelectionMiddlewareTest.php +++ b/tests/Auth/AuthSelectionMiddlewareTest.php @@ -13,18 +13,13 @@ use Aws\MockHandler; use Aws\Result; use GuzzleHttp\Promise; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(AuthSelectionMiddleware::class)] class AuthSelectionMiddlewareTest extends TestCase { - /** - * @param $serviceAuth - * @param $operationAuth - * @param $expected - * - - */ #[DataProvider('resolvesAuthSchemeWithoutCRTProvider')] public function testResolvesAuthSchemeWithoutCRT( $serviceAuth, @@ -61,7 +56,7 @@ public function testResolvesAuthSchemeWithoutCRT( $middleware($command); } - public function ResolvesAuthSchemeWithoutCRTProvider() + public static function resolvesAuthSchemeWithoutCRTProvider(): array { return [ [ @@ -93,14 +88,7 @@ public function ResolvesAuthSchemeWithoutCRTProvider() ]; } - /** - * @param $serviceAuth - * @param $operationAuth - * @param $expected - * - - */ - #[DataProvider('ResolvesAuthSchemeWithCRTprovider')] + #[DataProvider('resolvesAuthSchemeWithCRTProvider')] public function testResolvesAuthSchemeWithCRT( $serviceAuth, $operationAuth, @@ -130,7 +118,7 @@ public function testResolvesAuthSchemeWithCRT( $middleware($command); } - public static function ResolvesAuthSchemeWithCRTprovider() + public static function resolvesAuthSchemeWithCRTProvider(): array { return [ [ @@ -162,14 +150,6 @@ public static function ResolvesAuthSchemeWithCRTprovider() ]; } - /** - * @param $serviceAuth - * @param $operationAuth - * @param $identity - * @param $expected - * - - */ #[DataProvider('resolvesBearerAuthSchemeProvider')] public function testResolvesBearerAuthScheme( $serviceAuth, @@ -316,16 +296,7 @@ function () { return []; } /** * Test auth select is done based on user's provided auth schemes. - * - * @param array $supportedAuthSchemes - * @param array|null $serviceAuthSchemes - * @param array|null $operationAuthSchemes - * @param array|null $userPreferredAuthSchemes - * @param string $expected - * - * @return void - - */ + */ #[DataProvider('authSelectionBasedOnUserPreferenceProvider')] public function testAuthSelectionBasedOnUserPreference( array $supportedAuthSchemes, @@ -377,9 +348,6 @@ public function testAuthSelectionBasedOnUserPreference( $middleware($command); } - /** - * @return \Generator - */ public static function authSelectionBasedOnUserPreferenceProvider(): \Generator { $cases = [ diff --git a/tests/AwsClientTest.php b/tests/AwsClientTest.php index 2754402f3c..d1b77b2d0b 100644 --- a/tests/AwsClientTest.php +++ b/tests/AwsClientTest.php @@ -27,8 +27,9 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(AwsClient::class)] class AwsClientTest extends TestCase @@ -355,14 +356,6 @@ public function testDoesNotSignOperationsWithAnAuthTypeOfNone() $client->bar(); } - /** - * @param array $serviceDefinition - * @param array $clientArguments - * @param array $expectedHeaders - * @param array $expectedHeaderValues - * - - */ #[DataProvider('signOperationsWithAnAuthTypeProvider')] public function testSignOperationsWithAnAuthType( array $serviceDefinition, @@ -620,7 +613,6 @@ public function testIsUseGlobalEndpoint() { } #[DataProvider('configuredEndpointUrlProvider')] - public function testAppliesConfiguredEndpointUrl($ini, $env, $expected) { $dir = sys_get_temp_dir() . '/.aws'; @@ -652,7 +644,6 @@ public function testAppliesConfiguredEndpointUrl($ini, $env, $expected) } #[DataProvider('configuredEndpointUrlProvider')] - public function testDoesNotApplyConfiguredEndpointWhenConfiguredUrlsIgnored($ini, $env) { putenv('AWS_IGNORE_CONFIGURED_ENDPOINT_URLS=true'); @@ -687,7 +678,7 @@ public function testDoesNotApplyConfiguredEndpointWhenConfiguredUrlsIgnored($ini putenv('AWS_IGNORE_CONFIGURED_ENDPOINT_URLS='); } - public static function configuredEndpointUrlProvider() + public static function configuredEndpointUrlProvider(): array { return [ [ @@ -792,10 +783,6 @@ public function testAppliesConfiguredSignatureVersionViaClientConfig() { $client->foo(); } - /** - * @runInSeparateProcess - - */ #[DataProvider('signingRegionSetProvider')] public function testSigningRegionSetResolution( $command, @@ -861,7 +848,7 @@ public function testSigningRegionSetResolution( putenv('AWS_SIGV4A_SIGNING_REGION_SET='); } - public static function signingRegionSetProvider() + public static function signingRegionSetProvider(): array { return [ [null, null, null, null, 'us-west-2'], diff --git a/tests/Build/Changelog/ChangelogBuilderTest.php b/tests/Build/Changelog/ChangelogBuilderTest.php index f87f0ab8c5..3661a27291 100644 --- a/tests/Build/Changelog/ChangelogBuilderTest.php +++ b/tests/Build/Changelog/ChangelogBuilderTest.php @@ -2,7 +2,7 @@ namespace Aws\Test\Build\Changelog; use Aws\Build\Changelog\ChangelogBuilder; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(ChangelogBuilder::class)] diff --git a/tests/Build/Changelog/CurrentChangesTest.php b/tests/Build/Changelog/CurrentChangesTest.php index df06aed3eb..edc7c907b6 100644 --- a/tests/Build/Changelog/CurrentChangesTest.php +++ b/tests/Build/Changelog/CurrentChangesTest.php @@ -2,6 +2,7 @@ namespace Aws\Test\Build\Changelog; +use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\TestCase; class CurrentChangesTest extends TestCase diff --git a/tests/Build/Docs/CodeSnippetGeneratorTest.php b/tests/Build/Docs/CodeSnippetGeneratorTest.php index 0531fb611d..11551afa38 100644 --- a/tests/Build/Docs/CodeSnippetGeneratorTest.php +++ b/tests/Build/Docs/CodeSnippetGeneratorTest.php @@ -1,24 +1,16 @@ assertSame($expected, $builder($operation, $input, [], $isInput)); } - public static function exampleProvider() + public static function exampleProvider(): array { $provider = ApiProvider::defaultProvider(); return [ diff --git a/tests/ClientResolverTest.php b/tests/ClientResolverTest.php index 64a350b719..7930faea96 100644 --- a/tests/ClientResolverTest.php +++ b/tests/ClientResolverTest.php @@ -169,7 +169,7 @@ public function testAppliesClientContextParams() . "\n\n" . 'Accelerate: (boolean)' . "\n\n" . ' Enables this client to use S3 Transfer Acceleration endpoints.' ); - $conf = $r->resolve([ + $r->resolve([ 'service' => 's3', 'version' => 'latest', 'region' => 'x', diff --git a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php index 50e5cea0f1..4f67736bdf 100644 --- a/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php +++ b/tests/ClientSideMonitoring/ApiCallAttemptMonitoringMiddlewareTest.php @@ -15,7 +15,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(ApiCallAttemptMonitoringMiddleware::class)] #[CoversClass(ApiCallAttemptMonitoringMiddleware::class)] class ApiCallAttemptMonitoringMiddlewareTest extends TestCase { @@ -58,8 +57,13 @@ protected function resetMiddlewareSocket() $prepareSocket->invokeArgs($middleware, array(true)); } - public function getMonitoringDataTests() + public static function getMonitoringDataTests(): array { + $configuration = new Configuration(true, '127.0.0.1', 31000, 'AwsPhpSdkTestApp'); + $credentialProvider = CredentialProvider::fromCredentials( + new Credentials('testkey', 'testsecret', 'testtoken') + ); + $command = new Command('RunScheduledInstances', [ 'LaunchSpecification' => [ 'ImageId' => 'test-image', @@ -69,8 +73,8 @@ public function getMonitoringDataTests() ]); $testBase = [ ApiCallAttemptMonitoringMiddleware::wrap( - $this->getCredentialProvider(), - $this->getConfiguration(), + $credentialProvider, + $configuration, 'us-east-1', 'ec2' ), diff --git a/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php b/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php index 73949f6538..8e49cec96e 100644 --- a/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php +++ b/tests/ClientSideMonitoring/ApiCallMonitoringMiddlewareTest.php @@ -12,7 +12,6 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(ApiCallMonitoringMiddleware::class)] #[CoversClass(ApiCallMonitoringMiddleware::class)] class ApiCallMonitoringMiddlewareTest extends TestCase { @@ -55,8 +54,12 @@ protected function resetMiddlewareSocket() $prepareSocket->invokeArgs($middleware, array(true)); } - public function getMonitoringDataTests() + public static function getMonitoringDataTests(): array { + $credentials = new Credentials('testkey', 'testsecret', 'testtoken'); + $credentialProvider = CredentialProvider::fromCredentials($credentials); + $configuration = new Configuration(true, '127.0.0.1', 31000, 'AwsPhpSdkTestApp'); + $command = new Command('RunScheduledInstances', [ 'LaunchSpecification' => [ 'ImageId' => 'test-image', @@ -67,8 +70,8 @@ public function getMonitoringDataTests() $testBase = [ ApiCallMonitoringMiddleware::wrap( - $this->getCredentialProvider(), - $this->getConfiguration(), + $credentialProvider, + $configuration, 'us-east-1', 'ec2' ), diff --git a/tests/ClientSideMonitoring/ConfigurationProviderTest.php b/tests/ClientSideMonitoring/ConfigurationProviderTest.php index a5be323735..cc19996949 100644 --- a/tests/ClientSideMonitoring/ConfigurationProviderTest.php +++ b/tests/ClientSideMonitoring/ConfigurationProviderTest.php @@ -13,11 +13,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; - #[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { - private static $originalEnv; private $iniFile = <<clearEnv(); @@ -439,7 +437,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public static function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData(): array { $expected = new Configuration(true, '123.4.5.6', 555, 'FooApp'); return [ @@ -469,11 +467,6 @@ function() use ($expected) { ]; } - /** - * @param $toUnwrap - * @param ConfigurationInterface $expected - - */ #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { diff --git a/tests/ClientSideMonitoring/ConfigurationTest.php b/tests/ClientSideMonitoring/ConfigurationTest.php index c54ab2d68a..d26aa789df 100644 --- a/tests/ClientSideMonitoring/ConfigurationTest.php +++ b/tests/ClientSideMonitoring/ConfigurationTest.php @@ -4,11 +4,9 @@ use Aws\ClientSideMonitoring\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use Psr\Log\InvalidArgumentException; use PHPUnit\Framework\Attributes\CoversClass; - -#[CoversClass(\Aws\ClientSideMonitoring\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/CloudFront/CloudFrontClientTest.php b/tests/CloudFront/CloudFrontClientTest.php index 10c6b4fff7..e609d55ee7 100644 --- a/tests/CloudFront/CloudFrontClientTest.php +++ b/tests/CloudFront/CloudFrontClientTest.php @@ -5,6 +5,7 @@ use Aws\CloudFront\CloudFrontClient; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; #[CoversClass(CloudFrontClient::class)] class CloudFrontClientTest extends TestCase diff --git a/tests/CloudFront/CookieSignerTest.php b/tests/CloudFront/CookieSignerTest.php index 54856629db..a3e9e082ac 100644 --- a/tests/CloudFront/CookieSignerTest.php +++ b/tests/CloudFront/CookieSignerTest.php @@ -2,14 +2,16 @@ namespace Aws\Test\CloudFront; use Aws\CloudFront\CookieSigner; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\TestCase; +#[CoversClass(CookieSigner::class)] class CookieSignerTest extends TestCase { protected $key; protected $kp; - public function set_up() + public function setUp(): void { openssl_pkey_export(openssl_pkey_new(),$this->key); $this->kp = 'test'; diff --git a/tests/CloudFront/SignerTest.php b/tests/CloudFront/SignerTest.php index a20565ca10..633ea8292b 100644 --- a/tests/CloudFront/SignerTest.php +++ b/tests/CloudFront/SignerTest.php @@ -3,8 +3,10 @@ use Aws\CloudFront\Signer; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(Signer::class)] class SignerTest extends TestCase { /** @var Signer */ @@ -76,7 +78,10 @@ public function testReturnsSignatureAndKeyPairId() $this->assertArrayHasKey('Key-Pair-Id', $signature); } - public static function getExpiresCases() + /** + * @return array> + */ + public static function getExpiresCases(): array { return [ [ @@ -88,9 +93,6 @@ public static function getExpiresCases() ]; } - /** - - */ #[DataProvider('getExpiresCases')] public function testReturnsExpiresForCannedPolicies($expires) { @@ -139,12 +141,6 @@ public function testPolicyContainsNoForbiddenCharacters() $this->assertDoesNotMatchRegularExpression('/[\+\=\/]/', $signature['Policy']); } - /** - * - * @param string $resource - * @param int $ts - - */ #[DataProvider('cannedPolicyParameterProvider')] public function testCreatesCannedPolicies($resource, $ts) { @@ -158,7 +154,10 @@ public function testCreatesCannedPolicies($resource, $ts) ); } - public static function cannedPolicyParameterProvider() + /** + * @return array> + */ + public static function cannedPolicyParameterProvider(): array { return [ [ diff --git a/tests/CloudFront/UrlSignerTest.php b/tests/CloudFront/UrlSignerTest.php index cb8cf0daf9..243efb564e 100644 --- a/tests/CloudFront/UrlSignerTest.php +++ b/tests/CloudFront/UrlSignerTest.php @@ -131,12 +131,6 @@ public function testEnsuresUriSchemeIsPresent() $s->getSignedUrl('bar.com'); } - /** - * - * @param string $url - * @param string $resource - - */ #[DataProvider('urlAndResourceProvider')] public function testIsolatesResourceIUrls($url, $resource) { @@ -153,7 +147,7 @@ public function testIsolatesResourceIUrls($url, $resource) $this->assertSame($resource, $result); } - public static function urlAndResourceProvider() + public static function urlAndResourceProvider(): array { return [ ['rtmp://foo.cloudfront.net/videos/test.mp4', 'videos/test.mp4'], diff --git a/tests/CloudTrail/LogFileIteratorTest.php b/tests/CloudTrail/LogFileIteratorTest.php index 5805abfcef..de29407510 100644 --- a/tests/CloudTrail/LogFileIteratorTest.php +++ b/tests/CloudTrail/LogFileIteratorTest.php @@ -8,7 +8,7 @@ use Aws\S3\S3Client; use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7\Response; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(LogFileIterator::class)] diff --git a/tests/CloudTrail/LogFileReaderTest.php b/tests/CloudTrail/LogFileReaderTest.php index a845c81fcf..6c6c0966d1 100644 --- a/tests/CloudTrail/LogFileReaderTest.php +++ b/tests/CloudTrail/LogFileReaderTest.php @@ -13,9 +13,6 @@ class LogFileReaderTest extends TestCase { use UsesServiceTrait; - /** - - */ #[DataProvider('dataForLogReadingTest')] public function testCorrectlyReadsLogFiles($responseBody, $recordCount) { @@ -31,7 +28,7 @@ public function testCorrectlyReadsLogFiles($responseBody, $recordCount) $this->assertCount($recordCount, $records); } - public static function dataForLogReadingTest() + public static function dataForLogReadingTest(): array { return [ ['{"Records":[{"foo":"1"},{"bar":"2"},{"baz":"3"}]}', 3], diff --git a/tests/CloudWatchLogs/CloudWatchLogsClientTest.php b/tests/CloudWatchLogs/CloudWatchLogsClientTest.php index 69a2935f73..bd7d26cbbb 100644 --- a/tests/CloudWatchLogs/CloudWatchLogsClientTest.php +++ b/tests/CloudWatchLogs/CloudWatchLogsClientTest.php @@ -7,9 +7,11 @@ use GuzzleHttp\Psr7\NoSeekStream; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Framework\Attributes\CoversClass; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +#[CoversClass(CloudWatchLogsClient::class)] class CloudWatchLogsClientTest extends TestCase { public function testSetStreamingFlagMiddleware() diff --git a/tests/CognitoIdentity/CognitoIdentityProviderTest.php b/tests/CognitoIdentity/CognitoIdentityProviderTest.php index 6098430316..bfdfbd53b1 100644 --- a/tests/CognitoIdentity/CognitoIdentityProviderTest.php +++ b/tests/CognitoIdentity/CognitoIdentityProviderTest.php @@ -5,8 +5,10 @@ use Aws\CognitoIdentity\CognitoIdentityProvider; use Aws\MockHandler; use Aws\Result; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\TestCase; +#[CoversClass(CognitoIdentityProvider::class)] class CognitoIdentityProviderTest extends TestCase { public function testCreatesFromCognitoIdentity() @@ -48,9 +50,15 @@ public function testAccessTokensCanBeRefreshed() ); $provider->updateLogin('www.amazon.com', 'access-token-new'); + + $reflection = new \ReflectionClass($provider); + $property = $reflection->getProperty('logins'); + $property->setAccessible(true); + $logins = $property->getValue($provider); + $this->assertSame( 'access-token-new', - $this->getPropertyValue($provider, 'logins')['www.amazon.com'] + $logins['www.amazon.com'] ); } } diff --git a/tests/CognitoSync/CognitoSyncClientTest.php b/tests/CognitoSync/CognitoSyncClientTest.php index 1884163f68..6e86a59ba9 100644 --- a/tests/CognitoSync/CognitoSyncClientTest.php +++ b/tests/CognitoSync/CognitoSyncClientTest.php @@ -1,12 +1,15 @@ new Result(), 'B' => new Result()]; - $client = $this->getTestClient('s3'); - $this->addMockResults($client, $results); - $iter = [ - 'A' => $client->getCommand('HeadBucket', ['Bucket' => 'Foo']), - 'B' => $client->getCommand('HeadBucket', ['Bucket' => 'Foo']) - ]; - $pool = new CommandPool($client, $iter, [ - 'fulfilled' => function ($result, $key) use (&$called) { - $called[$key] = $result; - }, - 'preserve_iterator_keys' => true, + { + $results = ['A' => new Result(), 'B' => new Result()]; + $client = $this->getTestClient('s3'); + $this->addMockResults($client, $results); + $iter = [ + 'A' => $client->getCommand('HeadBucket', ['Bucket' => 'Foo']), + 'B' => $client->getCommand('HeadBucket', ['Bucket' => 'Foo']) + ]; + $pool = new CommandPool($client, $iter, [ + 'fulfilled' => function ($result, $key) use (&$called) { + $called[$key] = $result; + }, + 'preserve_iterator_keys' => true, ]); $pool->promise()->wait(); $this->assertSame($results, $called); diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 1ebe437498..da6313ff0e 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -4,10 +4,9 @@ use Aws\Command; use Aws\HandlerList; use Aws\MetricsBuilder; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(Command::class)] #[CoversClass(Command::class)] class CommandTest extends TestCase { diff --git a/tests/ConfigurationResolverTest.php b/tests/ConfigurationResolverTest.php index 8471344e31..30b3695a63 100644 --- a/tests/ConfigurationResolverTest.php +++ b/tests/ConfigurationResolverTest.php @@ -3,8 +3,10 @@ use Aws\Configuration\ConfigurationResolver; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(ConfigurationResolver::class)] class ConfigurationResolverTest extends TestCase { private static $configurationKey = 'foo_configuration_option'; @@ -81,7 +83,7 @@ public static function tear_down_after_class() self::$originalEnv['config_file']); } - public static function getEnvValues() + public static function getEnvValues(): array { return [ ['true', 'bool', true], @@ -91,9 +93,6 @@ public static function getEnvValues() ]; } - /** - - */ #[DataProvider('getEnvValues')] public function testRetrievesAndConvertsEnvironmentVariables($envValue, $type, $expected) { @@ -127,19 +126,37 @@ public function testResolvesDefaultFromFallback() $this->assertFalse($result); } - public function iniFileProvider() + public static function iniFileProvider(): array { + $boolIniFile = <<boolIniFile, 'bool', true], - [$this->intIniFile, 'int', 15], - [$this->stringIniFile, 'string', 'standard'], + [$boolIniFile, 'bool', true], + [$intIniFile, 'int', 15], + [$stringIniFile, 'string', 'standard'], ]; } - /** - - */ - #[DataProvider('IniFileProvider')] + #[DataProvider('iniFileProvider')] public function testResolvesFromIniFileWithDefaultProfile($iniFile, $type, $expected) { $dir = $this->clearEnv(); @@ -150,10 +167,7 @@ public function testResolvesFromIniFileWithDefaultProfile($iniFile, $type, $expe unlink($dir . '/config'); } - /** - - */ - #[DataProvider('IniFileProvider')] + #[DataProvider('iniFileProvider')] public function testCreatesFromIniFileWithDifferentDefaultFilename($iniFile, $type, $expected) { $dir = $this->clearEnv(); @@ -168,19 +182,37 @@ public function testCreatesFromIniFileWithDifferentDefaultFilename($iniFile, $ty unlink($dir . '/alt_config'); } - public function iniFileWithAltProfileProvider() + public static function iniFileWithAltProfileProvider(): array { + $boolIniFile = <<boolIniFile, 'bool', false], - [$this->intIniFile, 'int', 25], - [$this->stringIniFile, 'string', 'experimental'], + [$boolIniFile, 'bool', false], + [$intIniFile, 'int', 25], + [$stringIniFile, 'string', 'experimental'], ]; } - /** - - */ - #[DataProvider('IniFileWIthAltProfileProvider')] + #[DataProvider('iniFileWithAltProfileProvider')] public function testCreatesFromIniFileWithSpecifiedProfile($iniFile, $type, $expected) { $dir = $this->clearEnv(); @@ -349,9 +381,6 @@ public function testResolvesServiceIni() ); } - /** - - */ #[DataProvider('duplicateIniFileProvider')] public function testResolvesServiceIniWithDuplicateSections($ini) { @@ -384,7 +413,7 @@ public function testResolvesServiceIniWithDuplicateSections($ini) ); } - public static function duplicateIniFileProvider() + public static function duplicateIniFileProvider(): array { return [ [ @@ -431,4 +460,3 @@ public static function duplicateIniFileProvider() ]; } } - diff --git a/tests/Credentials/AssumeRoleCredentialProviderTest.php b/tests/Credentials/AssumeRoleCredentialProviderTest.php index ae14776982..cf486edb22 100644 --- a/tests/Credentials/AssumeRoleCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleCredentialProviderTest.php @@ -15,18 +15,13 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Credentials\AssumeRoleCredentialProvider::class)] +#[CoversClass(AssumeRoleCredentialProvider::class)] class AssumeRoleCredentialProviderTest extends TestCase { const SAMPLE_ROLE_ARN = 'arn:aws:iam::012345678910:role/role_name'; use UsesServiceTrait; - /** - * - * @param array $config - - */ #[DataProvider('insufficientArguments')] public function testEnsureSourceProfileProvidedForAssumeRole($config) { @@ -35,11 +30,7 @@ public function testEnsureSourceProfileProvidedForAssumeRole($config) new AssumeRoleCredentialProvider($config); } - /** - - */ - #[DataProvider('insufficientArguments')] - public static function insufficientArguments() + public static function insufficientArguments(): array { $client = [ 'client' => new StsClient([ diff --git a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php index 1de2937125..26e5752505 100644 --- a/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php +++ b/tests/Credentials/AssumeRoleWithWebIdentityCredentialProviderTest.php @@ -399,10 +399,6 @@ public function testCanDisableInvalidIdentityTokenRetries() } } - /** - * Tests region precedence: config > env var > fallback - - */ #[DataProvider('regionPrecedenceProvider')] public function testRegionPrecedence( ?string $configRegion, @@ -477,10 +473,6 @@ public static function regionPrecedenceProvider(): array ]; } - /** - * Tests that correct endpoints are called - - */ #[DataProvider('endpointProvider')] public function testEndpointSelection( string $region, diff --git a/tests/Credentials/CredentialsTest.php b/tests/Credentials/CredentialsTest.php index c3e1f1f067..3feda7eb34 100644 --- a/tests/Credentials/CredentialsTest.php +++ b/tests/Credentials/CredentialsTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Credentials\Credentials::class)] +#[CoversClass(Credentials::class)] class CredentialsTest extends TestCase { public function testHasGetters() diff --git a/tests/Credentials/CredentialsUtilsTest.php b/tests/Credentials/CredentialsUtilsTest.php index 0d269f2415..ba2430e66e 100644 --- a/tests/Credentials/CredentialsUtilsTest.php +++ b/tests/Credentials/CredentialsUtilsTest.php @@ -6,16 +6,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Credentials\CredentialsUtils::class)] +#[CoversClass(CredentialsUtils::class)] class CredentialsUtilsTest extends TestCase { - - /** - * @param string $host - * @param bool $expectedResult - * - - */ #[DataProvider('loopBackAddressCasesProvider')] public function testLoopBackAddressCases(string $host, bool $expectedResult) { @@ -24,7 +17,7 @@ public function testLoopBackAddressCases(string $host, bool $expectedResult) } /** - * @return string[] + * @return array */ public static function loopBackAddressCasesProvider(): array { diff --git a/tests/Credentials/EcsCredentialProviderTest.php b/tests/Credentials/EcsCredentialProviderTest.php index 47bd9645e6..1571b1c6f3 100644 --- a/tests/Credentials/EcsCredentialProviderTest.php +++ b/tests/Credentials/EcsCredentialProviderTest.php @@ -19,8 +19,9 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; -#[CoversClass(\Aws\Credentials\EcsCredentialProvider::class)] +#[CoversClass(EcsCredentialProvider::class)] class EcsCredentialProviderTest extends TestCase { private $uripath; @@ -145,9 +146,6 @@ public function testNoProxying() putenv("NO_PROXY=$no"); } - /** - - */ #[DataProvider('uriAndTokenResolutionProvider')] public function testUriAndTokenResolution($case) { @@ -366,12 +364,10 @@ public function testResolveCredentialsWithAccountIdFromArn() } /** - * * @param array $clientDef * @param CredentialsInterface $expected * @throws GuzzleException - - */ + */ #[DataProvider('successDataProvider')] public function testHandlesSuccessScenarios( array $clientDef, @@ -422,7 +418,7 @@ public static function successDataProvider(): array $promiseCreds = Promise\Create::promiseFor( new Response(200, [], Psr7\Utils::streamFor( json_encode(call_user_func_array( - [__CLASS__, 'getCredentialArray'], + [self::class, 'getCredentialArray'], $creds ))) ) @@ -462,16 +458,14 @@ public static function successDataProvider(): array } /** - * * @param $client * @param \Exception $expected - * + * * @throws GuzzleException - - */ + */ #[DataProvider('failureDataProvider')] public function testHandlesFailureScenarios( - array $responses, + array $responses, \Exception $expected ) { diff --git a/tests/Credentials/LoginCredentialProviderTest.php b/tests/Credentials/LoginCredentialProviderTest.php index 575a5ddffc..a2943a3d51 100644 --- a/tests/Credentials/LoginCredentialProviderTest.php +++ b/tests/Credentials/LoginCredentialProviderTest.php @@ -301,9 +301,6 @@ public function testLoadTokenFailsWithInvalidJson(): void $provider()->wait(); } - /** - - */ #[DataProvider('missingCacheKeysProvider')] public function testLoadTokenFailsWithMissingOrEmptyCacheKeys( array $tokenData, @@ -1250,9 +1247,6 @@ public function testLoadCredentialsWithSpecifiedCurveKey(): void $this->assertEquals('123456789012', $credentials->getAccountId()); } - /** - - */ #[DataProvider('loginTestCasesProvider')] public function testLoginCredentialProviderFromTestCases( string $documentation, @@ -1409,9 +1403,6 @@ public static function loginTestCasesProvider(): \Generator } } - /** - - */ #[DataProvider('externalRefreshProvider')] public function testExternalRefreshBehavior( string $scenario, diff --git a/tests/Crypto/AesDecryptingStreamTest.php b/tests/Crypto/AesDecryptingStreamTest.php index 90e2762a97..7092d25a27 100644 --- a/tests/Crypto/AesDecryptingStreamTest.php +++ b/tests/Crypto/AesDecryptingStreamTest.php @@ -6,9 +6,11 @@ use Aws\Crypto\Cipher\CipherMethod; use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; +#[CoversClass(AesDecryptingStream::class)] class AesDecryptingStreamTest extends TestCase { const KB = 1024; @@ -16,12 +18,6 @@ class AesDecryptingStreamTest extends TestCase use AesEncryptionStreamTestTrait; - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, @@ -59,12 +55,6 @@ public function testStreamOutputSameAsOpenSSL( ); } - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testReportsSizeOfPlaintextWherePossible( StreamInterface $plainText, @@ -91,12 +81,6 @@ public function testReportsSizeOfPlaintextWherePossible( } } - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testSupportsRewinding( StreamInterface $plainText, @@ -116,11 +100,6 @@ public function testSupportsRewinding( $this->assertSame($firstBytes, $deciphered->read(256 * 2 + 3)); } - /** - * - * @param CipherMethod $iv - - */ #[DataProvider('cipherMethodProvider')] public function testMemoryUsageRemainsConstant(CipherMethod $iv) { @@ -159,11 +138,6 @@ public function testDoesNotSupportArbitrarySeeking() $stream->seek(1); } - /** - * - * @param CipherMethod $cipherMethod - - */ #[DataProvider('cipherMethodProvider')] public function testReturnsEmptyStringWhenSourceStreamEmpty( CipherMethod $cipherMethod diff --git a/tests/Crypto/AesEncryptingStreamTest.php b/tests/Crypto/AesEncryptingStreamTest.php index b8c5dc78ce..2f2a0514ab 100644 --- a/tests/Crypto/AesEncryptingStreamTest.php +++ b/tests/Crypto/AesEncryptingStreamTest.php @@ -8,8 +8,10 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(AesEncryptingStream::class)] class AesEncryptingStreamTest extends TestCase { const KB = 1024; @@ -17,12 +19,6 @@ class AesEncryptingStreamTest extends TestCase use AesEncryptionStreamTestTrait; - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, @@ -44,12 +40,6 @@ public function testStreamOutputSameAsOpenSSL( ); } - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testGetOpenSslName( StreamInterface $plainText, @@ -65,12 +55,6 @@ public function testGetOpenSslName( ); } - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testGetCurrentIv( StreamInterface $plainText, @@ -86,12 +70,6 @@ public function testGetCurrentIv( ); } - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testSupportsRewinding( StreamInterface $plainText, @@ -104,12 +82,6 @@ public function testSupportsRewinding( $this->assertSame($firstBytes, $cipherText->read(256 * 2 + 3)); } - /** - * - * @param StreamInterface $plainText - * @param CipherMethod $iv - - */ #[DataProvider('cartesianJoinInputCipherMethodProvider')] public function testAccuratelyReportsSizeOfCipherText( StreamInterface $plainText, @@ -120,11 +92,6 @@ public function testAccuratelyReportsSizeOfCipherText( $this->assertSame($cipherText->getSize(), strlen((string) $cipherText)); } - /** - * - * @param CipherMethod $cipherMethod - - */ #[DataProvider('cipherMethodProvider')] public function testMemoryUsageRemainsConstant(CipherMethod $cipherMethod) { @@ -155,11 +122,6 @@ public function testIsNotWritable() $this->assertFalse($stream->isWritable()); } - /** - * - * @param CipherMethod $cipherMethod - - */ #[DataProvider('cipherMethodProvider')] public function testReturnsPaddedOrEmptyStringWhenSourceStreamEmpty( CipherMethod $cipherMethod @@ -176,11 +138,6 @@ public function testReturnsPaddedOrEmptyStringWhenSourceStreamEmpty( $this->assertSame($stream->read(self::MB), ''); } - /** - * - * @param CipherMethod $cipherMethod - - */ #[DataProvider('cipherMethodProvider')] public function testDoesNotSupportSeekingFromEnd(CipherMethod $cipherMethod) { @@ -190,10 +147,6 @@ public function testDoesNotSupportSeekingFromEnd(CipherMethod $cipherMethod) $stream->seek(1, SEEK_END); } - /** - * - * @param CipherMethod $cipherMethod - */ #[DataProvider('seekableCipherMethodProvider')] public function testSupportsSeekingFromCurrentPosition( CipherMethod $cipherMethod diff --git a/tests/Crypto/AesGcmDecryptingStreamTest.php b/tests/Crypto/AesGcmDecryptingStreamTest.php index cca92e233d..200c7f36df 100644 --- a/tests/Crypto/AesGcmDecryptingStreamTest.php +++ b/tests/Crypto/AesGcmDecryptingStreamTest.php @@ -5,18 +5,14 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(AesGcmDecryptingStream::class)] class AesGcmDecryptingStreamTest extends TestCase { use AesEncryptionStreamTestTrait; - /** - * - * @param StreamInterface $plainText - * @param int $keySize - - */ #[DataProvider('cartesianJoinInputKeySizeProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, @@ -56,12 +52,6 @@ public function testStreamOutputSameAsOpenSSL( $this->assertSame((string) $decryptingStream, $plainText); } - /** - * - * @param StreamInterface $plainText - * @param int $keySize - - */ #[DataProvider('cartesianJoinInputKeySizeProvider')] public function testThrowsForInvalidTag( StreamInterface $plainText, diff --git a/tests/Crypto/AesGcmEncryptingStreamTest.php b/tests/Crypto/AesGcmEncryptingStreamTest.php index d729201c0b..dc12106a65 100644 --- a/tests/Crypto/AesGcmEncryptingStreamTest.php +++ b/tests/Crypto/AesGcmEncryptingStreamTest.php @@ -5,18 +5,14 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(AesGcmEncryptingStream::class)] class AesGcmEncryptingStreamTest extends TestCase { use AesEncryptionStreamTestTrait; - /** - * - * @param StreamInterface $plainText - * @param int $keySize - - */ #[DataProvider('cartesianJoinInputKeySizeProvider')] public function testStreamOutputSameAsOpenSSL( StreamInterface $plainText, @@ -53,9 +49,6 @@ public function testStreamOutputSameAsOpenSSL( $this->assertSame($tag, $encryptingStream->getTag()); } - /** - - */ #[DataProvider('encryptDataProvider')] public function testCorrectlyEncryptsData( $plaintext, @@ -85,7 +78,7 @@ public function testCorrectlyEncryptsData( ); } - public static function encryptDataProvider() + public static function encryptDataProvider(): array { // [[ $plaintext, $key, $iv, $aad, $keySize, $expectedCipher, $expectedTag ]] return [ diff --git a/tests/Crypto/AlgorithmSuiteTest.php b/tests/Crypto/AlgorithmSuiteTest.php index 4fe039d3d8..033bef3021 100644 --- a/tests/Crypto/AlgorithmSuiteTest.php +++ b/tests/Crypto/AlgorithmSuiteTest.php @@ -5,11 +5,11 @@ use Aws\Crypto\AlgorithmConstants; use Aws\Crypto\MaterialsProviderV3; use Aws\S3\Crypto\S3EncryptionClientV3; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Crypto\AlgorithmSuite::class)] +#[CoversClass(AlgorithmSuite::class)] class AlgorithmSuiteTest extends TestCase { /** @@ -95,8 +95,7 @@ public static function cipherNameProvider(): array /** * Test getCipherName() method - - */ + */ #[DataProvider('cipherNameProvider')] public function testGetCipherName(AlgorithmSuite $suite, string $expectedCipher): void { @@ -149,8 +148,7 @@ public static function ivLengthProvider(): array /** * Test getIvLengthBits() and getIvLengthBytes() methods - - */ + */ #[DataProvider('ivLengthProvider')] public function testGetIvLength(AlgorithmSuite $suite, int $expectedBits, int $expectedBytes): void { @@ -184,8 +182,7 @@ public static function cipherTagLengthProvider(): array /** * Test getCipherTagLengthBits() and getCipherTagLengthInBytes() methods - - */ + */ #[DataProvider('cipherTagLengthProvider')] public function testGetCipherTagLength(AlgorithmSuite $suite, int $expectedBits, int $expectedBytes): void { @@ -235,8 +232,7 @@ public static function keyDerivationProvider(): array /** * Test key derivation length methods - - */ + */ #[DataProvider('keyDerivationProvider')] public function testGetDerivationKeyLengths( AlgorithmSuite $suite, @@ -283,8 +279,7 @@ public static function commitmentKeyLengthProvider(): array /** * Test commitment key length methods - - */ + */ #[DataProvider('commitmentKeyLengthProvider')] public function testGetCommitmentKeyLengths( AlgorithmSuite $suite, diff --git a/tests/Crypto/Cipher/CbcTest.php b/tests/Crypto/Cipher/CbcTest.php index ee4b6cca0d..7d97e05385 100644 --- a/tests/Crypto/Cipher/CbcTest.php +++ b/tests/Crypto/Cipher/CbcTest.php @@ -2,8 +2,10 @@ namespace Aws\Test\Crypto\Cipher; use Aws\Crypto\Cipher\Cbc; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\TestCase; +#[CoversClass(Cbc::class)] class CbcTest extends TestCase { public function testShouldReportCipherMethodOfCBC() diff --git a/tests/Crypto/EncryptionDecryptionTraitV3Test.php b/tests/Crypto/EncryptionDecryptionTraitV3Test.php index ed03ec7907..edcf66bea8 100644 --- a/tests/Crypto/EncryptionDecryptionTraitV3Test.php +++ b/tests/Crypto/EncryptionDecryptionTraitV3Test.php @@ -19,8 +19,8 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Crypto\EncryptionTraitV3::class)] -#[CoversClass(\Aws\Crypto\DecryptionTraitV3::class)] +#[CoversClass(EncryptionTraitV3::class)] +#[CoversClass(DecryptionTraitV3::class)] class EncryptionDecryptionTraitV3Test extends TestCase { use UsesCryptoParamsTraitV3; @@ -231,8 +231,7 @@ public function testValidV2ObjectHasV2EnvelopeFields(): void } /** - * Tests that a V2 envelope with V3 fields appropriately errors - * @return void + * Tests that a V2 envelope with V3 fields appropriately errors */ public function testV2EnvelopeWithV3FieldsThrows(): void { @@ -286,8 +285,7 @@ public function testV2EnvelopeWithV3FieldsThrows(): void } /** - * Tests that a V3 envelope with V2 fields appropriately errors - * @return void + * Tests that a V3 envelope with V2 fields appropriately errors */ public function testV3EnvelopeWithV2FieldsThrows(): void { @@ -381,11 +379,6 @@ public function testV3EnvelopeECValidSetCorrectly(): void $this->assertEquals($envelope[MetadataEnvelope::ENCRYPTED_DATA_KEY_ALGORITHM_V3], 12); } - /** - * Summary of testDiffAlgorithmSuitesProduceDiffObjectVersions - * @return void - - */ #[DataProvider('getAlgorithmSuites')] public function testDiffAlgorithmSuitesProduceDiffObjectVersions(AlgorithmSuite $algorithmSuite): void { @@ -434,7 +427,6 @@ public function testDiffAlgorithmSuitesProduceDiffObjectVersions(AlgorithmSuite /** * Summary of testDiffAlgorithmSuitesProduceDiffObjectVersions - * @return void */ public function testCbcAlgSuiteProducesV2Envelope(): void { @@ -484,8 +476,7 @@ public function testCbcAlgSuiteProducesV2Envelope(): void /** * Given a CommitmentPolicy assert error gets appropriately thrown if the key commitment policy * does not support decryption of the object. - - */ + */ #[DataProvider('getCommitmentPolicies')] public function testThrowsOnInvalidKCPolicyAndNoKeyCommitmentAlgSuite($commitmentPolicy): void { @@ -564,8 +555,7 @@ public function testThrowsOnInvalidKCPolicyAndNoKeyCommitmentAlgSuite($commitmen /** * Given a CommitmentPolicy assert error gets appropriately thrown if the key commitment policy * does not support decryption of the object. - - */ + */ #[DataProvider('getCommitmentPolicies')] public function testThrowsOnInvalidKCPolicyAndKeyCommitmentAlgSuite($commitmentPolicy): void { diff --git a/tests/Crypto/HkdfKatTest.php b/tests/Crypto/HkdfKatTest.php index 79910a1ad4..6a3b089553 100644 --- a/tests/Crypto/HkdfKatTest.php +++ b/tests/Crypto/HkdfKatTest.php @@ -15,7 +15,9 @@ use GuzzleHttp\Psr7\LimitStream; use PHPUnit\Framework\Constraint\IsEmpty; use Psr\Http\Message\StreamInterface; +use PHPUnit\Framework\Attributes\CoversNothing; +#[CoversNothing] class HkdfKatTest extends TestCase { public static function getKats(): array @@ -48,7 +50,7 @@ public static function getKats(): array ]; } - public function testHkdf(): void + public function testHkdf(): void { $kats = HkdfKatTest::getKats(); foreach ($kats as $kat) { diff --git a/tests/Crypto/KmsMaterialsProviderV2Test.php b/tests/Crypto/KmsMaterialsProviderV2Test.php index 82836c1ffe..ee07f78c0c 100644 --- a/tests/Crypto/KmsMaterialsProviderV2Test.php +++ b/tests/Crypto/KmsMaterialsProviderV2Test.php @@ -9,7 +9,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Crypto\KmsMaterialsProviderV2::class)] +#[CoversClass(KmsMaterialsProviderV2::class)] class KmsMaterialsProviderV2Test extends TestCase { use UsesServiceTrait; diff --git a/tests/Crypto/KmsMaterialsProviderV3Test.php b/tests/Crypto/KmsMaterialsProviderV3Test.php index ae97f18e55..4199d53e7b 100644 --- a/tests/Crypto/KmsMaterialsProviderV3Test.php +++ b/tests/Crypto/KmsMaterialsProviderV3Test.php @@ -9,7 +9,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Crypto\KmsMaterialsProviderV3::class)] +#[CoversClass(KmsMaterialsProviderV3::class)] class KmsMaterialsProviderV3Test extends TestCase { use UsesServiceTrait; diff --git a/tests/Crypto/MetadataEnvelopeTest.php b/tests/Crypto/MetadataEnvelopeTest.php index cf52e17cc0..b13547b405 100644 --- a/tests/Crypto/MetadataEnvelopeTest.php +++ b/tests/Crypto/MetadataEnvelopeTest.php @@ -11,9 +11,6 @@ class MetadataEnvelopeTest extends TestCase { use UsesMetadataEnvelopeTrait; - /** - - */ #[DataProvider('getIndividualMetadataFields')] public function testSetsValidFields($field, $value) { @@ -23,9 +20,6 @@ public function testSetsValidFields($field, $value) $this->assertEquals($value, $envelope[$field]); } - /** - - */ #[DataProvider('getMetadataFields')] public function testSetsAllFields($allValidFields) { @@ -40,9 +34,6 @@ public function testSetsAllFields($allValidFields) ); } - /** - - */ #[DataProvider('getIndividualInvalidMetadataFields')] public function testThrowsOnInvalidMetadataField($field, $value) { @@ -69,7 +60,7 @@ public function testNoReservedPrefixInEnvelope(): void $this->assertStringStartsNotWith('x-amz-meta', $envelopeKey); } } - + /** * Tests that all the metadata mapkeys are prefixed with * `x-amz-` @@ -86,5 +77,4 @@ public function testReservedPrefixInEnvelope(): void $this->assertStringStartsWith('x-amz-', $envelopeKey); } } - } diff --git a/tests/Crypto/UsesCryptoParamsTrait.php b/tests/Crypto/UsesCryptoParamsTrait.php index 47c8b2c2af..75e5345932 100644 --- a/tests/Crypto/UsesCryptoParamsTrait.php +++ b/tests/Crypto/UsesCryptoParamsTrait.php @@ -146,4 +146,4 @@ public function getKeySizes() ] ]; } -} \ No newline at end of file +} diff --git a/tests/Crypto/UsesMetadataEnvelopeTrait.php b/tests/Crypto/UsesMetadataEnvelopeTrait.php index df64400f1a..1ec784767f 100644 --- a/tests/Crypto/UsesMetadataEnvelopeTrait.php +++ b/tests/Crypto/UsesMetadataEnvelopeTrait.php @@ -5,7 +5,7 @@ trait UsesMetadataEnvelopeTrait { - public function getIndividualMetadataFields(): array + public static function getIndividualMetadataFields(): array { return [ [ @@ -39,12 +39,12 @@ public function getIndividualMetadataFields(): array ]; } - public function getIndividualV3MetadataFields(): array + public static function getIndividualV3MetadataFields(): array { return [ [ MetadataEnvelope::ENCRYPTED_DATA_KEY_V3, - 1 + 1 ], [ MetadataEnvelope::MAT_DESC_V3, @@ -71,15 +71,14 @@ public function getIndividualV3MetadataFields(): array 7 ] ]; - } - public function getIndividualV3MetadataOnlyFields(): array + public static function getIndividualV3MetadataOnlyFields(): array { return [ [ MetadataEnvelope::CONTENT_CIPHER_V3, - 1 + 1 ], [ MetadataEnvelope::KEY_COMMITMENT_V3, @@ -90,15 +89,14 @@ public function getIndividualV3MetadataOnlyFields(): array 3 ] ]; - } - public function getIndividualV3InstructionFileOnlyFields(): array + public static function getIndividualV3InstructionFileOnlyFields(): array { return [ [ MetadataEnvelope::ENCRYPTED_DATA_KEY_V3, - 4 + 4 ], [ MetadataEnvelope::MAT_DESC_V3, @@ -113,15 +111,14 @@ public function getIndividualV3InstructionFileOnlyFields(): array 7 ], ]; - } - public function getIndividualV3DuplicateKeysInstructionFileOnlyFields(): array + public static function getIndividualV3DuplicateKeysInstructionFileOnlyFields(): array { return [ [ MetadataEnvelope::ENCRYPTED_DATA_KEY_V3, - 4 + 4 ], [ MetadataEnvelope::MAT_DESC_V3, @@ -142,9 +139,9 @@ public function getIndividualV3DuplicateKeysInstructionFileOnlyFields(): array ]; } - public function getCondensedFields(): array + public static function getCondensedFields(): array { - $individualMetadataFields = $this->getIndividualMetadataFields(); + $individualMetadataFields = self::getIndividualMetadataFields(); $fields = []; foreach ($individualMetadataFields as $fieldInfo) { $fields[$fieldInfo[0]] = $fieldInfo[1]; @@ -153,9 +150,9 @@ public function getCondensedFields(): array return $fields; } - public function getCondensedV3Fields(): array + public static function getCondensedV3Fields(): array { - $individualMetadataFields = $this->getIndividualV3MetadataFields(); + $individualMetadataFields = self::getIndividualV3MetadataFields(); $fields = []; foreach ($individualMetadataFields as $fieldInfo) { $fields[$fieldInfo[0]] = $fieldInfo[1]; @@ -164,22 +161,20 @@ public function getCondensedV3Fields(): array return $fields; } - public function getMetadataOnlyCondensedV3Fields(): array + public static function getMetadataOnlyCondensedV3Fields(): array { - $individualMetadataFields = $this->getIndividualV3MetadataOnlyFields(); + $individualMetadataFields = self::getIndividualV3MetadataOnlyFields(); $fields = []; foreach ($individualMetadataFields as $fieldInfo) { $fields[$fieldInfo[0]] = $fieldInfo[1]; } return $fields; - } - public function getInstructionFileOnlyCondensedV3Fields(): array + public static function getInstructionFileOnlyCondensedV3Fields(): array { - - $individualMetadataFields = $this->getIndividualV3InstructionFileOnlyFields(); + $individualMetadataFields = self::getIndividualV3InstructionFileOnlyFields(); $fields = []; foreach ($individualMetadataFields as $fieldInfo) { $fields[$fieldInfo[0]] = $fieldInfo[1]; @@ -188,9 +183,9 @@ public function getInstructionFileOnlyCondensedV3Fields(): array return $fields; } - public function getV3DuplicateKeysForInstructionFile(): array + public static function getV3DuplicateKeysForInstructionFile(): array { - $individualMetadataFields = $this->getIndividualV3DuplicateKeysInstructionFileOnlyFields(); + $individualMetadataFields = self::getIndividualV3DuplicateKeysInstructionFileOnlyFields(); $fields = []; foreach ($individualMetadataFields as $fieldInfo) { $fields[$fieldInfo[0]] = $fieldInfo[1]; @@ -209,9 +204,9 @@ public function getFieldsAsMetaHeaders($fields): array return $metadataFields; } - public function getMetadataFields(): array + public static function getMetadataFields(): array { - $fields = $this->getCondensedFields(); + $fields = self::getCondensedFields(); return [ [ @@ -220,17 +215,17 @@ public function getMetadataFields(): array ]; } - public function getV3MetadataFields(): array + public static function getV3MetadataFields(): array { - $fields = $this->getCondensedV3Fields(); + $fields = self::getCondensedV3Fields(); return [ [$fields] ]; } - public function getMetadataResult(): array + public static function getMetadataResult(): array { - $fields = $this->getCondensedFields(); + $fields = self::getCondensedFields(); return [ [ @@ -244,9 +239,9 @@ public function getMetadataResult(): array ]; } - public function getV3MetadataResult(): array + public static function getV3MetadataResult(): array { - $fields = $this->getCondensedV3Fields(); + $fields = self::getCondensedV3Fields(); return [ [ @@ -260,10 +255,10 @@ public function getV3MetadataResult(): array ]; } - public function getV3FieldsForInstructionFile(): array + public static function getV3FieldsForInstructionFile(): array { - $metadataOnlyFields = $this->getMetadataOnlyCondensedV3Fields(); - $instructionFileOnlyFields = $this->getInstructionFileOnlyCondensedV3Fields(); + $metadataOnlyFields = self::getMetadataOnlyCondensedV3Fields(); + $instructionFileOnlyFields = self::getInstructionFileOnlyCondensedV3Fields(); return [ [ @@ -274,7 +269,7 @@ public function getV3FieldsForInstructionFile(): array ], $instructionFileOnlyFields ] - ]; + ]; } public function getMetadataEnvelope($fields): MetadataEnvelope @@ -289,14 +284,14 @@ public function getMetadataEnvelope($fields): MetadataEnvelope public function getV3InstructionFileFields($fields): MetadataEnvelope { - $envelope = $this->getMetadataEnvelope($fields); + $envelope = $this->getMetadataEnvelope($fields); unset($envelope[MetadataEnvelope::CONTENT_CIPHER_V3]); unset($envelope[MetadataEnvelope::KEY_COMMITMENT_V3]); unset($envelope[MetadataEnvelope::MESSAGE_ID_V3]); return $envelope; } - public function getIndividualInvalidMetadataFields(): array + public static function getIndividualInvalidMetadataFields(): array { return [ [ diff --git a/tests/DSQL/AuthTokenGeneratorTest.php b/tests/DSQL/AuthTokenGeneratorTest.php index 4a4b6612da..cba6479504 100644 --- a/tests/DSQL/AuthTokenGeneratorTest.php +++ b/tests/DSQL/AuthTokenGeneratorTest.php @@ -13,14 +13,6 @@ #[CoversClass(AuthTokenGenerator::class)] class AuthTokenGeneratorTest extends TestCase { - /** - * @param $endpoint - * @param $credentials - * @param $action - * @return void - * - - */ #[DataProvider('generateAuthTokenProvider')] public function testGeneratesAuthToken($credentials, $action) { @@ -39,8 +31,9 @@ public function testGeneratesAuthToken($credentials, $action) $this->assertStringNotContainsString('https://', $token); } - public static function generateAuthTokenProvider() - { $accessKeyId = 'AKID'; + public static function generateAuthTokenProvider(): array + { + $accessKeyId = 'AKID'; $secretKeyId = 'SECRET'; $credentials = new Credentials($accessKeyId, $secretKeyId); $credentialProvider = static function () use ($accessKeyId, $secretKeyId) { @@ -57,14 +50,6 @@ public static function generateAuthTokenProvider() ]; } - /** - * @param $action - * @param $endpoint - * @param $region - * @return void - * - - */ #[DataProvider('missingInputProvider')] public function testThrowsOnMissingInput($action, $endpoint, $region) { @@ -77,7 +62,7 @@ public function testThrowsOnMissingInput($action, $endpoint, $region) ); } - public static function missingInputProvider() + public static function missingInputProvider(): array { return [ ['generateDbConnectAuthToken', 'foo.bar.baz', null], @@ -87,15 +72,6 @@ public static function missingInputProvider() ]; } - /** - * @param $action - * @param $endpoint - * @param $region - * - * @return void - * - - */ #[DataProvider('emptyInputProvider')] public function testThrowsOnEmptyInput($action, $endpoint, $region) { @@ -109,7 +85,7 @@ public function testThrowsOnEmptyInput($action, $endpoint, $region) ); } - public static function emptyInputProvider() + public static function emptyInputProvider(): array { return [ ['generateDbConnectAuthToken', 'foo.bar.baz', ''], @@ -119,7 +95,7 @@ public static function emptyInputProvider() ]; } - public static function lifetimeFailureProvider() + public static function lifetimeFailureProvider(): array { return [ [0, 'generateDbConnectAuthToken'], @@ -129,11 +105,6 @@ public static function lifetimeFailureProvider() ]; } - /** - * - * @param $lifetime - - */ #[DataProvider('lifetimeFailureProvider')] public function testThrowsExceptionWithInvalidLifetime($expiration, $action) { diff --git a/tests/DefaultsMode/ConfigurationProviderTest.php b/tests/DefaultsMode/ConfigurationProviderTest.php index 37c7f23e01..0b4fbbe1d6 100644 --- a/tests/DefaultsMode/ConfigurationProviderTest.php +++ b/tests/DefaultsMode/ConfigurationProviderTest.php @@ -12,7 +12,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\DefaultsMode\ConfigurationProvider::class)] +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -349,7 +349,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public static function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData(): array { $expected = new Configuration('standard'); return [ @@ -375,11 +375,6 @@ function () use ($expected) { ]; } - /** - * @param $toUnwrap - * @param ConfigurationInterface $expected - - */ #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { @@ -389,7 +384,6 @@ public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expecte ); } - public function testCreatesLegacy() { $config = new Configuration(); diff --git a/tests/DefaultsMode/ConfigurationTest.php b/tests/DefaultsMode/ConfigurationTest.php index 9ab87fccb7..3c2448f170 100644 --- a/tests/DefaultsMode/ConfigurationTest.php +++ b/tests/DefaultsMode/ConfigurationTest.php @@ -6,7 +6,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\DefaultsMode\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/DocDb/DocDbClientTest.php b/tests/DocDb/DocDbClientTest.php index e097a5eb62..68c17c58ed 100644 --- a/tests/DocDb/DocDbClientTest.php +++ b/tests/DocDb/DocDbClientTest.php @@ -26,7 +26,7 @@ public static function tear_down_after_class() $_SERVER['formatAwsTime'] = null; } - public static function DocDbPresignMethodProvider() + public static function DocDbPresignMethodProvider(): array { return [ ['CopyDBClusterSnapshot', ['SourceDBClusterSnapshotIdentifier' => 'arn:aws:rds:us-east-1:123456789012:cluster-snapshot:source-db-cluster-snapshot', 'TargetDBClusterSnapshotIdentifier' => 'target-db-cluster-snapshot'], null, null, null, null], @@ -35,15 +35,6 @@ public static function DocDbPresignMethodProvider() ]; } - /** - * - * @param string $functionName - * @param string $presignedUrl - * @param string $sourceRegion - * @param string $expectedUrl - * @param string $expectedSignature - - */ #[DataProvider('DocDbPresignMethodProvider')] public function testCorrectPresignDocDbUrls( $functionName, @@ -86,4 +77,3 @@ public function testCorrectPresignDocDbUrls( call_user_func([$docDb, $functionName], $functionArgs); } } - diff --git a/tests/DoctrineCacheAdapterTest.php b/tests/DoctrineCacheAdapterTest.php index 7ce21f324c..2217c27608 100644 --- a/tests/DoctrineCacheAdapterTest.php +++ b/tests/DoctrineCacheAdapterTest.php @@ -4,8 +4,10 @@ use Aws\CacheInterface; use Aws\DoctrineCacheAdapter; use Doctrine\Common\Cache\Cache; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +#[CoversClass(DoctrineCacheAdapter::class)] class DoctrineCacheAdapterTest extends TestCase { public function testProxiesCallsToDoctrine() diff --git a/tests/DynamoDb/DynamoDbClientTest.php b/tests/DynamoDb/DynamoDbClientTest.php index 9b139c7beb..288260449f 100644 --- a/tests/DynamoDb/DynamoDbClientTest.php +++ b/tests/DynamoDb/DynamoDbClientTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\DynamoDb\DynamoDbClient::class)] +#[CoversClass(DynamoDbClient::class)] class DynamoDbClientTest extends TestCase { use UsesServiceTrait; @@ -31,7 +31,7 @@ public function testRegisterSessionHandlerReturnsHandler() ); } - public function dataForFormatValueTest() + public static function dataForFormatValueTest(): array { $handle = fopen('php://memory', 'w+'); fwrite($handle, 'foo'); @@ -84,9 +84,6 @@ public function dataForFormatValueTest() ]; } - /** - - */ #[DataProvider('dataProviderRetrySettings')] public function testRetriesOnDynamoSpecificRetryableException($settings) { @@ -138,7 +135,7 @@ public function testRetriesOnDynamoSpecificRetryableException($settings) $this->assertSame(3, $attemptCount); } - public static function dataProviderRetrySettings() + public static function dataProviderRetrySettings(): array { return [ [ @@ -189,11 +186,6 @@ public function testValidatesAndRetriesCrc32() $this->assertEmpty($queue); } - /** - * - * @param $settings - - */ #[DataProvider('dataProviderRetrySettings')] public function testAppliesRetryStatsConfig($settings) { diff --git a/tests/DynamoDb/MarshalerTest.php b/tests/DynamoDb/MarshalerTest.php index 55fe5e93b8..23f670563a 100644 --- a/tests/DynamoDb/MarshalerTest.php +++ b/tests/DynamoDb/MarshalerTest.php @@ -27,7 +27,7 @@ public function testMarshalValueUseCases($value, $expectedResult, $options = []) $this->assertSame($expectedResult, $actualResult); } - public static function getMarshalValueUseCases() + public static function getMarshalValueUseCases(): array { $m = new Marshaler; @@ -237,7 +237,6 @@ public function testErrorIfMarshalingBadJsonDoc() (new Marshaler)->marshalJson('foo'); } - public function testUnmarshalingHandlesAllDynamoDbTypes() { $item = [ @@ -341,7 +340,7 @@ public function testCanWrapLargeNumbersWithOption() $this->assertSame('99999999999999999999', (string) iterator_to_array($result['foo'])[0]); $this->assertSame('99999999999999999999.99999999999999999999', (string) $result['bar']); } - + public function testNumberValueCanBeFormattedAndSerialized() { $number = new NumberValue('99999999999999999999'); diff --git a/tests/DynamoDb/WriteRequestBatchTest.php b/tests/DynamoDb/WriteRequestBatchTest.php index 922972d88e..f0b473b891 100644 --- a/tests/DynamoDb/WriteRequestBatchTest.php +++ b/tests/DynamoDb/WriteRequestBatchTest.php @@ -23,9 +23,6 @@ public function testInstantiateWriteRequestBatch() $this->assertSame(50, $this->getPropertyValue($batch, 'config')['threshold']); } - /** - - */ #[DataProvider('getInvalidArgUseCases')] public function testInstantiationFailsOnInvalidArgs($config) { @@ -33,7 +30,7 @@ public function testInstantiationFailsOnInvalidArgs($config) new WriteRequestBatch($this->getTestClient('DynamoDb'), $config); } - public static function getInvalidArgUseCases() + public static function getInvalidArgUseCases(): array { return [ [['batch_size' => 1]], diff --git a/tests/Ec2/Ec2ClientTest.php b/tests/Ec2/Ec2ClientTest.php index 568e4a4706..e3c6e28759 100644 --- a/tests/Ec2/Ec2ClientTest.php +++ b/tests/Ec2/Ec2ClientTest.php @@ -94,7 +94,6 @@ function ($command, $request) { public function testSkipEmptyListSerialization() { - $ec2Client = new Ec2Client([ 'region' => 'us-east-1', 'http_handler' => function (RequestInterface $request) { diff --git a/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php b/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php index d4a62b3440..e504b1d352 100644 --- a/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php +++ b/tests/ElasticLoadBalancingV2/ElasticLoadBalancingV2ClientTest.php @@ -1,6 +1,7 @@ assertEquals($output, $p($input)); } - public static function endpointProvider() + public static function endpointProvider(): array { return [ [ @@ -155,12 +152,10 @@ public static function endpointProvider() } /** - * * @param string $region * @param string $service * @param string $partition - - */ + */ #[DataProvider('partitionRegionProvider')] public function testResolvesPartitionsByRegion($region, $service, $partition) { @@ -169,7 +164,7 @@ public function testResolvesPartitionsByRegion($region, $service, $partition) $this->assertSame($partition, $p->getPartition($region, $service)->getName()); } - public static function partitionRegionProvider() + public static function partitionRegionProvider(): array { return [ ['us-east-1', 's3', 'aws'], @@ -218,13 +213,11 @@ public function testPassesOptionsToProvider() } /** - * * @param PartitionEndpointProvider $provider * @param $region * @param $service * @param $endpoint - - */ + */ #[DataProvider('knownEndpointProvider')] public function testCanGenerateKnownEndpointsKnownToPatternProvider( PartitionEndpointProvider $provider, @@ -296,7 +289,7 @@ public function testCanMergePrefixData() } } - public static function knownEndpointProvider() + public static function knownEndpointProvider(): array { $partitions = PartitionEndpointProvider::defaultProvider(); diff --git a/tests/Endpoint/PartitionTest.php b/tests/Endpoint/PartitionTest.php index b040a595f1..c7a3e7d4b1 100644 --- a/tests/Endpoint/PartitionTest.php +++ b/tests/Endpoint/PartitionTest.php @@ -9,14 +9,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Endpoint\Partition::class)] +#[CoversClass(Partition::class)] class PartitionTest extends TestCase { - /** - * - * @param array $definition - - */ #[DataProvider('partitionDefinitionProvider')] public function testAcceptsValidDefinitions(array $definition) { @@ -26,11 +21,6 @@ public function testAcceptsValidDefinitions(array $definition) ); } - /** - * - * @param array $invalidDefinition - - */ #[DataProvider('invalidPartitionDefinitionProvider')] public function testRejectsInvalidDefinitions(array $invalidDefinition) { @@ -39,11 +29,6 @@ public function testRejectsInvalidDefinitions(array $invalidDefinition) new Partition($invalidDefinition); } - /** - * - * @param array $definition - - */ #[DataProvider('partitionDefinitionProvider')] public function testReportsData(array $definition) { @@ -56,11 +41,7 @@ public function testReportsData(array $definition) (new Partition($definition))->getDnsSuffix() ); } - /** - * - * @param array $definition - */ #[DataProvider('partitionDefinitionProvider')] public function testFipsEndpoint(array $definition) { @@ -108,11 +89,6 @@ public static function invalidPartitionDefinitionProvider(): array return $return; } - /** - * - * @param array $definition - - */ #[DataProvider('partitionDefinitionProvider')] public function testReportsRegionMatches(array $definition) { @@ -122,16 +98,10 @@ public function testReportsRegionMatches(array $definition) $this->assertFalse($partition->isRegionMatch('foo', 'bar')); } - /** - * - * @param array $definition - - */ #[DataProvider('partitionDefinitionProvider')] public function testReportsRegionMatchesByPattern(array $definition) { - $definition['regionRegex'] = '^fo[\w]{1 - $this->assertTrue(true);}'; + $definition['regionRegex'] = '^fo[\w]{1}'; $partition = new Partition($definition); $this->assertTrue($partition->isRegionMatch('foo', 's3')); @@ -139,14 +109,6 @@ public function testReportsRegionMatchesByPattern(array $definition) $this->assertFalse($partition->isRegionMatch('bar', 's3')); } - /** - * - * @param Partition $partition - * @param string $service - * @param array $regions - * @param bool $allowNonRegionalEndpoints - - */ #[DataProvider('serviceRegionsProvider')] public function testEnumeratesRegionsForGivenService( Partition $partition, @@ -160,7 +122,7 @@ public function testEnumeratesRegionsForGivenService( )); } - public static function serviceRegionsProvider() + public static function serviceRegionsProvider(): array { $partition = new Partition([ 'partition' => 'foo', @@ -198,14 +160,6 @@ public static function serviceRegionsProvider() ]; } - /** - * - * @param Partition $partition - * @param $region - * @param $service - * @param $signingRegion - - */ #[DataProvider('signingRegionProvider')] public function testDeterminesSigningRegion( Partition $partition, @@ -223,7 +177,7 @@ public function testDeterminesSigningRegion( $this->assertSame($signingRegion, $resolved['signingRegion']); } - public static function signingRegionProvider() + public static function signingRegionProvider(): array { $partition = new Partition([ 'partition' => 'foo', @@ -254,14 +208,6 @@ public static function signingRegionProvider() ]; } - /** - * - * @param Partition $partition - * @param $region - * @param $service - * @param $endpoint - - */ #[DataProvider('endpointProvider')] public function testDeterminesEndpoint( Partition $partition, @@ -279,7 +225,7 @@ public function testDeterminesEndpoint( $this->assertSame($endpoint, $resolved['endpoint']); } - public static function endpointProvider() + public static function endpointProvider(): array { $partition = new Partition([ 'partition' => 'foo', @@ -340,14 +286,6 @@ public function testIgnoresIsRegionalizedFlagIfPartitionEndpointAbsent() $this->assertSame('https://baz.us-east-1.bar', $resolved['endpoint']); } - /** - * - * @param Partition $partition - * @param $region - * @param $service - * @param $signatureVersion - - */ #[DataProvider('signatureVersionProvider')] public function testDeterminesSignatureVersion( Partition $partition, @@ -365,7 +303,7 @@ public function testDeterminesSignatureVersion( $this->assertSame($signatureVersion, $resolved['signatureVersion']); } - public static function signatureVersionProvider() + public static function signatureVersionProvider(): array { $partition = new Partition([ 'partition' => 'foo', @@ -421,14 +359,6 @@ public static function signatureVersionProvider() ]; } - /** - * - * @param Partition $partition - * @param string $region - * @param string $service - * @param string $signingName - - */ #[DataProvider('signingNameProvider')] public function testDeterminesSigningName( Partition $partition, @@ -446,7 +376,7 @@ public function testDeterminesSigningName( $this->assertSame($signingName, $resolved['signingName']); } - public static function signingNameProvider() + public static function signingNameProvider(): array { $partition = new Partition([ 'partition' => 'foo', @@ -494,13 +424,6 @@ public static function signingNameProvider() ]; } - /** - * - * @param $region - * @param $configOption - * @param $expectedEndpoint - - */ #[DataProvider('stsEndpointTestCases')] public function testResolvesStsRegionalEndpoints( $region, @@ -528,7 +451,7 @@ public function testResolvesStsRegionalEndpoints( } - public static function stsEndpointTestCases() + public static function stsEndpointTestCases(): array { return [ [ @@ -594,13 +517,6 @@ public static function stsEndpointTestCases() ]; } - /** - * - * @param $region - * @param $configOption - * @param $expectedEndpoint - - */ #[DataProvider('s3EndpointTestCases')] public function testResolvesS3RegionalEndpoint( $region, @@ -628,7 +544,7 @@ public function testResolvesS3RegionalEndpoint( } - public static function s3EndpointTestCases() + public static function s3EndpointTestCases(): array { return [ [ @@ -679,13 +595,6 @@ public static function s3EndpointTestCases() ]; } - /** - * - * @param array $definition - * @param bool $useFipsConfig - * @param bool $useDualstackConfig - - */ #[DataProvider('variantTagProvider')] public function testGetVariantIgnoresVariantTagOrder( array $definition, @@ -836,13 +745,6 @@ public static function variantTagProvider(): array ]; } - /** - * - * @param array $definition - * @param @fipsConfig - * @param @dualstackConfig - - */ #[DataProvider('variantTagEmptyProvider')] public function testGetVariantNoVariantSelectedIfTagsAreEmpty( array $definition, @@ -993,13 +895,6 @@ public static function variantTagEmptyProvider(): array ]; } - /** - * - * @param array $tags - * @param @fipsConfig - * @param @dualstackConfig - - */ #[DataProvider('booleanConfigProvider')] public function testGetVariantWithBooleanConfigValues( array $tags, @@ -1042,7 +937,7 @@ public function testGetVariantWithBooleanConfigValues( $this->assertStringContainsString('testsuffix.com', $resolved['endpoint']); } - public static function booleanConfigProvider() + public static function booleanConfigProvider(): array { return [ [ diff --git a/tests/Endpoint/PatternEndpointProviderTest.php b/tests/Endpoint/PatternEndpointProviderTest.php index 450b278ae1..32883eefd0 100644 --- a/tests/Endpoint/PatternEndpointProviderTest.php +++ b/tests/Endpoint/PatternEndpointProviderTest.php @@ -16,7 +16,7 @@ public function testReturnsNullWhenUnresolved() $this->assertNull($e(['service' => 'foo', 'region' => 'bar'])); } - public static function endpointProvider() + public static function endpointProvider(): array { return [ [ @@ -72,9 +72,6 @@ public static function endpointProvider() ]; } - /** - - */ #[DataProvider('endpointProvider')] public function testResolvesEndpoints($input, $output) { diff --git a/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php b/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php index 17b5b428a9..2610e9c51b 100644 --- a/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php +++ b/tests/Endpoint/UseDualstackEndpoint/ConfigurationProviderTest.php @@ -1,7 +1,6 @@ assertSame($expected->toArray(), $result->toArray()); } } - diff --git a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php index a14f0fa80c..5de15f2afd 100644 --- a/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseDualstackEndpoint/ConfigurationTest.php @@ -6,15 +6,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Endpoint\UseDualstackEndpoint\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { - /** - * - * @param $param - * @param $expected - - */ #[DataProvider('correctValueCases')] public function testGetsCorrectValues($param, $expected) { @@ -22,7 +16,7 @@ public function testGetsCorrectValues($param, $expected) $this->assertEquals($expected, $config->isuseDualstackEndpoint()); } - public static function correctValueCases() + public static function correctValueCases(): array { return [ [true, true], diff --git a/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php b/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php index 62cd4ab805..6d95b093cf 100644 --- a/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php +++ b/tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php @@ -360,4 +360,3 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } } - diff --git a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php index 04bc457f69..9fe56615ab 100644 --- a/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php +++ b/tests/Endpoint/UseFipsEndpoint/ConfigurationTest.php @@ -6,15 +6,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Endpoint\UseFipsEndpoint\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { - /** - * - * @param $param - * @param $expected - - */ #[DataProvider('correctValueCases')] public function testGetsCorrectValues($param, $expected) { @@ -22,7 +16,7 @@ public function testGetsCorrectValues($param, $expected) $this->assertEquals($expected, $config->isuseFipsEndpoint()); } - public static function correctValueCases() + public static function correctValueCases(): array { return [ [true, true], diff --git a/tests/EndpointDiscovery/ConfigurationProviderTest.php b/tests/EndpointDiscovery/ConfigurationProviderTest.php index 183c1afd30..3e523e1d9e 100644 --- a/tests/EndpointDiscovery/ConfigurationProviderTest.php +++ b/tests/EndpointDiscovery/ConfigurationProviderTest.php @@ -75,10 +75,6 @@ public static function tear_down_after_class() putenv('HOME=' . self::$originalEnv['home']); } - /** - * @param $envName - - */ #[DataProvider('getEnvVariableNames')] public function testCreatesFromEnvironmentVariables($envName) { @@ -89,7 +85,7 @@ public function testCreatesFromEnvironmentVariables($envName) $this->assertSame($expected->toArray(), $result->toArray()); } - public static function getEnvVariableNames() + public static function getEnvVariableNames(): array { return [ [ConfigurationProvider::ENV_ENABLED], @@ -404,7 +400,6 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public function testUsesIniWithUseAwsConfigFileTrue() { $dir = $this->clearEnv(); @@ -433,7 +428,7 @@ public function testIgnoresIniWithUseAwsConfigFileFalse() unlink($dir . '/config'); } - public static function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData(): array { $expected = new Configuration(true, 4000); return [ @@ -470,11 +465,6 @@ function () use ($expected) { ]; } - /** - * @param $toUnwrap - * @param ConfigurationInterface $expected - - */ #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { diff --git a/tests/EndpointDiscovery/ConfigurationTest.php b/tests/EndpointDiscovery/ConfigurationTest.php index eec10981b1..13fc8e7f51 100644 --- a/tests/EndpointDiscovery/ConfigurationTest.php +++ b/tests/EndpointDiscovery/ConfigurationTest.php @@ -4,10 +4,9 @@ use Aws\EndpointDiscovery\Configuration; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use Psr\Log\InvalidArgumentException; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\EndpointDiscovery\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php index b8ccab9c7e..4d610305b9 100644 --- a/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php +++ b/tests/EndpointDiscovery/EndpointDiscoveryMiddlewareTest.php @@ -70,13 +70,6 @@ public function tear_down() $cacheReflection->setValue(null, self::$originalCache); } - /** - * @param array $commandArgs - * @param array $clientArgs - * @param ResultInterface $describeResult - * @param RequestInterface $expected - - */ #[DataProvider('getRequestTestCases')] public function testCorrectlyModifiesRequest( array $commandArgs, @@ -114,7 +107,7 @@ public function testCorrectlyModifiesRequest( $client->execute($command); } - public static function getRequestTestCases() + public static function getRequestTestCases(): array { $baseUri = new Uri('https://awsendpointdiscoverytestservice.us-east-1.amazonaws.com/'); $baseUserAgent = 'aws-sdk-php/' . Sdk::VERSION; @@ -297,12 +290,6 @@ public static function getRequestTestCases() ]; } - /** - * @param CommandInterface $mainCmd - * @param CommandInterface $expectedCmd - * @param RequestInterface $expectedReq - - */ #[DataProvider('getDiscoveryRequestTestCases')] public function testCorrectlyConstructsDiscoveryRequest( CommandInterface $mainCmd, @@ -330,7 +317,7 @@ public function testCorrectlyConstructsDiscoveryRequest( $handler($mainCmd, new Request('POST', new Uri('https://foo.com'))); } - public static function getDiscoveryRequestTestCases() + public static function getDiscoveryRequestTestCases(): array { $baseUri = new Uri('https://awsendpointdiscoverytestservice.us-east-1.amazonaws.com'); $baseRequest = new Request( @@ -552,10 +539,6 @@ public function testThrowsExceptionOnDescribeFailure() } } - /** - * @param $exception - - */ #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testUsesCachedEndpointForInvalidEndpointException($exception) { @@ -588,10 +571,6 @@ public function testUsesCachedEndpointForInvalidEndpointException($exception) $this->assertEquals(['describe', 'failure', 'success'], $callOrder); } - /** - * @param $exception - - */ #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testUseRegionalEndpointForInvalidEndpointException($exception) { @@ -632,10 +611,6 @@ public function testUseRegionalEndpointForInvalidEndpointException($exception) ); } - /** - * @param $exception - - */ #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testThrowsExceptionOnInvalidEndpointException($exception) { @@ -674,10 +649,6 @@ public function testThrowsExceptionOnInvalidEndpointException($exception) $this->assertEquals(['describe', 'failure'], $callOrder); } - /** - * @param $exception - - */ #[DataProvider('invalidEndpointExceptionsDataProvider')] public function testCallsDiscoveryApiOnInvalidEndpointException($exception) { @@ -737,8 +708,6 @@ public function testCallsDiscoveryApiOnInvalidEndpointException($exception) /** * Data provider for exceptions treated as invalid endpoint exceptions - * - * @return array */ public static function invalidEndpointExceptionsDataProvider(): array { diff --git a/tests/EndpointDiscovery/EndpointListTest.php b/tests/EndpointDiscovery/EndpointListTest.php index 9a869feb6b..6c0dc89f63 100644 --- a/tests/EndpointDiscovery/EndpointListTest.php +++ b/tests/EndpointDiscovery/EndpointListTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\EndpointDiscovery\EndpointList::class)] +#[CoversClass(EndpointList::class)] class EndpointListTest extends TestCase { public function testStoresRetrievesAndCyclesActiveEndpoints() diff --git a/tests/EndpointParameterMiddlewareTest.php b/tests/EndpointParameterMiddlewareTest.php index 8a3aea7093..72292e6639 100644 --- a/tests/EndpointParameterMiddlewareTest.php +++ b/tests/EndpointParameterMiddlewareTest.php @@ -10,7 +10,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\EndpointParameterMiddleware::class)] +#[CoversClass(EndpointParameterMiddleware::class)] class EndpointParameterMiddlewareTest extends TestCase { public function testThrowsExceptionForMissingParameter() @@ -66,9 +66,6 @@ public function testThrowsExceptionForInvalidParameter() } } - /** - - */ #[DataProvider('correctlyOutputsHostDataProvider')] public function testCorrectlyOutputsHost( $clientArgs, diff --git a/tests/EndpointV2/EndpointDefinitionProviderTest.php b/tests/EndpointV2/EndpointDefinitionProviderTest.php index e5d77fe66c..6873a6b909 100644 --- a/tests/EndpointV2/EndpointDefinitionProviderTest.php +++ b/tests/EndpointV2/EndpointDefinitionProviderTest.php @@ -3,9 +3,11 @@ namespace Aws\Test\EndpointV2; use Aws\EndpointV2\EndpointDefinitionProvider; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; +#[CoversClass(EndpointDefinitionProvider::class)] class EndpointDefinitionProviderTest extends TestCase { public function testProvidesRuleset() @@ -47,7 +49,7 @@ public function testThrowsExceptionOnInvalidApiVersion() EndpointDefinitionProvider::getEndpointRuleset('s3', '10-22-2022'); } - public static function getEndpointFileProvider() + public static function getEndpointFileProvider(): array { return [ ['Ruleset'], @@ -55,11 +57,6 @@ public static function getEndpointFileProvider() ]; } - /** - * - * @param $type - - */ #[DataProvider('getEndpointFileProvider')] public function testThrowsExceptionOnMissingFiles($type) { @@ -76,4 +73,4 @@ public function testThrowsExceptionOnMissingFiles($type) rmdir($tmpdir . 'data/' . 's3/'); rmdir($tmpdir . 'data'); } -} \ No newline at end of file +} diff --git a/tests/EndpointV2/EndpointProviderV2Test.php b/tests/EndpointV2/EndpointProviderV2Test.php index 7ba6688adc..131decd5e7 100644 --- a/tests/EndpointV2/EndpointProviderV2Test.php +++ b/tests/EndpointV2/EndpointProviderV2Test.php @@ -67,9 +67,6 @@ public static function basicTestCaseProvider(): \Generator } } - /** - - */ #[DataProvider('basicTestCaseProvider')] public function testBasicEndpointAndErrorCases( $ruleset, @@ -130,9 +127,6 @@ public static function serviceTestCaseProvider(): \Generator } } - /** - - */ #[DataProvider('serviceTestCaseProvider')] public function testServiceEndpointAndErrorCases( $service, @@ -226,9 +220,7 @@ public static function rulesetProtocolEndpointAndErrorCaseProvider(): \Generator * End-to-end tests which ensure the correct values are resolved * before being passed into the endpoint provider and after other * middleware has acted upon the request. - * - - */ + */ #[DataProvider('rulesetProtocolEndpointAndErrorCaseProvider')] public function testRulesetProtocolEndpointAndErrorCases($service, $clientArgs, $operationInput, $expected, $errorCase) { @@ -380,10 +372,6 @@ public function testCachesEndpointObject() $endpointProvider->resolveEndpoint(['Region' => 'us-west-2']); } - /** - * @return void - - */ #[DataProvider('stringArrayOperationInputsProvider')] public function testStringArrayOperationInputs( $params, diff --git a/tests/EndpointV2/EndpointV2MiddlewareTest.php b/tests/EndpointV2/EndpointV2MiddlewareTest.php index 64af77483c..2eca25ec8b 100644 --- a/tests/EndpointV2/EndpointV2MiddlewareTest.php +++ b/tests/EndpointV2/EndpointV2MiddlewareTest.php @@ -9,21 +9,14 @@ use Aws\Test\UsesServiceTrait; use ReflectionClass; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(EndpointV2Middleware::class)] class EndpointV2MiddlewareTest extends TestCase { use UsesServiceTrait; - /** - * - * @param $service - * @param $clientArgs - * @param $commandName - * @param $commandArgs - * @param $expectedUri - - */ #[DataProvider('providedSuccessCases')] public function testSuccessfullyResolvesEndpointAndAuthScheme( $service, @@ -49,7 +42,7 @@ public function testSuccessfullyResolvesEndpointAndAuthScheme( $mw($command); } - public static function providedSuccessCases() + public static function providedSuccessCases(): array { return [ [ @@ -122,12 +115,6 @@ function ($command, $endpoint) {}, $method->invoke($middleware, [['name' => 'invalidAuthScheme']]); } - /** - * @param $authSchemes - * @param $expected - * - - */ #[DataProvider('v4aAuthProvider')] public function testV4aAuthSchemeSelection($authSchemes, $expected) { @@ -156,7 +143,7 @@ function ($command, $endpoint) {}, $this->assertSame($expected, $result['version']); } - public static function v4aAuthProvider() + public static function v4aAuthProvider(): array { return [ [ @@ -196,12 +183,9 @@ function ($command, $endpoint) {}, $reflection = new ReflectionClass(EndpointV2Middleware::class); $method = $reflection->getMethod('resolveAuthScheme'); - $method->invoke($middleware, [['name' => 'sigv4a']]); + $method->invoke($middleware, [['name' => 'sigv4a']]); } - /** - - */ #[DataProvider('invalidInitializationProvider')] public function testInitializationWithInvalidParameters( $nextHandler, @@ -258,7 +242,8 @@ function ($command, $endpoint) {}, ]; } - public function testBadParametersOnInvocation() { + public function testBadParametersOnInvocation() + { $this->expectException(\TypeError::class); $nextHandler = function ($command, $endpoint) {}; diff --git a/tests/EndpointV2/EndpointV2SerializerTraitTest.php b/tests/EndpointV2/EndpointV2SerializerTraitTest.php index 25b83e478a..6108495e3d 100644 --- a/tests/EndpointV2/EndpointV2SerializerTraitTest.php +++ b/tests/EndpointV2/EndpointV2SerializerTraitTest.php @@ -80,4 +80,4 @@ public function testThrowsExceptionForInvalidAuthScheme() $handler = $list->resolve(); $handler($command)->wait(); } -} \ No newline at end of file +} diff --git a/tests/EndpointV2/RuleCreatorTest.php b/tests/EndpointV2/RuleCreatorTest.php index f530ac0231..d97c5a5445 100644 --- a/tests/EndpointV2/RuleCreatorTest.php +++ b/tests/EndpointV2/RuleCreatorTest.php @@ -2,15 +2,16 @@ namespace Aws\Test\EndpointV2; use Aws\EndpointV2\Rule; +use Aws\EndpointV2\Rule\RuleCreator; use Aws\Exception\UnresolvedEndpointException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\EndpointV2\Rule\RuleCreator::class)] +#[CoversClass(RuleCreator::class)] class RuleCreatorTest extends TestCase { - public function ruleCreationProvider() + public static function ruleCreationProvider(): array { return [ [ @@ -44,16 +45,13 @@ public function ruleCreationProvider() ]; } - /** - - */ - #[DataProvider('RuleCreationProvider')] + #[DataProvider('ruleCreationProvider')] public function testRuleCreation($spec, $expected) { $result = Rule\RuleCreator::create($spec['type'], $spec); $this->assertInstanceOf($expected, $result); } - public static function invalidRuleTypeProvider() + public static function invalidRuleTypeProvider(): array { return [ ['foo'], @@ -62,9 +60,6 @@ public static function invalidRuleTypeProvider() ]; } - /** - - */ #[DataProvider('invalidRuleTypeProvider')] public function testThrowsExceptionForInvalidRuleType($input) { diff --git a/tests/EndpointV2/RulesetEndpointTest.php b/tests/EndpointV2/RulesetEndpointTest.php index 977f9218d5..e7a8d0eb85 100644 --- a/tests/EndpointV2/RulesetEndpointTest.php +++ b/tests/EndpointV2/RulesetEndpointTest.php @@ -1,8 +1,8 @@ assertSame($spec['default'], $ruleset->getDefault()); } - /** - #[CoversNothing] - * */ #[DataProvider('validTypesProvider')] public function testRulesetCreationWithValidTypes($spec) { new RulesetParameter('FooParam', $spec); $this->assertTrue(true); - $this->assertTrue(true); } public static function validTypesProvider(): array diff --git a/tests/EndpointV2/RulesetStandardLibraryTest.php b/tests/EndpointV2/RulesetStandardLibraryTest.php index 02dc8e2132..22c93d476a 100644 --- a/tests/EndpointV2/RulesetStandardLibraryTest.php +++ b/tests/EndpointV2/RulesetStandardLibraryTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\EndpointV2\Ruleset\RulesetStandardLibrary::class)] +#[CoversClass(RulesetStandardLibrary::class)] class RulesetStandardLibraryTest extends TestCase { private $standardLibrary; @@ -20,7 +20,10 @@ protected function set_up() $this->standardLibrary = new RulesetStandardLibrary($partitions); } - public static function isSetProvider() + /** + * @return array> + */ + public static function isSetProvider(): array { return [ [null, false], @@ -33,19 +36,16 @@ public static function isSetProvider() ]; } - /** - * - * @param $input - * @param $expected - - */ #[DataProvider('isSetProvider')] public function testIsSet($input, $expected) { $this->assertSame($expected, $this->standardLibrary->is_set($input)); } - public static function notProvider() + /** + * @return array> + */ + public static function notProvider(): array { return [ [true, false], @@ -56,19 +56,16 @@ public static function notProvider() ]; } - /** - * - * @param $input - * @param $expected - - */ #[DataProvider('notProvider')] public function testNot($input, $expected) { $this->assertSame($expected, $this->standardLibrary->not($input)); } - public static function getAttrProvider() + /** + * @return array> + */ + public static function getAttrProvider(): array { return [ ['{"Thing1": "foo", "Thing2": ["index0", "index1"], "Thing3": {"SubThing": 42}}', "Thing1", "foo"], @@ -78,12 +75,6 @@ public static function getAttrProvider() ]; } - /** - * - * @param $path - * @param $expected - - */ #[DataProvider('getAttrProvider')] public function testGetAttr($from, $path, $expected) { @@ -97,7 +88,10 @@ public function testGetAttrFromArray() $this->assertSame("foo", $this->standardLibrary->getAttr($from, 0)); } - public static function stringEqualsProvider() + /** + * @return array> + */ + public static function stringEqualsProvider(): array { return [ ["abc", "abc", true], @@ -106,20 +100,16 @@ public static function stringEqualsProvider() ]; } - /** - * - * @param $string1 - * @param $string2 - * @param $expected - - */ #[DataProvider('stringEqualsProvider')] public function testStringEquals($string1, $string2, $expected) { $this->assertSame($expected, $this->standardLibrary->stringEquals($string1, $string2)); } - public static function booleanEqualsProvider() + /** + * @return array> + */ + public static function booleanEqualsProvider(): array { return [ [true, true, true], @@ -137,13 +127,6 @@ public static function booleanEqualsProvider() ]; } - /** - * - * @param $boolean1 - * @param $boolean2 - * @param $expected - - */ #[DataProvider('booleanEqualsProvider')] public function testBooleanEquals($boolean1, $boolean2, $expected) { @@ -156,7 +139,10 @@ public function testParseUrlReturnsNullWithQuery() $this->assertEquals(null, $result); } - public static function isValidHostLabelProvider() + /** + * @return array> + */ + public static function isValidHostLabelProvider(): array { return [ "valid" => ["exampleHostLabel", false, true], @@ -167,20 +153,16 @@ public static function isValidHostLabelProvider() ]; } - /** - * - * @param $hostLabel - * @param $allowSubDomains - * @param $expected - - */ #[DataProvider('isValidHostLabelProvider')] public function testIsValidHostLabel($hostLabel, $allowSubDomains, $expected) { $this->assertSame($expected, $this->standardLibrary->isValidHostLabel($hostLabel, $allowSubDomains)); } - public static function resolveTemplateStringProvider() + /** + * @return array> + */ + public static function resolveTemplateStringProvider(): array { $params = [ 'ShorthandSyntax' => [ @@ -226,13 +208,6 @@ public static function resolveTemplateStringProvider() ]; } - /** - * - * @param $string - * @param $inputParams - * @param $expected - - */ #[DataProvider('resolveTemplateStringProvider')] public function testResolveTemplateString($string, $inputParams, $expected) { @@ -240,7 +215,10 @@ public function testResolveTemplateString($string, $inputParams, $expected) $this->assertEquals($expected, $result); } - public static function NullParamProvider() + /** + * @return array> + */ + public static function NullParamProvider(): array { $params = [ 'Region' => 'us-east-1', @@ -261,12 +239,6 @@ public static function NullParamProvider() ]; } - /** - * - * @param $string - * @param $inputParams - - */ #[DataProvider('NullParamProvider')] public function testResolveTemplateStringThrowsExceptionIfNullParam($string, $inputParams) { @@ -334,4 +306,3 @@ public function testCallFunctionThrowsErrorIfAlreadyAssigned() { $this->standardLibrary->callFunction($condition, $inputParameters); } } - diff --git a/tests/EventBridge/EventBridgeClientTest.php b/tests/EventBridge/EventBridgeClientTest.php index 9f8be83752..c6fe52c511 100644 --- a/tests/EventBridge/EventBridgeClientTest.php +++ b/tests/EventBridge/EventBridgeClientTest.php @@ -2,21 +2,21 @@ namespace Aws\Test\EventBridge; use Aws\CommandInterface; -use Aws\Exception\UnresolvedEndpointException; -use Aws\Result; use Aws\EventBridge\EventBridgeClient; +use Aws\Result; use Aws\Test\UsesServiceTrait; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(EventBridgeClient::class)] class EventBridgeClientTest extends TestCase { use UsesServiceTrait; - public static function putEventsEndpointSuccessProvider() + public static function putEventsEndpointSuccessProvider(): array { - return [ [ "us-east-1", @@ -55,7 +55,8 @@ public static function putEventsEndpointSuccessProvider() ], [ "us-iso-east-1", - [], 'abc123.456def', + [], + 'abc123.456def', 'https://abc123.456def.endpoint.events.c2s.ic.gov/', ['x-amz-region-set' => '*'], ], @@ -76,15 +77,6 @@ public static function putEventsEndpointSuccessProvider() ]; } - /** - * - * @param $clientRegion - * @param $additionalConfig - * @param $endpointId - * @param $expectedEndpoint - * @param $additionalHeaders - - */ #[DataProvider('putEventsEndpointSuccessProvider')] public function testPutEventsEndpointSuccessCases( $clientRegion, @@ -140,9 +132,8 @@ public function testPutEventsEndpointSuccessCases( $client->execute($command); } - public static function putEventsEndpointFailureProvider() + public static function putEventsEndpointFailureProvider(): array { - return [ ["us-east-1", [], 'badactor.com?foo=bar', 'EndpointId must be a valid host label.'], ["us-east-1", ['use_fips_endpoint' => true], 'abc123.456def', 'Invalid Configuration: FIPS is not supported with EventBridge multi-region endpoints.'], @@ -150,14 +141,6 @@ public static function putEventsEndpointFailureProvider() ]; } - /** - * - * @param $clientRegion - * @param $additionalConfig - * @param $endpointId - * @param $expectedException - - */ #[DataProvider('putEventsEndpointFailureProvider')] public function testPutEventsEndpointFailureCases( $clientRegion, @@ -201,4 +184,4 @@ public function testPutEventsEndpointFailureCases( self::assertStringContainsString($expectedException, $exception->getMessage()); } } -} \ No newline at end of file +} diff --git a/tests/Exception/AwsExceptionTest.php b/tests/Exception/AwsExceptionTest.php index 07f26f1c9d..9897ce6cf2 100644 --- a/tests/Exception/AwsExceptionTest.php +++ b/tests/Exception/AwsExceptionTest.php @@ -223,9 +223,6 @@ public function testAcceptsNullAsPrevious(): void $this->assertNull($e->getPrevious()); } - /** - - */ #[DataProvider('previousThrowableProvider')] public function testAcceptsVariousThrowableTypes(\Throwable $previous): void { diff --git a/tests/Exception/MultipartUploadExceptionTest.php b/tests/Exception/MultipartUploadExceptionTest.php index 69ff8065d4..49f1b7fe74 100644 --- a/tests/Exception/MultipartUploadExceptionTest.php +++ b/tests/Exception/MultipartUploadExceptionTest.php @@ -12,9 +12,6 @@ #[CoversClass(MultipartUploadException::class)] class MultipartUploadExceptionTest extends TestCase { - /** - - */ #[DataProvider('getTestCases')] public function testCanCreateMultipartException($commandName, $status) { @@ -31,7 +28,7 @@ public function testCanCreateMultipartException($commandName, $status) $this->assertSame($prev, $exception->getPrevious()); } - public static function getTestCases() + public static function getTestCases(): array { return [ ['CreateMultipartUpload', 'initiating'], diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index d4b625d103..a84523e10f 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -8,23 +8,27 @@ use PHPUnit\Framework\Attributes\CoversFunction; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\CoversClass; - -#[CoversFunction('\Aws\recursive_dir_iterator')] -#[CoversClass('\Aws\or_chain')] -#[CoversClass('\Aws\load_compiled_json')] -#[CoversClass('\Aws\constantly')] -#[CoversClass('\Aws\filter')] -#[CoversClass('\Aws\map')] -#[CoversClass('\Aws\flatmap')] -#[CoversClass('\Aws\partition')] -#[CoversClass('\Aws\describe_type')] -#[CoversClass('\Aws\describe_type')] + +#[CoversFunction('Aws\recursive_dir_iterator')] +#[CoversFunction('Aws\or_chain')] +#[CoversFunction('Aws\load_compiled_json')] +#[CoversFunction('Aws\constantly')] +#[CoversFunction('Aws\filter')] +#[CoversFunction('Aws\map')] +#[CoversFunction('Aws\flatmap')] +#[CoversFunction('Aws\partition')] +#[CoversFunction('Aws\describe_type')] +#[CoversFunction('Aws\dir_iterator')] +#[CoversFunction('Aws\default_http_handler')] +#[CoversFunction('Aws\serialize')] +#[CoversFunction('Aws\manifest')] +#[CoversFunction('Aws\is_valid_hostname')] +#[CoversFunction('Aws\is_valid_hostlabel')] +#[CoversFunction('Aws\parse_ini_file')] +#[CoversFunction('Aws\parse_ini_section_with_subsections')] +#[CoversFunction('Aws\is_associative')] class FunctionsTest extends TestCase { - /** - - */ public function testCreatesRecursiveDirIterator() { $iter = Aws\recursive_dir_iterator(__DIR__); @@ -275,7 +279,7 @@ public function testValidatesHostnames($hostname, $expected) $this->assertEquals($expected, Aws\is_valid_hostname($hostname)); } - public static function getHostnameTestCases() + public static function getHostnameTestCases(): array { return [ ['a', true], @@ -319,14 +323,14 @@ public static function getHostnameTestCases() /** * @param string $label * @param bool $expected - * */ + */ #[DataProvider('getHostlabelTestCases')] public function testValidatesHostlabels($label, $expected) { $this->assertEquals($expected, Aws\is_valid_hostlabel($label)); } - public static function getHostlabelTestCases() + public static function getHostlabelTestCases(): array { return [ ['us-west-2', true], @@ -364,7 +368,7 @@ public function testParsesIniFile($ini, $expected) unlink($tmpFile); } - public static function getIniFileTestCases() + public static function getIniFileTestCases(): array { return [ [ @@ -421,7 +425,7 @@ public function testParsesIniSectionsWithSubsections($ini, $expected) unlink($tmpFile); } - public static function getIniFileServiceTestCases() + public static function getIniFileServiceTestCases(): array { return [ [ @@ -454,9 +458,7 @@ public static function getIniFileServiceTestCases() /** * @param $array * @param $expected - * - - */ + */ #[DataProvider('isAssociativeProvider')] public function testIsAssociative($array, $expected) { @@ -464,7 +466,7 @@ public function testIsAssociative($array, $expected) $this->assertEquals($expected, $result); } - public static function isAssociativeProvider() + public static function isAssociativeProvider(): array { return [ [[], false], diff --git a/tests/Glacier/MultipartUploaderTest.php b/tests/Glacier/MultipartUploaderTest.php index f0470e51fd..f528b6c2a4 100644 --- a/tests/Glacier/MultipartUploaderTest.php +++ b/tests/Glacier/MultipartUploaderTest.php @@ -23,9 +23,6 @@ public static function _tearDownAfterClass() @unlink(sys_get_temp_dir() . '/' . self::FILENAME); } - /** - - */ #[DataProvider('getTestCases')] public function testGlacierMultipartUploadWorkflow( array $uploadOptions = [], @@ -56,7 +53,7 @@ public function testGlacierMultipartUploadWorkflow( $this->assertSame('buzz', $result['fizz']); } - public static function getTestCases() + public static function getTestCases(): array { $defaults = [ 'account_id' => 'foo', diff --git a/tests/Handler/GuzzleV6/HandlerTest.php b/tests/Handler/GuzzleV6/HandlerTest.php index 28e10f38ed..b1251a8add 100644 --- a/tests/Handler/GuzzleV6/HandlerTest.php +++ b/tests/Handler/GuzzleV6/HandlerTest.php @@ -1,8 +1,11 @@ assertTrue(true);}; + $this->assertTrue(true); + }; $list = new HandlerList($handler); $this->assertTrue($list->hasHandler()); $this->assertSame($handler, $list->resolve()); @@ -33,8 +34,8 @@ public function testHandlerCanBeSetInCtor() public function testHandlerCanBeSetInSetter() { $handler = function () { - - $this->assertTrue(true);}; + $this->assertTrue(true); + }; $list = new HandlerList(); $list->setHandler($handler); $this->assertTrue($list->hasHandler()); @@ -51,8 +52,8 @@ public function testCanPrependWithName() public function testCanRemoveByInstance() { $handler = function () { - - $this->assertTrue(true);}; + $this->assertTrue(true); + }; $list = new HandlerList($handler); $middleware = function () { return function () {}; }; $list->appendInit($middleware); @@ -74,8 +75,8 @@ public function testIgnoreWhenNameNotFound() public function testCanRemoveByName() { $handler = function () { - - $this->assertTrue(true);}; + $this->assertTrue(true); + }; $list = new HandlerList($handler); $middleware = function () { return function () {}; }; $list->appendInit($middleware, 'foo'); @@ -186,8 +187,8 @@ public function testMustExistByNameToPrependOrAppend() public function testCanInterposeMiddleware() { $list = new HandlerList(function () { - - $this->assertTrue(true);}); + $this->assertTrue(true); + }); $list->appendInit(Middleware::tap(function () {}), 'a'); $list->appendValidate(Middleware::tap(function () {}), 'b'); $list->appendBuild(Middleware::tap(function () {}), 'c'); diff --git a/tests/HasMonitoringEventsTraitTest.php b/tests/HasMonitoringEventsTraitTest.php index 07d8b0bc28..82655e5ae3 100644 --- a/tests/HasMonitoringEventsTraitTest.php +++ b/tests/HasMonitoringEventsTraitTest.php @@ -5,11 +5,9 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; - -#[CoversClass(\Aws\HasMonitoringEventsTrait::class)] +#[CoversClass(HasMonitoringEventsTrait::class)] class HasMonitoringEventsTraitTest extends TestCase { - public function testAddsAndRetrievesMonitoringEvents() { $events = [ @@ -26,7 +24,7 @@ public function testAddsAndRetrievesMonitoringEvents() ]; $mock = $this->getMockForTrait(HasMonitoringEventsTrait::class); - foreach($events as $event) { + foreach ($events as $event) { $mock->appendMonitoringEvent($event); } @@ -34,5 +32,4 @@ public function testAddsAndRetrievesMonitoringEvents() $events, $mock->getMonitoringEvents() ); } - } diff --git a/tests/HistoryTest.php b/tests/HistoryTest.php index bc3eaf5065..85a7103cc8 100644 --- a/tests/HistoryTest.php +++ b/tests/HistoryTest.php @@ -6,7 +6,7 @@ use Aws\History; use Aws\Exception\AwsException; use GuzzleHttp\Psr7\Request; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(History::class)] diff --git a/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php b/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php index 7bfbe47c35..51e74d5518 100644 --- a/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php +++ b/tests/Identity/S3Express/S3ExpressIdentityProviderTest.php @@ -27,13 +27,13 @@ private function getCredentialResultFromTimestamp($timestamp) ] ]); } - + public function testProvidesIdentity() { $expiration = time() + 5000; $client = $this->getTestClient('S3', []); $this->addMockResults($client, [ - $this->getCredentialResultFromTimestamp($expiration) + $this->getCredentialResultFromTimestamp($expiration) ]); $cmd = $client->getCommand('getObject', ['Bucket' => 'foo', 'Key' => 'bar']); $provider = new S3ExpressIdentityProvider( @@ -76,7 +76,6 @@ public function testRefreshesCache() $this->addMockResults($client, [ $this->getCredentialResultFromTimestamp($before), $this->getCredentialResultFromTimestamp($after), - ]); $cmd = $client->getCommand('getObject', ['Bucket' => 'foo', 'Key' => 'bar']); $provider = new S3ExpressIdentityProvider( diff --git a/tests/InputValidationMiddlewareTest.php b/tests/InputValidationMiddlewareTest.php index a5eb771ec4..d52bcbb2b1 100644 --- a/tests/InputValidationMiddlewareTest.php +++ b/tests/InputValidationMiddlewareTest.php @@ -3,17 +3,15 @@ use Aws\Api\DateTimeResult; use Aws\AwsClient; -use Aws\EndpointParameterMiddleware; use Aws\HandlerList; use Aws\Api\Service; use Aws\InputValidationMiddleware; -use Cassandra\Time; use GuzzleHttp\Psr7\Request; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\InputValidationMiddleware::class)] +#[CoversClass(InputValidationMiddleware::class)] class InputValidationMiddlewareTest extends TestCase { /** @@ -21,7 +19,7 @@ class InputValidationMiddlewareTest extends TestCase * * @return array */ - public static function getInvalidEndpointExceptions() + public static function getInvalidEndpointExceptions(): array { return [ [''], @@ -36,7 +34,7 @@ public static function getInvalidEndpointExceptions() * * @return array */ - public static function getValidInputs() + public static function getValidInputs(): array { return [ ['existing data'], @@ -48,11 +46,6 @@ public static function getValidInputs() ]; } - /** - * - * @param $input - - */ #[DataProvider('getInvalidEndpointExceptions')] public function testThrowsExceptions($input) { @@ -81,11 +74,6 @@ public function testThrowsExceptions($input) } } - /** - * - * @param $input - - */ #[DataProvider('getInvalidEndpointExceptions')] public function testNoValidationWithoutInputList($input) { @@ -105,11 +93,6 @@ public function testNoValidationWithoutInputList($input) self::assertSame($result, "success"); } - /** - * - * @param $input - - */ #[DataProvider('getValidInputs')] public function testPassingValidations($input) { diff --git a/tests/Integ/GuzzleStreamHandlerTest.php b/tests/Integ/GuzzleStreamHandlerTest.php index 19f9be799c..e34f3b75ce 100644 --- a/tests/Integ/GuzzleStreamHandlerTest.php +++ b/tests/Integ/GuzzleStreamHandlerTest.php @@ -2,8 +2,10 @@ namespace Aws\Test\Integ; use GuzzleHttp\Handler\StreamHandler; +use PHPUnit\Framework\Attributes\CoversNothing; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +#[CoversNothing] class GuzzleStreamHandlerTest extends TestCase { use IntegUtils; diff --git a/tests/Lambda/LambdaClientTest.php b/tests/Lambda/LambdaClientTest.php index f484a14da1..d0ec733a77 100644 --- a/tests/Lambda/LambdaClientTest.php +++ b/tests/Lambda/LambdaClientTest.php @@ -5,13 +5,15 @@ use Aws\Result; use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use GuzzleHttp\Promise; +use PHPUnit\Framework\Attributes\CoversClass; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +#[CoversClass(LambdaClient::class)] class LambdaClientTest extends TestCase { use ArraySubsetAsserts; - function testsAddsDefaultCurlOptions() + public function testsAddsDefaultCurlOptions() { if (!extension_loaded('curl')) { $this->markTestSkipped('Test skipped on no cURL extension'); @@ -37,4 +39,4 @@ function testsAddsDefaultCurlOptions() $client->listFunctions(); } -} \ No newline at end of file +} diff --git a/tests/MetricsBuilderTest.php b/tests/MetricsBuilderTest.php index 5caf0638a8..cbda4c0e08 100644 --- a/tests/MetricsBuilderTest.php +++ b/tests/MetricsBuilderTest.php @@ -7,8 +7,10 @@ use Aws\Middleware; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(MetricsBuilder::class)] class MetricsBuilderTest extends TestCase { public function testAppendMetrics() @@ -67,8 +69,8 @@ public function testGetMetricsBuilderFromCommand() public function testAppendMetricsCaptureMiddleware() { $handlerList = new HandlerList(function (){ - - $this->assertTrue(true);}); + $this->assertTrue(true); + }); $metric = "Foo"; // It should be appended into the build step MetricsBuilder::appendMetricsCaptureMiddleware( @@ -102,8 +104,7 @@ function ( * @param string $expectedMetrics * * @return void - - */ + */ #[DataProvider('resolveAndAppendFromArgsProvider')] public function testResolveAndAppendFromArgs( array $args, @@ -173,9 +174,11 @@ public static function resolveAndAppendFromArgsProvider(): array * * @return void */ - public function testAppendMetricsCaptureMiddlewareJustOnce(): void { + public function testAppendMetricsCaptureMiddlewareJustOnce(): void + { $handlerList = new HandlerList(function (){ - $this->assertTrue(true);}); + $this->assertTrue(true); + }); MetricsBuilder::appendMetricsCaptureMiddleware( $handlerList, 'test' diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index 6e40bd9b48..7b3a3da995 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -394,13 +394,6 @@ function (AwsException $e) { $promise->wait(); } - /** - * - * @param string|null $functionName - * @param string|null $traceId - * @param bool $traceHeaderExpected - * @param string $traceHeaderExpectedValue - */ #[DataProvider('recursionDetectionProvider')] public function testRecursionDetection( ?string $functionName, diff --git a/tests/MultiRegionClientTest.php b/tests/MultiRegionClientTest.php index aadda7da12..19a7b14453 100644 --- a/tests/MultiRegionClientTest.php +++ b/tests/MultiRegionClientTest.php @@ -14,8 +14,10 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(MultiRegionClient::class)] class MultiRegionClientTest extends TestCase { /** @var MultiRegionClient */ @@ -110,12 +112,6 @@ public function testProxiesArbitraryCallsToRegionalizedClient() $this->instance->baz(['foo' => 'bar']); } - /** - * - * @param string $method - * @param array $args - - */ #[DataProvider('clientInterfaceMethodProvider')] public function testProxiesCallsToRegionalizedClient($method, array $args) { @@ -126,7 +122,7 @@ public function testProxiesCallsToRegionalizedClient($method, array $args) call_user_func_array([$this->instance, $method], $args); } - public static function clientInterfaceMethodProvider() + public static function clientInterfaceMethodProvider(): array { return [ ['getConfig', ['someOption']], @@ -171,12 +167,8 @@ public function testUseCustomHandler() $response = $s3->listBuckets(); $this->assertEquals('bar', $response['foo']); - if (method_exists($this, 'expectException')) { - $this->expectException(AwsException::class); - $this->expectExceptionMessage('Mock exception'); - } else { - $this->setExpectedException(AwsException::class); - } + $this->expectException(AwsException::class); + $this->expectExceptionMessage('Mock exception'); $s3->listBuckets(); } } diff --git a/tests/Multipart/AbstractUploaderTest.php b/tests/Multipart/AbstractUploaderTest.php index 1901b6286b..e53404c2e7 100644 --- a/tests/Multipart/AbstractUploaderTest.php +++ b/tests/Multipart/AbstractUploaderTest.php @@ -4,6 +4,7 @@ use Aws\Command; use Aws\Exception\AwsException; use Aws\Exception\MultipartUploadException; +use Aws\Multipart\AbstractUploader; use Aws\Multipart\UploadState; use Aws\Result; use Aws\Test\UsesServiceTrait; @@ -187,13 +188,6 @@ public function testCanSetSourceFromFilenameIfExists() $this->assertInstanceOf('InvalidArgumentException', $exception); } - /** - * @param bool $seekable - * @param UploadState $state - * @param array $expectedBodies - * - - */ #[DataProvider('getPartGeneratorTestCases')] public function testCommandGeneratorYieldsExpectedUploadCommands( $seekable, @@ -223,7 +217,7 @@ public function testCommandGeneratorYieldsExpectedUploadCommands( $this->assertEquals($expectedBodies, $actualBodies); } - public static function getPartGeneratorTestCases() + public static function getPartGeneratorTestCases(): array { $expected = [ 1 => 'AA', diff --git a/tests/Multipart/UploadStateTest.php b/tests/Multipart/UploadStateTest.php index f64f32e198..58609dd50f 100644 --- a/tests/Multipart/UploadStateTest.php +++ b/tests/Multipart/UploadStateTest.php @@ -78,9 +78,6 @@ public function testEmptyUploadStateOutputWithConfigFalse() $this->expectOutputString(''); } - /** - - */ #[DataProvider('getDisplayProgressCases')] public function testGetDisplayProgressPrintsProgress( $totalSize, @@ -94,7 +91,7 @@ public function testGetDisplayProgressPrintsProgress( $this->expectOutputString($progressBar); } - public static function getDisplayProgressCases() + public static function getDisplayProgressCases(): array { $progressBar = ["Transfer initiated...\n| | 0.0%\n", "|== | 12.5%\n", @@ -174,9 +171,6 @@ public static function getDisplayProgressCases() ]; } - /** - - */ #[DataProvider('getThresholdCases')] public function testUploadThresholds($totalSize) { @@ -187,7 +181,7 @@ public function testUploadThresholds($totalSize) $this->assertCount(9, $threshold); } - public static function getThresholdCases() + public static function getThresholdCases(): array { return [ [0], @@ -196,9 +190,6 @@ public static function getThresholdCases() ]; } - /** - - */ #[DataProvider('getInvalidIntCases')] public function testSetProgressThresholdsThrowsException($totalSize) { @@ -209,9 +200,6 @@ public function testSetProgressThresholdsThrowsException($totalSize) $state->setProgressThresholds($totalSize); } - /** - - */ #[DataProvider('getInvalidIntCases')] public function testDisplayProgressThrowsException($totalUploaded) { @@ -221,7 +209,7 @@ public function testDisplayProgressThrowsException($totalUploaded) $state->getDisplayProgress($totalUploaded); } - public static function getInvalidIntCases() + public static function getInvalidIntCases(): array { return [ [''], diff --git a/tests/Neptune/NeptuneClientTest.php b/tests/Neptune/NeptuneClientTest.php index 6eb68988c6..0362ea7b7a 100644 --- a/tests/Neptune/NeptuneClientTest.php +++ b/tests/Neptune/NeptuneClientTest.php @@ -26,7 +26,7 @@ public static function tear_down_after_class() $_SERVER['formatAwsTime'] = null; } - public static function neptunePresignMethodProvider() + public static function neptunePresignMethodProvider(): array { return [ ['CopyDBClusterSnapshot', ['SourceDBClusterSnapshotIdentifier' => 'arn:aws:rds:us-east-1:123456789012:cluster-snapshot:source-db-cluster-snapshot', 'TargetDBClusterSnapshotIdentifier' => 'target-db-cluster-snapshot'], null, null, null, null], @@ -38,15 +38,6 @@ public static function neptunePresignMethodProvider() ]; } - /** - * - * @param string $functionName - * @param string $presignedUrl - * @param string $sourceRegion - * @param string $expectedUrl - * @param string $expectedSignature - - */ #[DataProvider('neptunePresignMethodProvider')] public function testCorrectPresignNeptuneUrls( $functionName, @@ -90,4 +81,3 @@ function ( call_user_func([$neptune, $functionName], $functionArgs); } } - diff --git a/tests/PresignUrlMiddlewareTest.php b/tests/PresignUrlMiddlewareTest.php index 00feeee8f8..a713bd8f1d 100644 --- a/tests/PresignUrlMiddlewareTest.php +++ b/tests/PresignUrlMiddlewareTest.php @@ -102,14 +102,6 @@ public function testNoPreSignedUrlWhenDifferentSourceRegionRequired() ]); } - /** - * @param string $parameter - * @param string $value - * @param string $expected - * - * @return void - - */ #[DataProvider('extraQueryParamsProvider')] public function testExtraQueryParametersAreURLEncoded( string $parameter, @@ -132,7 +124,7 @@ public function testExtraQueryParametersAreURLEncoded( return new Result; }, ]); - + $ec2->getHandlerList()->prependInit( PresignUrlMiddleware::wrap($ec2, $ec2->getEndpointProvider(), [ 'operations' => ['CopySnapshot'], @@ -140,7 +132,7 @@ public function testExtraQueryParametersAreURLEncoded( 'extra_query_params' => ['CopySnapshot' => [$parameter]] ]) ); - + $ec2->copySnapshot([ 'SourceRegion' => 'eu-west-1', 'SourceSnapshotId' => 'foo', @@ -148,9 +140,6 @@ public function testExtraQueryParametersAreURLEncoded( ]); } - /** - * @return array[] - */ public static function extraQueryParamsProvider(): array { return [ @@ -187,4 +176,3 @@ public static function extraQueryParamsProvider(): array ]; } } - diff --git a/tests/Psr16CacheAdapterTest.php b/tests/Psr16CacheAdapterTest.php index 0457a3fc1d..67f52ed769 100644 --- a/tests/Psr16CacheAdapterTest.php +++ b/tests/Psr16CacheAdapterTest.php @@ -2,10 +2,12 @@ namespace Aws\Test; use Aws\Psr16CacheAdapter; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\SimpleCache\CacheInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(Psr16CacheAdapter::class)] class Psr16CacheAdapterTest extends TestCase { /** @var CacheInterface|\PHPUnit_Framework_MockObject_MockObject $wrappedCache */ @@ -19,12 +21,6 @@ public function set_up() $this->instance = new Psr16CacheAdapter($this->wrapped); } - /** - * - * @param string $key - * @param mixed $value - - */ #[DataProvider('cacheDataProvider')] public function testProxiesGetCallsToPsrCache($key, $value) { @@ -36,13 +32,6 @@ public function testProxiesGetCallsToPsrCache($key, $value) $this->assertSame($value, $this->instance->get($key)); } - /** - * - * @param string $key - * @param mixed $value - * @param int|\DateInterval $ttl - - */ #[DataProvider('cacheDataProvider')] public function testProxiesSetCallsToPsrCache($key, $value, $ttl) { @@ -54,11 +43,6 @@ public function testProxiesSetCallsToPsrCache($key, $value, $ttl) $this->instance->set($key, $value, $ttl); } - /** - * - * @param string $key - - */ #[DataProvider('cacheDataProvider')] public function testProxiesRemoveCallsToPsrCache($key) { @@ -70,7 +54,7 @@ public function testProxiesRemoveCallsToPsrCache($key) $this->instance->remove($key); } - public static function cacheDataProvider() + public static function cacheDataProvider(): array { return [ ['foo', 'bar', 300], diff --git a/tests/PsrCacheAdapterTest.php b/tests/PsrCacheAdapterTest.php index bb83c66527..dc464fde6b 100644 --- a/tests/PsrCacheAdapterTest.php +++ b/tests/PsrCacheAdapterTest.php @@ -2,11 +2,13 @@ namespace Aws\Test; use Aws\PsrCacheAdapter; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(PsrCacheAdapter::class)] class PsrCacheAdapterTest extends TestCase { @@ -22,11 +24,9 @@ public function set_up() } /** - * * @param string $key * @param mixed $value - - */ + */ #[DataProvider('cacheDataProvider')] public function testProxiesGetCallsToPsrCache($key, $value) { @@ -47,12 +47,10 @@ public function testProxiesGetCallsToPsrCache($key, $value) } /** - * * @param string $key * @param mixed $value * @param int|\DateInterval $ttl - - */ + */ #[DataProvider('cacheDataProvider')] public function testProxiesSetCallsToPsrCache($key, $value, $ttl) { @@ -79,10 +77,8 @@ public function testProxiesSetCallsToPsrCache($key, $value, $ttl) } /** - * * @param string $key - - */ + */ #[DataProvider('cacheDataProvider')] public function testProxiesRemoveCallsToPsrCache($key) { @@ -94,7 +90,10 @@ public function testProxiesRemoveCallsToPsrCache($key) $this->instance->remove($key); } - public static function cacheDataProvider() + /** + * @return array> + */ + public static function cacheDataProvider(): array { return [ ['foo', 'bar', 300], diff --git a/tests/QueryCompatibleInputMiddlewareTest.php b/tests/QueryCompatibleInputMiddlewareTest.php index 7f5a7d3334..967c129d9d 100644 --- a/tests/QueryCompatibleInputMiddlewareTest.php +++ b/tests/QueryCompatibleInputMiddlewareTest.php @@ -14,14 +14,6 @@ #[CoversClass(\Aws\QueryCompatibleInputMiddleware::class)] class QueryCompatibleInputMiddlewareTest extends TestCase { - /** - * - * @param $inputParam - * @param $inputValue - * @param $expected - * @param $type - - */ #[DataProvider('getInputsDataProvider')] public function testEmitsWarning($inputParam, $inputValue, $expected, $type) { @@ -47,13 +39,6 @@ public function testEmitsWarning($inputParam, $inputValue, $expected, $type) } } - /** - * - * @param $inputParam - * @param $inputValue - * @param $expected - - */ #[DataProvider('getInputsDataProvider')] public function testAppliesMiddlewareAndCastsValues($inputParam, $inputValue, $expected) { diff --git a/tests/Rds/AuthTokenGeneratorTest.php b/tests/Rds/AuthTokenGeneratorTest.php index fdacfc117c..4ffdb1dca9 100644 --- a/tests/Rds/AuthTokenGeneratorTest.php +++ b/tests/Rds/AuthTokenGeneratorTest.php @@ -56,7 +56,7 @@ public function testCanCreateAuthTokenWthCredentialProvider() $this->assertStringContainsString('Action=connect', $token); } - public static function lifetimeProvider() + public static function lifetimeProvider(): array { return [ [1], @@ -66,11 +66,6 @@ public static function lifetimeProvider() ]; } - /** - * - * @param $lifetime - - */ #[DataProvider('lifetimeProvider')] public function testCanCreateAuthTokenWthNonDefaultLifetime($lifetime) { @@ -92,7 +87,7 @@ public function testCanCreateAuthTokenWthNonDefaultLifetime($lifetime) $this->assertStringContainsString('Action=connect', $token); } - public static function lifetimeFailureProvider() + public static function lifetimeFailureProvider(): array { return [ [0], @@ -105,11 +100,6 @@ public static function lifetimeFailureProvider() ]; } - /** - * - * @param $lifetime - - */ #[DataProvider('lifetimeFailureProvider')] public function testThrowsExceptionWithInvalidLifetime($lifetime) { diff --git a/tests/Rds/RdsClientTest.php b/tests/Rds/RdsClientTest.php index 84853fcd30..847265a98e 100644 --- a/tests/Rds/RdsClientTest.php +++ b/tests/Rds/RdsClientTest.php @@ -26,7 +26,7 @@ public static function tear_down_after_class() $_SERVER['aws_time'] = null; $_SERVER['formatAwsTime'] = null; } - + public function testAddsCopySnapshotMiddleware() { $rds = new RdsClient([ @@ -53,7 +53,7 @@ function ($command, $request) { ]); } - public static function rdsPresignMethodProvider() + public static function rdsPresignMethodProvider(): array { return [ ['copyDBSnapshot', ['SourceDBSnapshotIdentifier' => 'arn:aws:rds:us-east-1:123456789012:snapshot:source-db-snapshot', 'TargetDBSnapshotIdentifier' => 'target-db-snapshot'], null, null, null, null], @@ -71,15 +71,6 @@ public static function rdsPresignMethodProvider() ]; } - /** - * - * @param string $functionName - * @param string $presignedUrl - * @param string $sourceRegion - * @param string $expectedUrl - * @param string $expectedSignature - - */ #[DataProvider('rdsPresignMethodProvider')] public function testCorrectPresignRdsUrls( $functionName, @@ -120,4 +111,3 @@ public function testCorrectPresignRdsUrls( call_user_func([$rds, $functionName], $functionArgs); } } - diff --git a/tests/RequestCompression/RequestCompressionMiddlewareTest.php b/tests/RequestCompression/RequestCompressionMiddlewareTest.php index eaa190d79a..4420585251 100644 --- a/tests/RequestCompression/RequestCompressionMiddlewareTest.php +++ b/tests/RequestCompression/RequestCompressionMiddlewareTest.php @@ -8,8 +8,10 @@ use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(RequestCompressionMiddleware::class)] class RequestCompressionMiddlewareTest extends TestCase { public function testCompressesRequestByDefault() @@ -64,7 +66,7 @@ public function testDoesNotCompressRequestWhenConfigured() } } - public static function specificSizeProvider() + public static function specificSizeProvider(): array { return [ [60, 0, 65], @@ -74,13 +76,6 @@ public static function specificSizeProvider() ]; } - /** - * - * @param $minSize - * @param $numMetricData - * @param $expectedBodySize - - */ #[DataProvider('specificSizeProvider')] public function testCompressesRequestAtSpecificSize($minSize, $numMetricData, $expectedBodySize) { @@ -195,7 +190,7 @@ public function testCommandLevelMinRequestSizeOverrides() } } - public static function invalidDisableCompressionType() + public static function invalidDisableCompressionType(): array { return [ ['foo'], @@ -203,11 +198,6 @@ public static function invalidDisableCompressionType() ]; } - /** - * - * @param $invalidType - - */ #[DataProvider('invalidDisableCompressionType')] public function testThrowsExceptionWhenDisableMinCompressionNotBool($invalidType) { @@ -217,7 +207,7 @@ public function testThrowsExceptionWhenDisableMinCompressionNotBool($invalidType $client = $this->generateTestClient($service, ['disable_request_compression' => $invalidType]); } - public static function invalidMinRequestSizeProvider() + public static function invalidMinRequestSizeProvider(): array { return [ [-1], @@ -226,11 +216,6 @@ public static function invalidMinRequestSizeProvider() ]; } - /** - * - * @param $minRequestSize - - */ #[DataProvider('invalidMinRequestSizeProvider')] public function testThrowsExceptionWhenInvalidMinCompressionSizeOnClient($minRequestSize) { @@ -251,11 +236,6 @@ public function testThrowsExceptionWhenInvalidMinCompressionSizeOnClient($minReq ); } - /** - * - * @param $minRequestSize - - */ #[DataProvider('invalidMinRequestSizeProvider')] public function testThrowsExceptionWhenInvalidMinCompressionSize($minRequestSize) { @@ -325,24 +305,22 @@ private static function getMockMetricData($numElements) { //40 brings the request body size above the default minimum // compression threshold of 10240. 10919 to be exact. - return array_fill( - 0, - $numElements, - [ - 'MetricName' => 'MyMetric', - 'Timestamp' => time(), - 'Dimensions' => [ - [ - 'Name' => 'MyDimension1', - 'Value' => 'MyValue1' - - ], + return array_fill( + 0, + $numElements, + [ + 'MetricName' => 'MyMetric', + 'Timestamp' => time(), + 'Dimensions' => [ + [ + 'Name' => 'MyDimension1', + 'Value' => 'MyValue1' + ], - 'Unit' => 'Count', - 'Value' => 1 - ] - ); - } + ], + 'Unit' => 'Count', + 'Value' => 1 + ] + ); + } } - - diff --git a/tests/ResultPaginatorTest.php b/tests/ResultPaginatorTest.php index 25a7b07644..a378982584 100644 --- a/tests/ResultPaginatorTest.php +++ b/tests/ResultPaginatorTest.php @@ -7,6 +7,7 @@ use Aws\DynamoDb\DynamoDbClient; use Aws\MetricsBuilder; use Aws\Result; +use Aws\ResultPaginator; use Aws\S3\S3Client; use GuzzleHttp\Promise; use GuzzleHttp\Psr7\Response; @@ -41,9 +42,6 @@ private function getCustomClientProvider(array $config) ]); } - /** - - */ #[DataProvider('getPaginatorIterationData')] public function testStandardIterationWorkflow( array $config, @@ -78,9 +76,6 @@ function () use (&$requestCount) { $this->assertEquals($expectedTableNames, $tableNames); } - /** - - */ #[DataProvider('getPaginatorIterationData')] public function testAsyncWorkflow( array $config, @@ -105,8 +100,9 @@ public function testAsyncWorkflow( public function testNonIterator() { // Get test data - $config = $this->getPaginatorIterationData()[0][0]; - $results = $this->getPaginatorIterationData()[0][1]; + $data = self::getPaginatorIterationData(); + $config = $data[0][0]; + $results = $data[0][1]; // Create the client and paginator $client = $this->getCustomClientProvider($config); $this->addMockResults($client, $results); @@ -124,7 +120,8 @@ public function testNonIterator() /** * @return array Test data */ - public static function getPaginatorIterationData(): array { + public static function getPaginatorIterationData(): array + { return [ // Single field token case [ diff --git a/tests/Retry/ConfigurationProviderTest.php b/tests/Retry/ConfigurationProviderTest.php index 18f70500b4..4d6e30eb99 100644 --- a/tests/Retry/ConfigurationProviderTest.php +++ b/tests/Retry/ConfigurationProviderTest.php @@ -12,7 +12,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Retry\ConfigurationProvider::class)] +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -362,7 +362,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public static function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData(): array { $expected = new Configuration('standard', 30); return [ @@ -400,11 +400,6 @@ function () use ($expected) { ]; } - /** - * @param $toUnwrap - * @param ConfigurationInterface $expected - - */ #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { diff --git a/tests/Retry/ConfigurationTest.php b/tests/Retry/ConfigurationTest.php index cb61172e95..6a2142ffc9 100644 --- a/tests/Retry/ConfigurationTest.php +++ b/tests/Retry/ConfigurationTest.php @@ -6,7 +6,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Retry\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/Retry/QuotaManagerTest.php b/tests/Retry/QuotaManagerTest.php index c04111fd51..9684e4b718 100644 --- a/tests/Retry/QuotaManagerTest.php +++ b/tests/Retry/QuotaManagerTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Retry\QuotaManager::class)] +#[CoversClass(QuotaManager::class)] class QuotaManagerTest extends TestCase { public function testReturnsFalseWithNoCapacity() diff --git a/tests/Retry/RateLimiterTest.php b/tests/Retry/RateLimiterTest.php index 0e30aa193b..b7fdf7226a 100644 --- a/tests/Retry/RateLimiterTest.php +++ b/tests/Retry/RateLimiterTest.php @@ -50,7 +50,7 @@ public function testCorrectlyCalculatesSendingRate() $this->assertSame(2.048, $rateLimiter->updateSendingRate(false)); } - public static function cubicSuccessProvider() + public static function cubicSuccessProvider(): array { return [ [5, 7], @@ -63,13 +63,6 @@ public static function cubicSuccessProvider() ]; } - /** - * - * @param $timestamp - * @param $expectedRate - * @throws \ReflectionException - - */ #[DataProvider('cubicSuccessProvider')] public function testCalculatesCubicSuccessValues($timestamp, $expectedRate) { @@ -237,5 +230,4 @@ public function testUpdatesClientSendingRatesCorrectly() ); } } - } diff --git a/tests/RetryMiddlewareTest.php b/tests/RetryMiddlewareTest.php index e77924b99a..288947e2b7 100644 --- a/tests/RetryMiddlewareTest.php +++ b/tests/RetryMiddlewareTest.php @@ -149,7 +149,7 @@ public function testDeciderRetriesForCustomCurlErrors() $this->assertFalse($decider(0, $command, $request, null, $err)); } - public static function awsErrorCodeProvider() + public static function awsErrorCodeProvider(): array { $command = new Command('foo'); return [ @@ -165,11 +165,7 @@ public static function awsErrorCodeProvider() [new AwsException('e', $command, ['code' => 'EC2ThrottledException'])], ]; } - /** - * @param $err - * - */ #[DataProvider('awsErrorCodeProvider')] public function testDeciderRetriesWhenAwsErrorCodeMatches($err) { diff --git a/tests/RetryMiddlewareV2Test.php b/tests/RetryMiddlewareV2Test.php index c57e53288c..add10ab550 100644 --- a/tests/RetryMiddlewareV2Test.php +++ b/tests/RetryMiddlewareV2Test.php @@ -28,15 +28,13 @@ class RetryMiddlewareV2Test extends TestCase use UsesServiceTrait; /** - * * @param CommandInterface $command * @param QuotaManager $quotaManager * @param array $queue * @param array $options * @param $expected * @throws \Exception - - */ + */ #[DataProvider('standardModeTestCases')] public function testRetriesForStandardMode( CommandInterface $command, @@ -131,7 +129,8 @@ function() use ($expected, &$attempt, $quotaManager, &$errors, $command) { $this->assertCount($attempt, $queue); } - public static function standardModeTestCases(): array { + public static function standardModeTestCases(): array + { $command = new Command('foo'); $result200 = new Result([ '@metadata' => [ @@ -583,7 +582,7 @@ public function testDeciderRetriesForCustomCurlErrors() $this->assertFalse($decider(0, $command, $err)); } - public static function awsErrorCodeProvider() + public static function awsErrorCodeProvider(): array { $command = new Command('foo'); return [ @@ -600,10 +599,8 @@ public static function awsErrorCodeProvider() } /** - * @param $err - * - - */ + * @param $err + */ #[DataProvider('awsErrorCodeProvider')] public function testDeciderRetriesWhenAwsErrorCodeMatches($err) { diff --git a/tests/S3/AmbiguousSuccessParserTest.php b/tests/S3/AmbiguousSuccessParserTest.php index 82aee6a2fd..a4658362e3 100644 --- a/tests/S3/AmbiguousSuccessParserTest.php +++ b/tests/S3/AmbiguousSuccessParserTest.php @@ -8,11 +8,13 @@ use Aws\S3\AmbiguousSuccessParser; use Aws\S3\Exception\S3Exception; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\ResponseInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(AmbiguousSuccessParser::class)] class AmbiguousSuccessParserTest extends TestCase { private $instance; @@ -31,11 +33,6 @@ public function set_up() ); } - /** - * - * @param string $operation - - */ #[DataProvider('opsWithAmbiguousSuccessesProvider')] public function testConvertsAmbiguousSuccessesToExceptions($operation) { @@ -54,10 +51,6 @@ public function testConvertsAmbiguousSuccessesToExceptions($operation) $instance($command, $response); } - /** - * @param string $operation - #[CoversNothing] - */ #[DataProvider('opsWithoutAmbiguousSuccessesProvider')] #[CoversNothing] public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations(string $operation) @@ -74,12 +67,8 @@ public function testIgnoresAmbiguousSuccessesOnUnaffectedOperations(string $oper $instance = $this->instance; $instance($command, $response); $this->assertTrue(true); - $this->assertTrue(true); } - /** - - */ #[DataProvider('opsWithAmbiguousSuccessesProvider')] public function testThrowsConnectionErrorForEmptyBody($operation) { diff --git a/tests/S3/ApplyChecksumMiddlewareTest.php b/tests/S3/ApplyChecksumMiddlewareTest.php index 6d1a69313b..84d79fbd2d 100644 --- a/tests/S3/ApplyChecksumMiddlewareTest.php +++ b/tests/S3/ApplyChecksumMiddlewareTest.php @@ -13,9 +13,6 @@ class ApplyChecksumMiddlewareTest extends TestCase { use UsesServiceTrait; - /** - - */ #[DataProvider('getFlexibleChecksumUseCases')] public function testFlexibleChecksums( $operation, @@ -55,7 +52,7 @@ public function testFlexibleChecksums( $mw($command, $request); } - public static function getFlexibleChecksumUseCases() + public static function getFlexibleChecksumUseCases(): array { return [ 'http_checksum_not_modeled' => [ @@ -198,9 +195,6 @@ public static function getFlexibleChecksumUseCases() ]; } - /** - - */ #[DataProvider('getContentSha256UseCases')] public function testAddsContentSHA256($operation, $args, $hashAdded, $hashValue) { @@ -217,7 +211,7 @@ public function testAddsContentSHA256($operation, $args, $hashAdded, $hashValue) $mw($command, $request); } - public static function getContentSha256UseCases() + public static function getContentSha256UseCases(): array { $hash = 'SHA256HASH'; diff --git a/tests/S3/BatchDeleteTest.php b/tests/S3/BatchDeleteTest.php index c8d31c871e..dd06aff199 100644 --- a/tests/S3/BatchDeleteTest.php +++ b/tests/S3/BatchDeleteTest.php @@ -7,10 +7,10 @@ use Aws\S3\BatchDelete; use Aws\S3\Exception\DeleteMultipleObjectsException; use Aws\Test\UsesServiceTrait; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\S3\BatchDelete::class)] +#[CoversClass(BatchDelete::class)] class BatchDeleteTest extends TestCase { use UsesServiceTrait; @@ -185,7 +185,7 @@ public function testDeletesYieldedCommandsWhenEachCallbackReturns() $keys = \JmesPath\search('[].Delete.Objects[].Key', $cmds); $this->assertEquals(range(0, 9), $keys); } - + public function testWithNoMatchingObjects() { $client = $this->getTestClient('s3'); diff --git a/tests/S3/BucketEndpointArnMiddlewareTest.php b/tests/S3/BucketEndpointArnMiddlewareTest.php index 6db04d29d5..35489b9e5e 100644 --- a/tests/S3/BucketEndpointArnMiddlewareTest.php +++ b/tests/S3/BucketEndpointArnMiddlewareTest.php @@ -7,6 +7,7 @@ use Aws\Exception\UnresolvedEndpointException; use Aws\Middleware; use Aws\Result; +use Aws\S3\BucketEndpointMiddleware; use Aws\S3\Exception\S3Exception; use Aws\S3\S3Client; use Aws\Test\UsesServiceTrait; @@ -16,22 +17,11 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\S3\BucketEndpointMiddleware::class)] +#[CoversClass(BucketEndpointMiddleware::class)] class BucketEndpointArnMiddlewareTest extends TestCase { use UsesServiceTrait; - /** - * - * @param $arn - * @param $options - * @param $endpoint - * @param $key - * @param $signingRegion - * @param $signingService - * @throws \Exception - - */ #[DataProvider('accessPointArnCases')] public function testCorrectlyModifiesUri( $arn, @@ -85,7 +75,7 @@ public function testCorrectlyModifiesUri( $s3->execute($command); } - public static function accessPointArnCases() + public static function accessPointArnCases(): array { return [ // Standard case @@ -330,13 +320,6 @@ public static function accessPointArnCases() ]; } - /** - * - * @param CommandInterface $command - * @param array $config - * @param \Exception $expected - - */ #[DataProvider('incorrectUsageProvider')] public function testThrowsForIncorrectArnUsage($command, $config, \Exception $expected) { @@ -358,7 +341,7 @@ public function testThrowsForIncorrectArnUsage($command, $config, \Exception $ex } } - public static function incorrectUsageProvider() + public static function incorrectUsageProvider(): array { return [ [ diff --git a/tests/S3/BucketEndpointMiddlewareTest.php b/tests/S3/BucketEndpointMiddlewareTest.php index 1e2e1a0348..dfd2d50e17 100644 --- a/tests/S3/BucketEndpointMiddlewareTest.php +++ b/tests/S3/BucketEndpointMiddlewareTest.php @@ -2,6 +2,7 @@ namespace Aws\Test\S3; use Aws\Middleware; +use Aws\S3\BucketEndpointMiddleware; use Aws\Test\UsesServiceTrait; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; @@ -150,11 +151,6 @@ public static function keyContainsBucketNameProvider(): iterable ]; } - /** - * - * @param $key - - */ #[DataProvider('keyContainsBucketNameProvider')] public function testsHandlesDuplicatePathWithKeyContainsBucketName($key): void { diff --git a/tests/S3/Crypto/HeadersMetadataStrategyTest.php b/tests/S3/Crypto/HeadersMetadataStrategyTest.php index 9fd200a09c..e301ad83d3 100644 --- a/tests/S3/Crypto/HeadersMetadataStrategyTest.php +++ b/tests/S3/Crypto/HeadersMetadataStrategyTest.php @@ -12,9 +12,6 @@ class HeadersMetadataStrategyTest extends TestCase { use UsesMetadataEnvelopeTrait; - /** - - */ #[DataProvider('getMetadataFields')] public function testSave($fields) { @@ -30,9 +27,6 @@ public function testSave($fields) } } - /** - - */ #[DataProvider('getMetadataResult')] public function testLoad($args, $metadata) { diff --git a/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php b/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php index 28512b0ddf..a35bccdd3c 100644 --- a/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php +++ b/tests/S3/Crypto/InstructionFileMetadataStrategyTest.php @@ -16,9 +16,6 @@ class InstructionFileMetadataStrategyTest extends TestCase { use UsesMetadataEnvelopeTrait, UsesServiceTrait; - /** - - */ #[DataProvider('getMetadataFields')] public function testSave($fields) { @@ -47,8 +44,7 @@ public function testSave($fields) /** * Tests that only required data gets saved to the instruction file * and other data is left to the object metadata headers - - */ + */ #[DataProvider('getV3MetadataFields')] public function testSaveV3MetadataEnvelope($fields): void { @@ -111,9 +107,6 @@ public function testSaveV3MetadataEnvelope($fields): void } - /** - - */ #[DataProvider('getMetadataResult')] public function testLoad($args, $metadata) { @@ -138,9 +131,6 @@ public function testLoad($args, $metadata) } } - /** - - */ #[DataProvider('getV3FieldsForInstructionFile')] public function testLoadV3FromInstructionFileAndMetadata($args, $instructionFile): void { @@ -169,9 +159,6 @@ public function testLoadV3FromInstructionFileAndMetadata($args, $instructionFile } } - /** - - */ #[DataProvider('getV3MetadataResult')] public function testLoadV3FromInstructionFileAndMetadataCorruptInstructionFile($args, $instructionFile) { @@ -187,10 +174,7 @@ public function testLoadV3FromInstructionFileAndMetadataCorruptInstructionFile($ $this->expectExceptionMessage("One or more reserved keys found in Instruction file when they should not be present."); $envelope = $strategy->load($args); } - - /** - */ #[DataProvider('getMetadataResult')] public function testLoadV2FromInstructionFileAndMetadataCorruptInstructionFile($args, $instructionFile) { @@ -208,10 +192,7 @@ public function testLoadV2FromInstructionFileAndMetadataCorruptInstructionFile($ $this->expectExceptionMessage("Malformed metadata envelope."); $envelope = $strategy->load($args); } - - /** - */ #[DataProvider('getMetadataResult')] public function testLoadV2FromInstructionFileAndMetadataInvalidJson($args, $instructionFile) { diff --git a/tests/S3/Crypto/S3EncryptionClientTest.php b/tests/S3/Crypto/S3EncryptionClientTest.php index 84eeb4d774..821be21cf4 100644 --- a/tests/S3/Crypto/S3EncryptionClientTest.php +++ b/tests/S3/Crypto/S3EncryptionClientTest.php @@ -20,10 +20,12 @@ use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Psr7\Response; use Aws\Test\MetricsBuilderTestTrait; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\RequestInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(S3EncryptionClient::class)] class S3EncryptionClientTest extends TestCase { use S3EncryptionClientTestingTrait; @@ -62,9 +64,6 @@ private function setupProvidedExpectedException($exception) } } - /** - - */ #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, @@ -97,9 +96,6 @@ public function testPutObjectTakesValidMaterialsProviders( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, @@ -123,9 +119,6 @@ public function testPutObjectRejectsInvalidMaterialsProviders( ]); } - /** - - */ #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, @@ -165,9 +158,6 @@ public function testPutObjectTakesValidMetadataStrategy( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy($strategy, $exception) { @@ -254,9 +244,6 @@ public function testPutObjectWithOperationInstructionFileSuffix() $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, @@ -292,9 +279,6 @@ public function testPutObjectValidatesCipher( ]); } - /** - - */ #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, diff --git a/tests/S3/Crypto/S3EncryptionClientV2Test.php b/tests/S3/Crypto/S3EncryptionClientV2Test.php index 60766ffcc1..dc3de901cc 100644 --- a/tests/S3/Crypto/S3EncryptionClientV2Test.php +++ b/tests/S3/Crypto/S3EncryptionClientV2Test.php @@ -21,8 +21,10 @@ use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(S3EncryptionClientV2::class)] class S3EncryptionClientV2Test extends TestCase { use S3EncryptionClientTestingTrait; @@ -61,9 +63,6 @@ private function setupProvidedExpectedException($exception) } } - /** - - */ #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, @@ -100,9 +99,6 @@ public function testPutObjectTakesValidMaterialsProviders( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, @@ -127,9 +123,6 @@ public function testPutObjectRejectsInvalidMaterialsProviders( ]); } - /** - - */ #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, @@ -173,9 +166,6 @@ public function testPutObjectTakesValidMetadataStrategy( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy($strategy, $exception) { @@ -271,9 +261,6 @@ public function testPutObjectWithOperationInstructionFileSuffix() $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, @@ -313,9 +300,6 @@ public function testPutObjectValidatesCipher( ]); } - /** - - */ #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, diff --git a/tests/S3/Crypto/S3EncryptionClientV3Test.php b/tests/S3/Crypto/S3EncryptionClientV3Test.php index 040c2589e8..34a7af7032 100644 --- a/tests/S3/Crypto/S3EncryptionClientV3Test.php +++ b/tests/S3/Crypto/S3EncryptionClientV3Test.php @@ -20,7 +20,6 @@ use GuzzleHttp\Promise; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Psr7\Response; -use PHPUnit\Framework\Attributes\CoversNothing; use TypeError; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; @@ -58,9 +57,6 @@ protected function getKmsClient(): mixed return $client; } - /** - - */ #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, @@ -101,9 +97,6 @@ public function testPutObjectTakesValidMaterialsProviders( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, @@ -131,9 +124,6 @@ public function testPutObjectRejectsInvalidMaterialsProviders( ]); } - /** - - */ #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, @@ -181,9 +171,6 @@ public function testPutObjectTakesValidMetadataStrategy( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy( $strategy, @@ -537,9 +524,6 @@ public function testDefaultVsInstructionFileMetadataStorage(): void $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, @@ -582,9 +566,6 @@ public function testPutObjectValidatesCipher( ]); } - /** - - */ #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, @@ -699,7 +680,7 @@ public function testPutObjectWrapsBodyInAesGcmEncryptingStream(): void */ public function testTriggersWarningForGcmEncryptionWithAad(): void { - $this->$this->expectException(\RuntimeException::class); + $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('\'Aad\' has been supplied for content encryption' . ' with AES/GCM/NoPadding'); set_error_handler(function ($errno, $errstr) { @@ -1231,49 +1212,57 @@ public function testGetObjectSavesFile(): void public function testEmitsWarningForLegacySecurityProfile(): void { + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }, E_USER_WARNING); $this->expectExceptionMessage('This S3 Encryption Client operation' . ' is configured to read encrypted data with legacy encryption modes'); - $this->$this->expectException(\RuntimeException::class); - $kms = $this->getKmsClient(); - $list = $kms->getHandlerList(); - $list->setHandler(function ($cmd, $req) { - // Verify decryption command has correct parameters - $this->assertSame('cek', $cmd['CiphertextBlob']); - $this->assertEquals( - [ - 'kms_cmk_id' => '11111111-2222-3333-4444-555555555555' - ], - $cmd['EncryptionContext'] - ); - return Promise\Create::promiseFor( - new Result(['Plaintext' => random_bytes(32)]) - ); - }); - $providerV1 = new KmsMaterialsProvider($kms); - $providerV3 = new KmsMaterialsProviderV3($kms); + $this->expectException(\RuntimeException::class); - $s3 = new S3Client([ - 'region' => 'us-west-2', - 'version' => 'latest', - 'http_handler' => function () use ($providerV1) { - return new FulfilledPromise(new Response( - 200, - $this->getFieldsAsMetaHeaders( - $this->getValidV1CbcMetadataFields($providerV1) - ), - 'test' - )); - }, - ]); + try { + $kms = $this->getKmsClient(); + $list = $kms->getHandlerList(); + $list->setHandler(function ($cmd, $req) { + // Verify decryption command has correct parameters + $this->assertSame('cek', $cmd['CiphertextBlob']); + $this->assertEquals( + [ + 'kms_cmk_id' => '11111111-2222-3333-4444-555555555555' + ], + $cmd['EncryptionContext'] + ); + return Promise\Create::promiseFor( + new Result(['Plaintext' => random_bytes(32)]) + ); + }); + $providerV1 = new KmsMaterialsProvider($kms); + $providerV3 = new KmsMaterialsProviderV3($kms); - $client = new S3EncryptionClientV3($s3); - $client->getObject([ - 'Bucket' => 'foo', - 'Key' => 'bar', - '@MaterialsProvider' => $providerV3, - '@CommitmentPolicy' => "FORBID_ENCRYPT_ALLOW_DECRYPT", - '@SecurityProfile' => 'V3_AND_LEGACY', - ]); + $s3 = new S3Client([ + 'region' => 'us-west-2', + 'version' => 'latest', + 'http_handler' => function () use ($providerV1) { + return new FulfilledPromise(new Response( + 200, + $this->getFieldsAsMetaHeaders( + $this->getValidV1CbcMetadataFields($providerV1) + ), + 'test' + )); + }, + ]); + + $client = new S3EncryptionClientV3($s3); + $client->getObject([ + 'Bucket' => 'foo', + 'Key' => 'bar', + '@MaterialsProvider' => $providerV3, + '@CommitmentPolicy' => "FORBID_ENCRYPT_ALLOW_DECRYPT", + '@SecurityProfile' => 'V3_AND_LEGACY', + ]); + } finally { + restore_error_handler(); + } } public function testThrowsForV3ProfileAndLegacyObject(): void @@ -1480,8 +1469,7 @@ public function testPutObjectRequiresCommitmentPolicy(): void /** * Test that putObject rejects invalid commitment policies - - */ + */ #[DataProvider('getInvalidCommitmentPolicies')] public function testPutObjectRejectsInvalidCommitmentPolicy($policy, $expectedException): void { @@ -1550,8 +1538,7 @@ public function testGetObjectRequiresV3SecurityProfile(): void /** * Test that V2 security profiles are rejected in V3 - - */ + */ #[DataProvider('getV2SecurityProfiles')] public function testGetObjectRejectsV2SecurityProfiles($securityProfile): void { @@ -1574,48 +1561,54 @@ public function testGetObjectRejectsV2SecurityProfiles($securityProfile): void /** * Test valid V3 security profiles are accepted - - */ + */ #[DataProvider('getValidV3SecurityProfiles')] public function testGetObjectAcceptsValidV3SecurityProfiles($securityProfile): void { + set_error_handler(function ($errno, $errstr) { + throw new \RuntimeException($errstr, $errno); + }, E_USER_WARNING); if ($securityProfile === 'V3_AND_LEGACY') { $this->expectExceptionMessage("This S3 Encryption Client operation is configured to read encrypted data with legacy encryption modes"); - $this->$this->expectException(\RuntimeException::class); + $this->expectException(\RuntimeException::class); } elseif ($securityProfile === 'V3') { $this->expectExceptionMessage("Invalid MessageId length found in object envelope."); $this->expectException(\Aws\Exception\CryptoException::class); } - $kms = $this->getKmsClient(); - $provider = new KmsMaterialsProviderV3($kms, 'test-key'); - $this->addMockResults($kms, [ - new Result(['Plaintext' => random_bytes(32)]) - ]); + try { + $kms = $this->getKmsClient(); + $provider = new KmsMaterialsProviderV3($kms, 'test-key'); + $this->addMockResults($kms, [ + new Result(['Plaintext' => random_bytes(32)]) + ]); - $s3 = new S3Client([ - 'region' => 'us-west-2', - 'version' => 'latest', - 'http_handler' => function () use ($provider) { - return new FulfilledPromise(new Response( - 200, - $this->getFieldsAsMetaHeaders( - $this->getValidV3MetadataFields($provider) - ), - 'test' - )); - }, - ]); + $s3 = new S3Client([ + 'region' => 'us-west-2', + 'version' => 'latest', + 'http_handler' => function () use ($provider) { + return new FulfilledPromise(new Response( + 200, + $this->getFieldsAsMetaHeaders( + $this->getValidV3MetadataFields($provider) + ), + 'test' + )); + }, + ]); - $client = new S3EncryptionClientV3($s3); - $result = $client->getObject([ - 'Bucket' => 'foo', - 'Key' => 'bar', - '@MaterialsProvider' => $provider, - '@CommitmentPolicy' => 'REQUIRE_ENCRYPT_REQUIRE_DECRYPT', - '@SecurityProfile' => $securityProfile, - ]); + $client = new S3EncryptionClientV3($s3); + $result = $client->getObject([ + 'Bucket' => 'foo', + 'Key' => 'bar', + '@MaterialsProvider' => $provider, + '@CommitmentPolicy' => 'REQUIRE_ENCRYPT_REQUIRE_DECRYPT', + '@SecurityProfile' => $securityProfile, + ]); - $this->assertInstanceOf(AesGcmDecryptingStream::class, $result['Body']); + $this->assertInstanceOf(AesGcmDecryptingStream::class, $result['Body']); + } finally { + restore_error_handler(); + } } /** @@ -1752,8 +1745,7 @@ public function testExceptionThrownForLegacyAlgorithmOnPut(): void /** * Test that we validate the commitment policy with the encryption algorithm - - */ + */ #[DataProvider('getCiphersAndKCPolicies')] public function testCompatibleCipherAndKC( $cipherName, @@ -1801,8 +1793,7 @@ public function testCompatibleCipherAndKC( /** * Test that we validate the commitment policy with the encryption algorithm - - */ + */ #[DataProvider('getIncompatibleCiphersAndKCPolicies')] public function testIncompatibleCipherAndKC( $cipherName, @@ -1842,8 +1833,7 @@ public function testIncompatibleCipherAndKC( /** * Test that we validate the commitment policy with the encryption algorithm - - */ + */ #[DataProvider('getKCPolicies')] public function testIncompatibleCipherCBCAndKCGetObject( $commitmentPolicy @@ -1923,8 +1913,7 @@ public function testIncompatibleCipherCBCAndKCGetObject( /** * Test that we validate the commitment policy with the encryption algorithm - - */ + */ #[DataProvider('getKCPolicies')] public function testIncompatibleCipherGCMAndKCGetObject( $commitmentPolicy diff --git a/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php b/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php index 7064a14606..633e5200b0 100644 --- a/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php +++ b/tests/S3/Crypto/S3EncryptionMultipartUploaderTest.php @@ -11,8 +11,10 @@ use Aws\Test\Crypto\UsesMetadataEnvelopeTrait; use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(S3EncryptionMultipartUploader::class)] class S3EncryptionMultipartUploaderTest extends TestCase { use UsesServiceTrait, UsesMetadataEnvelopeTrait, UsesCryptoParamsTrait; @@ -50,9 +52,6 @@ private function setupProvidedExpectedException($exception) } } - /** - - */ #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, @@ -95,9 +94,6 @@ public function testPutObjectTakesValidMaterialsProviders( $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, @@ -124,9 +120,6 @@ public function testPutObjectRejectsInvalidMaterialsProviders( $uploader->upload(); } - /** - - */ #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, @@ -177,9 +170,6 @@ public function testPutObjectTakesValidMetadataStrategy( $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy( $strategy, @@ -250,9 +240,6 @@ public function testPutObjectWithClientInstructionFileSuffix() $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, @@ -297,9 +284,6 @@ public function testPutObjectValidatesCipher( $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, diff --git a/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php b/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php index b241a27a3b..f6ab5d96dc 100644 --- a/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php +++ b/tests/S3/Crypto/S3EncryptionMultipartUploaderV2Test.php @@ -13,8 +13,10 @@ use GuzzleHttp\Psr7; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(S3EncryptionMultipartUploaderV2::class)] class S3EncryptionMultipartUploaderV2Test extends TestCase { use UsesServiceTrait, UsesMetadataEnvelopeTrait, UsesCryptoParamsTraitV2; @@ -52,9 +54,6 @@ private function setupProvidedExpectedException($exception) } } - /** - - */ #[DataProvider('getValidMaterialsProviders')] public function testPutObjectTakesValidMaterialsProviders( $provider, @@ -101,9 +100,6 @@ public function testPutObjectTakesValidMaterialsProviders( $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getInvalidMaterialsProviders')] public function testPutObjectRejectsInvalidMaterialsProviders( $provider, @@ -131,9 +127,6 @@ public function testPutObjectRejectsInvalidMaterialsProviders( $uploader->upload(); } - /** - - */ #[DataProvider('getValidMetadataStrategies')] public function testPutObjectTakesValidMetadataStrategy( $strategy, @@ -188,9 +181,6 @@ public function testPutObjectTakesValidMetadataStrategy( $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getInvalidMetadataStrategies')] public function testPutObjectRejectsInvalidMetadataStrategy( $strategy, @@ -266,9 +256,6 @@ public function testPutObjectWithClientInstructionFileSuffix() $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getCiphers')] public function testPutObjectValidatesCipher( $cipher, @@ -317,9 +304,6 @@ public function testPutObjectValidatesCipher( $this->assertSame(self::TEST_URL, $result['ObjectURL']); } - /** - - */ #[DataProvider('getKeySizes')] public function testPutObjectValidatesKeySize( $keySize, diff --git a/tests/S3/GetBucketLocationParserTest.php b/tests/S3/GetBucketLocationParserTest.php index e3b92f293f..d7f27e83a3 100644 --- a/tests/S3/GetBucketLocationParserTest.php +++ b/tests/S3/GetBucketLocationParserTest.php @@ -15,9 +15,6 @@ class GetBucketLocationParserTest extends TestCase { use UsesServiceTrait; - /** - - */ #[DataProvider('getTestCases')] public function testParsesLocationFromGetBucketLocationOperations( $commandName, $responseBody, $expectedValue @@ -34,7 +31,7 @@ public function testParsesLocationFromGetBucketLocationOperations( $this->assertEquals($expectedValue, $result['LocationConstraint']); } - public static function getTestCases() + public static function getTestCases(): array { return [ ['GetBucketLocation', 'us-west-2', 'us-west-2'], diff --git a/tests/S3/MultipartCopyTest.php b/tests/S3/MultipartCopyTest.php index be606acbaf..23c81ceb39 100644 --- a/tests/S3/MultipartCopyTest.php +++ b/tests/S3/MultipartCopyTest.php @@ -9,17 +9,16 @@ use GuzzleHttp\Promise; use GuzzleHttp\Psr7; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(MultipartCopy::class)] class MultipartCopyTest extends TestCase { use UsesServiceTrait; const MB = 1048576; - /** - - */ #[DataProvider('getTestCases')] public function testS3MultipartCopyWorkflow( array $uploadOptions = [], @@ -50,7 +49,7 @@ public function testS3MultipartCopyWorkflow( $this->assertSame($url, $result['ObjectURL']); } - public static function getTestCases() + public static function getTestCases(): array { $defaults = [ 'bucket' => 'foo', diff --git a/tests/S3/MultipartUploaderTest.php b/tests/S3/MultipartUploaderTest.php index a3eec379db..c0f8c0ea20 100644 --- a/tests/S3/MultipartUploaderTest.php +++ b/tests/S3/MultipartUploaderTest.php @@ -26,9 +26,6 @@ public static function tear_down_after_class() @unlink(sys_get_temp_dir() . '/' . self::FILENAME); } - /** - - */ #[DataProvider('getTestCases')] public function testS3MultipartUploadWorkflow( array $clientOptions = [], @@ -61,7 +58,7 @@ public function testS3MultipartUploadWorkflow( $this->assertSame($url, $result['ObjectURL']); } - public static function getTestCases() + public static function getTestCases(): array { $defaults = [ 'bucket' => 'foo', @@ -154,9 +151,6 @@ public static function multipartSuccessStreams(): array ]; } - /** - - */ #[DataProvider('multipartSuccessStreams')] public function testS3MultipartUploadParams($stream, $size) { @@ -198,7 +192,7 @@ public function testS3MultipartUploadParams($stream, $size) $this->assertTrue(true); } - public static function getContentTypeSettingTests() + public static function getContentTypeSettingTests(): array { $size = 12 * self::MB; $data = str_repeat('.', $size); @@ -229,9 +223,6 @@ public static function getContentTypeSettingTests() ]; } - /** - - */ #[DataProvider('getContentTypeSettingTests')] public function testS3MultipartContentTypeSetting( $stream, @@ -307,9 +298,6 @@ public function testAppliesAmbiguousSuccessParsing() $uploader->upload(); } - /** - - */ #[DataProvider('multipartSuccessStreams')] public function testUploaderAddsFlexibleChecksums($stream, $size) { @@ -381,7 +369,7 @@ public function testAddContentMd5EmitsDeprecationNotice() restore_error_handler(); } } - + public function testUploadPrintsProgress() { $progressBar = [ diff --git a/tests/S3/ObjectCopierTest.php b/tests/S3/ObjectCopierTest.php index 337658665b..5e692601d0 100644 --- a/tests/S3/ObjectCopierTest.php +++ b/tests/S3/ObjectCopierTest.php @@ -12,15 +12,14 @@ use GuzzleHttp\Promise; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(ObjectCopier::class)] class ObjectCopierTest extends TestCase { use UsesServiceTrait; - /** - - */ #[DataProvider('copyDataProvider')] public function testDoesCorrectOperation( array $mockedResults, @@ -40,9 +39,6 @@ public function testDoesCorrectOperation( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('copyWithPathStyleDataProvider')] public function testDoesCorrectOperationWithPathStyle( array $mockedResults, @@ -64,11 +60,6 @@ public function testDoesCorrectOperationWithPathStyle( $this->assertTrue($this->mockQueueEmpty()); } - /** - * @param array $mockedResults - * @param array $options - - */ #[DataProvider('copyDataProvider')] public function testDoesCorrectOperationWithAccessPointArn( array $mockedResults, @@ -143,9 +134,6 @@ function (CommandInterface $cmd, RequestInterface $req) { $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('copyDataProvider')] public function testDoesCorrectOperationAsynchronously( array $mockedResults, @@ -167,9 +155,6 @@ public function testDoesCorrectOperationAsynchronously( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('copyWithPathStyleDataProvider')] public function testDoesCorrectOperationAsynchronouslyWithPathStyle( array $mockedResults, @@ -404,7 +389,8 @@ public function testS3ObjectCopierDoesTransformUnicodeKeyToEncodedURL() $this->assertSame($url, $result['ObjectURL']); } - public static function MultipartCopierProvider(){ + public static function MultipartCopierProvider(): array + { return [ ["中文", "文件夹/文件"], ["文件夹/文件", "中文"], @@ -412,9 +398,6 @@ public static function MultipartCopierProvider(){ ]; } - /** - - */ #[DataProvider('MultipartCopierProvider')] public function testS3ObjectMultipartCopier($input, $expectedOutput) { diff --git a/tests/S3/ObjectUploaderTest.php b/tests/S3/ObjectUploaderTest.php index 3aa9fed7cb..d032235d30 100644 --- a/tests/S3/ObjectUploaderTest.php +++ b/tests/S3/ObjectUploaderTest.php @@ -9,10 +9,10 @@ use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\FnStream; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(ObjectUploader::class)] class ObjectUploaderTest extends TestCase @@ -21,9 +21,6 @@ class ObjectUploaderTest extends TestCase const MB = 1048576; - /** - - */ #[DataProvider('uploadDataProvider')] public function testDoesCorrectOperation( StreamInterface $body, @@ -39,9 +36,6 @@ public function testDoesCorrectOperation( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('getUploadTestCasesWithPathStyle')] public function testDoesCorrectOperationWithPathStyle( StreamInterface $body, @@ -59,9 +53,6 @@ public function testDoesCorrectOperationWithPathStyle( $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('uploadDataProvider')] public function testDoesCorrectOperationWithAccessPointArn( StreamInterface $body, @@ -96,9 +87,6 @@ function(CommandInterface $cmd, RequestInterface $req) { $this->assertTrue($this->mockQueueEmpty()); } - /** - - */ #[DataProvider('uploadDataProvider')] public function testDoesCorrectOperationAsynchronously( StreamInterface $body, @@ -115,9 +103,6 @@ public function testDoesCorrectOperationAsynchronously( $this->assertSame('https://bucket.s3.amazonaws.com/key', $result['ObjectURL']); } - /** - - */ #[DataProvider('getUploadTestCasesWithPathStyle')] public function testDoesCorrectOperationAsynchronouslyWithPathStyle( StreamInterface $body, @@ -334,9 +319,7 @@ public function testS3ObjectUploaderMultipartParams() /** * @param $checksumAlgorithm * @return void - * - - */ + */ #[DataProvider('flexibleChecksumsProvider')] public function testAddsFlexibleChecksums($checksumAlgorithm, $value) { @@ -366,7 +349,8 @@ function ($cmd, $req) use ($checksumAlgorithm, $value) { ))->upload(); } - public static function flexibleChecksumsProvider() { + public static function flexibleChecksumsProvider(): array + { return [ ['sha1', 'VfWih+7phcE4uG3HQZCHKfpUwFs='], ['sha256', 'FT+vHyoAcJfTMSC77mlEpBy4vnZDwSIva8a8aewxaI8='], diff --git a/tests/S3/Parser/GetBucketLocationResultMutatorTest.php b/tests/S3/Parser/GetBucketLocationResultMutatorTest.php index 6d62a9e379..b873869b9c 100644 --- a/tests/S3/Parser/GetBucketLocationResultMutatorTest.php +++ b/tests/S3/Parser/GetBucketLocationResultMutatorTest.php @@ -6,9 +6,11 @@ use Aws\Result; use Aws\S3\Parser\GetBucketLocationResultMutator; use GuzzleHttp\Psr7\Response; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\TestCase; +#[CoversClass(GetBucketLocationResultMutator::class)] class GetBucketLocationResultMutatorTest extends TestCase { /** @@ -16,8 +18,7 @@ class GetBucketLocationResultMutatorTest extends TestCase * and added to the result as the LocationConstraint field. * * @return void - - */ + */ #[DataProvider('getTestCases')] public function testInjectsLocationConstraint($operationName, $responseBody, $expectedValue) { @@ -32,7 +33,7 @@ public function testInjectsLocationConstraint($operationName, $responseBody, $ex $this->assertEquals($expectedValue, $result['LocationConstraint']); } - public static function getTestCases() + public static function getTestCases(): array { return [ ['GetBucketLocation', 'us-west-2', 'us-west-2'], diff --git a/tests/S3/Parser/S3ParserTest.php b/tests/S3/Parser/S3ParserTest.php index 310658ff1d..a2bd2a68d3 100644 --- a/tests/S3/Parser/S3ParserTest.php +++ b/tests/S3/Parser/S3ParserTest.php @@ -14,11 +14,13 @@ use GuzzleHttp\Psr7\NoSeekStream; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(S3Parser::class)] class S3ParserTest extends TestCase { const INTERNAL_S3200_ERROR = << EOXML; - /** - * @param string $operation The operation to test. - * - * @return void - - */ #[DataProvider('s3200ErrorHandlingCasesProvider')] public function testHandle200Errors(string $operation) { @@ -251,13 +247,6 @@ public function __invoke( $this->assertFalse(isset($mutators[$s3MutatorName])); } - /** - * @param StreamInterface $stream - * @param bool $expectValidation - * - * @return void - - */ #[DataProvider('validate200ErrorValidationJustInSeekableStreamsProvider')] public function testValidate200ErrorValidationJustInSeekableStreams( StreamInterface $stream, diff --git a/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php b/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php index f4f0cc2565..36fe836576 100644 --- a/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php +++ b/tests/S3/Parser/ValidateResponseChecksumResultMutatorTest.php @@ -11,27 +11,19 @@ use Aws\S3\Parser\ValidateResponseChecksumResultMutator; use Aws\Test\UsesServiceTrait; use GuzzleHttp\Psr7\Response; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\TestCase; /** * The tests defined here are similar to the tests * from ValidateResponseChecksumParserTest. */ +#[CoversClass(ValidateResponseChecksumResultMutator::class)] class ValidateResponseChecksumResultMutatorTest extends TestCase { use UsesServiceTrait; - /** - * @param array $responseAlgorithms - * @param array $checksumHeadersReturned - * @param string|null $expectedChecksumAlgorithm - * @param array $config - * @param string $operation - * @param string|null $checksumMode - * @return void - - */ #[DataProvider('checksumCasesDataProvider')] public function testChecksumValidation( array $responseAlgorithms, @@ -243,7 +235,6 @@ public function testValidatesChecksumSucceeds() $result = $mutator($result, $command, $response); $this->assertEquals($expectedAlgorithm, $result['ChecksumValidated']); - } public function testValidatesChecksumSkipsValidation() diff --git a/tests/S3/PermanentRedirectMiddlewareTest.php b/tests/S3/PermanentRedirectMiddlewareTest.php index 66a7f1153d..8344aa4824 100644 --- a/tests/S3/PermanentRedirectMiddlewareTest.php +++ b/tests/S3/PermanentRedirectMiddlewareTest.php @@ -4,8 +4,10 @@ use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; +use Aws\S3\PermanentRedirectMiddleware; -#[CoversClass(\Aws\S3\PermanentRedirectMiddleware::class)] +#[CoversClass(PermanentRedirectMiddleware::class)] class PermanentRedirectMiddlewareTest extends TestCase { use UsesServiceTrait; diff --git a/tests/S3/PostObjectTest.php b/tests/S3/PostObjectTest.php index 65dee486ad..606f0355f6 100644 --- a/tests/S3/PostObjectTest.php +++ b/tests/S3/PostObjectTest.php @@ -73,13 +73,6 @@ public function testCanHandleDomainsWithDots() ); } - /** - * - * @param string $endpoint - * @param string $bucket - * @param string $expected - - */ #[DataProvider('pathStyleProvider')] public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expected) { @@ -104,7 +97,7 @@ public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expect $this->assertSame($expected, $formAttrs['action']); } - public static function pathStyleProvider() + public static function pathStyleProvider(): array { return [ ['http://s3.amazonaws.com', 'foo', 'http://s3.amazonaws.com/foo'], diff --git a/tests/S3/PostObjectV4Test.php b/tests/S3/PostObjectV4Test.php index 2176002831..a0774cf372 100644 --- a/tests/S3/PostObjectV4Test.php +++ b/tests/S3/PostObjectV4Test.php @@ -244,13 +244,6 @@ public function testCanHandleDomainsWithDots() ); } - /** - * - * @param string $endpoint - * @param string $bucket - * @param string $expected - - */ #[DataProvider('virtualStyleProvider')] public function testCanHandleVirtualStyleEndpoint($endpoint, $bucket, $expected) { @@ -269,7 +262,7 @@ public function testCanHandleVirtualStyleEndpoint($endpoint, $bucket, $expected) $this->assertSame($expected, $formAttrs['action']); } - public static function virtualStyleProvider() + public static function virtualStyleProvider(): array { return [ ['http://foo.s3.amazonaws.com', 'foo', 'http://foo.s3.amazonaws.com'], @@ -280,13 +273,6 @@ public static function virtualStyleProvider() ]; } - /** - * - * @param string $endpoint - * @param string $bucket - * @param string $expected - - */ #[DataProvider('pathStyleProvider')] public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expected) { @@ -305,7 +291,7 @@ public function testCanHandleForcedPathStyleEndpoint($endpoint, $bucket, $expect $this->assertSame($expected, $formAttrs['action']); } - public static function pathStyleProvider() + public static function pathStyleProvider(): array { return [ ['http://s3.amazonaws.com', 'foo', 'http://s3.amazonaws.com/foo'], diff --git a/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php b/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php index e06fb50985..3086b04131 100644 --- a/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php +++ b/tests/S3/RegionalEndpoint/ConfigurationProviderTest.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\S3\RegionalEndpoint\ConfigurationProvider::class)] +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -262,7 +262,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public static function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData(): array { $expected = new Configuration('regional'); return [ @@ -293,11 +293,6 @@ function () use ($expected) { ]; } - /** - * @param $toUnwrap - * @param ConfigurationInterface $expected - - */ #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { diff --git a/tests/S3/RegionalEndpoint/ConfigurationTest.php b/tests/S3/RegionalEndpoint/ConfigurationTest.php index d51a4c19fb..b774ef1a95 100644 --- a/tests/S3/RegionalEndpoint/ConfigurationTest.php +++ b/tests/S3/RegionalEndpoint/ConfigurationTest.php @@ -2,11 +2,11 @@ namespace Aws\Test\S3\RegionalEndpoint; -use Aws\Sts\RegionalEndpoints\Configuration; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use Aws\S3\RegionalEndpoint\Configuration; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\TestCase; -#[CoversClass(\Aws\S3\RegionalEndpoint\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/S3/RetryableMalformedResponseParserTest.php b/tests/S3/RetryableMalformedResponseParserTest.php index adc071b15f..529d194d8d 100644 --- a/tests/S3/RetryableMalformedResponseParserTest.php +++ b/tests/S3/RetryableMalformedResponseParserTest.php @@ -1,14 +1,15 @@ getRequest($command)); } - /** - * - * @param CommandInterface $command - - */ #[DataProvider('excludedCommandProvider')] public function testAppliesDualStackWithPathStyleToCommandForInvalidOperationsWhenEnableBoth(CommandInterface $command) { @@ -147,11 +139,6 @@ public function testAppliesAccelerateDualStackEndpointWithOperationalLevelOptIn( } } - /** - * - * @param CommandInterface $command - - */ #[DataProvider('excludedCommandProvider')] public function testAppliesDualStackForInvalidOperationsWhenEnableBothAtOperationalLevel(CommandInterface $command) { @@ -166,11 +153,6 @@ public function testAppliesDualStackForInvalidOperationsWhenEnableBothAtOperatio $middleware($command, $this->getRequest($command)); } - /** - * - * @param CommandInterface $command - - */ #[DataProvider('excludedCommandProvider')] public function testAppliesDualStackForInvalidOperationsWhenEnableBothWithPathStyleAtOperationalLevel(CommandInterface $command) { @@ -224,11 +206,6 @@ public function testDoesNothingWhenDisabledBothOnOperationLevel() } } - /** - * - * @param CommandInterface $command - - */ #[DataProvider('excludedCommandProvider')] public function testIgnoresExcludedCommands(CommandInterface $command) { @@ -531,7 +508,7 @@ private function ipAddressPathStyleFallbackAssertingHandler(CommandInterface $co }; } - public static function jsonCaseProvider() + public static function jsonCaseProvider(): array { return json_decode( file_get_contents(__DIR__ . '/test_cases/uri_addressing.json'), @@ -539,11 +516,6 @@ public static function jsonCaseProvider() ); } - /** - * - * @param array $testCase - - */ #[DataProvider('jsonCaseProvider')] public function testPassesCompliance( $bucket, @@ -576,16 +548,6 @@ public function testPassesCompliance( ]); } - /** - * - * @param $bucketFieldInput - * @param $clientRegion - * @param $additionalFlags - * @param $useArnRegion - * @param $endpointUrl - * @param $expectedEndpoint - - */ #[DataProvider('objectLambdasSuccessProvider')] public function testObjectLambdaArnSuccess( $bucketFieldInput, @@ -630,7 +592,7 @@ public function testObjectLambdaArnSuccess( $client->execute($command); } - public static function objectLambdasSuccessProvider() + public static function objectLambdasSuccessProvider(): array { return [ ["arn:aws:s3-object-lambda:us-east-1:123456789012:accesspoint/mybanner", "us-east-1", "none", false, null, "mybanner-123456789012.s3-object-lambda.us-east-1.amazonaws.com"], @@ -651,16 +613,6 @@ public static function objectLambdasSuccessProvider() ]; } - /** - * - * @param $bucketFieldInput - * @param $clientRegion - * @param $additionalFlags - * @param $useArnRegion - * @param $endpointUrl - * @param $expectedException - - */ #[DataProvider('objectLambdasFailureProvider')] public function testObjectLambdaArnFailures( $bucketFieldInput, @@ -710,7 +662,7 @@ public function testObjectLambdaArnFailures( } } - public static function objectLambdasFailureProvider() + public static function objectLambdasFailureProvider(): array { return [ ["arn:aws:s3-object-lambda:us-east-1:123456789012:accesspoint/mybanner", "us-west-2", "none", false, null, @@ -779,15 +731,6 @@ public static function objectLambdasFailureProvider() ]; } - - /** - * - * @param $clientRegion - * @param $route - * @param $endpointUrl - * @param $expectedEndpoint - - */ #[DataProvider('writeGetObjectResponseProvider')] public function testWriteGetObjectResponse( $clientRegion, @@ -822,7 +765,7 @@ public function testWriteGetObjectResponse( $client->execute($command); } - public static function writeGetObjectResponseProvider() + public static function writeGetObjectResponseProvider(): array { return [ diff --git a/tests/S3/S3MultiRegionClientTest.php b/tests/S3/S3MultiRegionClientTest.php index 5198fa9faf..99b5e7c298 100644 --- a/tests/S3/S3MultiRegionClientTest.php +++ b/tests/S3/S3MultiRegionClientTest.php @@ -14,10 +14,12 @@ use GuzzleHttp\Psr7\Response; use GuzzleHttp\Promise; use GuzzleHttp\Promise\RejectedPromise; -use Psr\Http\Message\RequestInterface; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\TestCase; +use Psr\Http\Message\RequestInterface; +#[CoversClass(S3MultiRegionClient::class)] class S3MultiRegionClientTest extends TestCase { use UsesServiceTrait; @@ -568,11 +570,6 @@ public function testWillDefaultToRegionInPartitionWithPathStyle() $client->getObject(['Bucket' => 'foo', 'Key' => 'bar']); } - /** - * - * @param bool $regionalized - - */ #[DataProvider('booleanProvider')] public function testCallbacksAttachedToCommandHandlerListsAreInvoked($regionalized) { @@ -604,7 +601,7 @@ public function testCallbacksAttachedToCommandHandlerListsAreInvoked($regionaliz $this->assertSame('object!object!', (string) $result['Body']); } - public static function booleanProvider() + public static function booleanProvider(): array { return [[true], [false]]; } diff --git a/tests/S3/S3Transfer/AbstractMultipartDownloaderTest.php b/tests/S3/S3Transfer/AbstractMultipartDownloaderTest.php index 0f42fd1c51..6a1a968403 100644 --- a/tests/S3/S3Transfer/AbstractMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/AbstractMultipartDownloaderTest.php @@ -16,11 +16,13 @@ use Aws\S3\S3Transfer\Utils\StreamDownloadHandler; use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; /** * Tests MultipartDownloader abstract class implementation. */ +#[CoversClass(AbstractMultipartDownloader::class)] class AbstractMultipartDownloaderTest extends TestCase { /** diff --git a/tests/S3/S3Transfer/MultipartUploaderTest.php b/tests/S3/S3Transfer/MultipartUploaderTest.php index 210c61cad0..9e8d3bc91a 100644 --- a/tests/S3/S3Transfer/MultipartUploaderTest.php +++ b/tests/S3/S3Transfer/MultipartUploaderTest.php @@ -18,11 +18,13 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; -use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(MultipartUploader::class)] class MultipartUploaderTest extends TestCase { @@ -38,15 +40,6 @@ protected function tearDown(): void restore_error_handler(); } - /** - * @param array $sourceConfig - * @param array $commandArgs - * @param array $config - * @param array $expected - * @return void - * - - */ #[DataProvider('multipartUploadProvider')] public function testMultipartUpload( array $sourceConfig, @@ -136,9 +129,6 @@ public function testMultipartUpload( } } - /** - * @return array[] - */ public static function multipartUploadProvider(): array { return [ '5_parts_upload' => [ @@ -240,9 +230,6 @@ public static function multipartUploadProvider(): array { ]; } - /** - * @return S3ClientInterface - */ private function getMultipartUploadS3Client(): S3ClientInterface { return new S3Client([ @@ -273,14 +260,6 @@ private function getMultipartUploadS3Client(): S3ClientInterface ]); } - - /** - * @param int $partSize - * @param bool $expectError - * - * @return void - - */ #[DataProvider('validatePartSizeProvider')] public function testValidatePartSize( int $partSize, @@ -309,9 +288,6 @@ public function testValidatePartSize( ); } - /** - * @return array - */ public static function validatePartSizeProvider(): array { return [ 'part_size_over_max' => [ @@ -333,13 +309,6 @@ public static function validatePartSizeProvider(): array { ]; } - /** - * @param string|int $source - * @param bool $expectError - * - * @return void - - */ #[DataProvider('invalidSourceStringProvider')] public function testInvalidSourceStringThrowsException( string|int $source, @@ -384,9 +353,6 @@ public function testInvalidSourceStringThrowsException( } } - /** - * @return array[] - */ public static function invalidSourceStringProvider(): array { return [ 'invalid_source_file_path_1' => [ @@ -408,9 +374,6 @@ public static function invalidSourceStringProvider(): array { ]; } - /** - * @return void - */ public function testTransferListenerNotifierNotifiesListenersOnSuccess(): void { $noOfListeners = 3; @@ -477,8 +440,6 @@ public function testTransferListenerNotifierNotifiesListenersOnSuccess(): void /** * Test to make sure createMultipart, uploadPart, and completeMultipart * operations are called. - * - * @return void */ public function testMultipartOperationsAreCalled(): void { $operationsCalled = [ @@ -531,14 +492,6 @@ public function testMultipartOperationsAreCalled(): void { } } - /** - * @param array $sourceConfig - * @param array $checksumConfig - * @param array $expectedOperationHeaders - * - * @return void - - */ #[DataProvider('multipartUploadWithCustomChecksumProvider')] public function testMultipartUploadWithCustomChecksum( array $sourceConfig, @@ -628,9 +581,6 @@ function (callable $handler) use (&$operationsCalled, $expectedOperationHeaders) } } - /** - * @return array - */ public static function multipartUploadWithCustomChecksumProvider(): array { return [ 'custom_checksum_crc32_1' => [ @@ -667,9 +617,6 @@ public static function multipartUploadWithCustomChecksumProvider(): array { ]; } - /** - * @return void - */ public function testMultipartUploadAbort() { $this->expectException(S3TransferException::class); $this->expectExceptionMessage('Upload failed'); @@ -726,9 +673,6 @@ public function testMultipartUploadAbort() { } } - /** - * @return void - */ public function testTransferListenerNotifierNotifiesListenersOnFailure(): void { $this->expectException(\Exception::class); @@ -788,9 +732,6 @@ public function testTransferListenerNotifierNotifiesListenersOnFailure(): void $multipartUploader->promise()->wait(); } - /** - * @return void - */ public function testTransferListenerNotifierWithEmptyListeners(): void { $listenerNotifier = new TransferListenerNotifier([]); @@ -843,13 +784,7 @@ public function testTransferListenerNotifierWithEmptyListeners(): void /** * This test makes sure that when full object checksum type is resolved * then, if a custom algorithm provide is not CRC family then it should fail. - * - * @param array $checksumConfig - * @param bool $expectsError - * - * @return void - - */ + */ #[DataProvider('fullObjectChecksumWorksJustWithCRCProvider')] public function testFullObjectChecksumWorksJustWithCRC( array $checksumConfig, @@ -892,9 +827,6 @@ public function testFullObjectChecksumWorksJustWithCRC( } } - /** - * @return Generator - */ public static function fullObjectChecksumWorksJustWithCRCProvider(): Generator { yield 'sha_256_should_fail' => [ 'checksum_config' => [ @@ -918,15 +850,6 @@ public static function fullObjectChecksumWorksJustWithCRCProvider(): Generator { ]; } - /** - * @param array $sourceConfig - * @param array $requestArgs - * @param array $expectedInputArgs - * @param bool $expectsError - * @param int|null $errorOnPartNumber - * @return void - - */ #[DataProvider('inputArgumentsPerOperationProvider')] public function testInputArgumentsPerOperation( array $sourceConfig, @@ -1020,9 +943,6 @@ function ($commandName, $args) } } - /** - * @return Generator - */ public static function inputArgumentsPerOperationProvider(): Generator { yield 'test_input_fields_are_copied_without_custom_checksums' => [ @@ -1329,9 +1249,6 @@ public static function inputArgumentsPerOperationProvider(): Generator ]; } - /** - * @return void - */ public function testAbortMultipartUploadShowsWarning(): void { // Convert the warning to an exception diff --git a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php index 8eea6c875e..73401369ad 100644 --- a/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/PartGetMultipartDownloaderTest.php @@ -12,11 +12,13 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Utils; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; /** * Tests PartGetMultipartDownloader implementation. */ +#[CoversClass(PartGetMultipartDownloader::class)] class PartGetMultipartDownloaderTest extends TestCase { /** @@ -27,8 +29,7 @@ class PartGetMultipartDownloaderTest extends TestCase * @param int $targetPartSize * * @return void - - */ + */ #[DataProvider('partGetMultipartDownloaderProvider')] public function testPartGetMultipartDownloader( string $objectKey, @@ -41,7 +42,7 @@ public function testPartGetMultipartDownloader( ->getMock(); $remainingToTransfer = $objectSizeInBytes; $mockClient->method('executeAsync') - -> willReturnCallback(function ($command) + ->willReturnCallback(function ($command) use ( $objectSizeInBytes, $partsCount, @@ -64,7 +65,7 @@ public function testPartGetMultipartDownloader( ])); }); $mockClient->method('getCommand') - -> willReturnCallback(function ($commandName, $args) { + ->willReturnCallback(function ($commandName, $args) { return new Command($commandName, $args); }); @@ -96,7 +97,8 @@ public function testPartGetMultipartDownloader( * * @return array[] */ - public static function partGetMultipartDownloaderProvider(): array { + public static function partGetMultipartDownloaderProvider(): array + { return [ [ 'objectKey' => 'ObjectKey_1', @@ -211,8 +213,7 @@ public function testComputeObjectDimensions(): void * @param string $eTag * * @return void - - */ + */ #[DataProvider('ifMatchIsPresentInEachPartRequestAfterFirstProvider')] public function testIfMatchIsPresentInEachRangeRequestAfterFirst( int $objectSizeInBytes, @@ -241,7 +242,7 @@ public function testIfMatchIsPresentInEachRangeRequestAfterFirst( return new Command($commandName, $args); }); $s3Client->method('executeAsync') - -> willReturnCallback(function ($command) + ->willReturnCallback(function ($command) use ( $eTag, $objectSizeInBytes, diff --git a/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php b/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php index 70236ab835..0e12ff5d78 100644 --- a/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php +++ b/tests/S3/S3Transfer/Progress/AbstractProgressBarFormatTest.php @@ -7,23 +7,20 @@ use Aws\S3\S3Transfer\Progress\AbstractProgressBarFormat; use Aws\S3\S3Transfer\Progress\TransferProgressBarFormat; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(AbstractProgressBarFormat::class)] +#[CoversClass(ColoredTransferProgressBarFormat::class)] +#[CoversClass(PlainProgressBarFormat::class)] +#[CoversClass(TransferProgressBarFormat::class)] class AbstractProgressBarFormatTest extends TestCase { /** * Tests the different implementations of * ProgressBarFormat. Each template and parameter * can be seen in each of the implementations. - * - * @param string $implementationClass - * @param array $args - * @param string $expectedFormat - * - * @return void - * - - */ + */ #[DataProvider('progressBarFormatProvider')] public function testProgressBarFormat( string $implementationClass, diff --git a/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php b/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php index b84d569b4e..227fe97158 100644 --- a/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php +++ b/tests/S3/S3Transfer/Progress/ConsoleProgressBarTest.php @@ -8,11 +8,13 @@ use Aws\S3\S3Transfer\Progress\AbstractProgressBarFormat; use Aws\S3\S3Transfer\Progress\TransferProgressBarFormat; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; /** * Tests console progress bar. */ +#[CoversClass(ConsoleProgressBar::class)] class ConsoleProgressBarTest extends TestCase { /** @@ -92,14 +94,12 @@ public function testPercentIsNotOverOneHundred(): void * @param string $progressBarChar * @param int $progressBarWidth * @param int $percentCompleted - * @param AbstractProgressBarFormatTest $progressBarFormat + * @param AbstractProgressBarFormat $progressBarFormat * @param array $progressBarFormatArgs * @param string $expectedOutput * * @return void - * - - */ + */ #[DataProvider('progressBarRenderingProvider')] public function testProgressBarRendering( string $progressBarChar, diff --git a/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php b/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php index ee0485d5bc..c04380400f 100644 --- a/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php +++ b/tests/S3/S3Transfer/Progress/MultiProgressTrackerTest.php @@ -11,8 +11,10 @@ use Aws\S3\S3Transfer\Progress\TransferProgressSnapshot; use Closure; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(MultiProgressTracker::class)] class MultiProgressTrackerTest extends TestCase { /** @@ -29,7 +31,6 @@ public function testDefaultInitialization(): void } /** - * * @param array $progressTrackers * @param mixed $output * @param int $transferCount @@ -37,8 +38,7 @@ public function testDefaultInitialization(): void * @param int $failed * * @return void - - */ + */ #[DataProvider('customInitializationProvider')] public function testCustomInitialization( array $progressTrackers, @@ -46,8 +46,7 @@ public function testCustomInitialization( int $transferCount, int $completed, int $failed - ): void - { + ): void { $progressTracker = new MultiProgressTracker( $progressTrackers, $output, @@ -67,16 +66,13 @@ public function testCustomInitialization( * @param array $expectedOutputs * * @return void - * - - */ + */ #[DataProvider('multiProgressTrackerProvider')] public function testMultiProgressTracker( Closure $progressBarFactory, callable $eventInvoker, array $expectedOutputs, - ): void - { + ): void { $output = fopen("php://temp", "w+"); $progressTracker = new MultiProgressTracker( output: $output, diff --git a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php index 5b0839943a..15bd0d98de 100644 --- a/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php +++ b/tests/S3/S3Transfer/Progress/SingleProgressTrackerTest.php @@ -10,13 +10,12 @@ use Aws\S3\S3Transfer\Progress\AbstractTransferListener; use Aws\S3\S3Transfer\Progress\TransferProgressSnapshot; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(SingleProgressTracker::class)] class SingleProgressTrackerTest extends TestCase { - /** - * @return void - */ public function testDefaultInitialization(): void { $progressTracker = new SingleProgressTracker(); @@ -26,15 +25,6 @@ public function testDefaultInitialization(): void $this->assertNull($progressTracker->getCurrentSnapshot()); } - /** - * @param ProgressBarInterface $progressBar - * @param mixed $output - * @param bool $clear - * @param TransferProgressSnapshot $snapshot - * - * @return void - - */ #[DataProvider('customInitializationProvider')] public function testCustomInitialization( ProgressBarInterface $progressBar, @@ -55,9 +45,6 @@ public function testCustomInitialization( $this->assertSame($snapshot, $progressTracker->getCurrentSnapshot()); } - /** - * @return array[] - */ public static function customInitializationProvider(): array { return [ @@ -84,14 +71,6 @@ public static function customInitializationProvider(): array ]; } - /** - * @param ProgressBarInterface $progressBar - * @param callable $eventInvoker - * @param array $expectedOutputs - * - * @return void - - */ #[DataProvider('singleProgressTrackingProvider')] public function testSingleProgressTracking( ProgressBarInterface $progressBar, @@ -129,9 +108,6 @@ public function testSingleProgressTracking( ); } - /** - * @return array[] - */ public static function singleProgressTrackingProvider(): array { return [ diff --git a/tests/S3/S3Transfer/Progress/TransferListenerNotifierTest.php b/tests/S3/S3Transfer/Progress/TransferListenerNotifierTest.php index 4a8c4a732a..64dc1601d2 100644 --- a/tests/S3/S3Transfer/Progress/TransferListenerNotifierTest.php +++ b/tests/S3/S3Transfer/Progress/TransferListenerNotifierTest.php @@ -4,14 +4,14 @@ use Aws\S3\S3Transfer\Progress\AbstractTransferListener; use Aws\S3\S3Transfer\Progress\TransferListenerNotifier; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +#[CoversClass(TransferListenerNotifier::class)] class TransferListenerNotifierTest extends TestCase { - /** - * @return void - */ - public function testListenerNotifier(): void { + public function testListenerNotifier(): void + { $listeners = [ $this->getMockBuilder(AbstractTransferListener::class) ->getMock(), diff --git a/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php b/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php index 2b6ef5fee5..a424a9c917 100644 --- a/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php +++ b/tests/S3/S3Transfer/Progress/TransferProgressSnapshotTest.php @@ -4,13 +4,12 @@ use Aws\S3\S3Transfer\Progress\TransferProgressSnapshot; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(TransferProgressSnapshot::class)] class TransferProgressSnapshotTest extends TestCase { - /** - * @return void - */ public function testInitialization(): void { $snapshot = new TransferProgressSnapshot( @@ -26,15 +25,6 @@ public function testInitialization(): void $this->assertEquals($snapshot->getResponse(), ['Foo' => 'Bar']); } - /** - * @param int $transferredBytes - * @param int $totalBytes - * @param float $expectedRatio - * - * @return void - * - - */ #[DataProvider('ratioTransferredProvider')] public function testRatioTransferred( int $transferredBytes, @@ -50,9 +40,6 @@ public function testRatioTransferred( $this->assertEquals($expectedRatio, $snapshot->ratioTransferred()); } - /** - * @return array - */ public static function ratioTransferredProvider(): array { return [ diff --git a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php index 4d22fafabe..6d794c994e 100644 --- a/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php +++ b/tests/S3/S3Transfer/RangeGetMultipartDownloaderTest.php @@ -13,11 +13,13 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Utils; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; /** * Tests RangeGetMultipartDownloader implementation. */ +#[CoversClass(RangeGetMultipartDownloader::class)] class RangeGetMultipartDownloaderTest extends TestCase { /** @@ -28,8 +30,7 @@ class RangeGetMultipartDownloaderTest extends TestCase * @param int $targetPartSize * * @return void - - */ + */ #[DataProvider('rangeGetMultipartDownloaderProvider')] public function testRangeGetMultipartDownloader( string $objectKey, @@ -97,7 +98,8 @@ public function testRangeGetMultipartDownloader( * * @return array[] */ - public static function rangeGetMultipartDownloaderProvider(): array { + public static function rangeGetMultipartDownloaderProvider(): array + { return [ [ 'objectKey' => 'ObjectKey_1', @@ -261,8 +263,7 @@ public function testNextCommandIncludesIfMatchWhenETagPresent(): void * @param string $eTag * * @return void - - */ + */ #[DataProvider('ifMatchIsPresentInEachRangeRequestAfterFirstProvider')] public function testIfMatchIsPresentInEachRangeRequestAfterFirst( int $objectSizeInBytes, diff --git a/tests/S3/S3UriParserTest.php b/tests/S3/S3UriParserTest.php index b128cfc5cb..0ca0cea815 100644 --- a/tests/S3/S3UriParserTest.php +++ b/tests/S3/S3UriParserTest.php @@ -10,7 +10,7 @@ #[CoversClass(S3UriParser::class)] class S3UriParserTest extends TestCase { - public static function uriProvider() + public static function uriProvider(): array { return [ ['http://s3.amazonaws.com', ['region' => null, 'bucket' => null, 'key' => null, 'path_style' => true]], @@ -89,9 +89,6 @@ public static function uriProvider() ]; } - /** - - */ #[DataProvider('uriProvider')] public function testParsesUrls($uri, $result, $isError = false) { diff --git a/tests/S3/SSECMiddlewareTest.php b/tests/S3/SSECMiddlewareTest.php index 7dc6901aaa..4d6ebe1f5a 100644 --- a/tests/S3/SSECMiddlewareTest.php +++ b/tests/S3/SSECMiddlewareTest.php @@ -5,18 +5,16 @@ use Aws\Result; use Aws\S3\SSECMiddleware; use Aws\Test\UsesServiceTrait; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; +use PHPUnit\Framework\Attributes\DataProvider; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; #[CoversClass(SSECMiddleware::class)] class SSECMiddlewareTest extends TestCase { use UsesServiceTrait; - /** - - */ #[DataProvider('getListenerTestCases')] public function testSseCpkListener($operation, array $params, array $expectedResults) { @@ -33,7 +31,7 @@ public function testSseCpkListener($operation, array $params, array $expectedRes $s3->execute($cmd); } - public static function getListenerTestCases() + public static function getListenerTestCases(): array { return [ [ diff --git a/tests/S3/StreamWrapperPathStyleTest.php b/tests/S3/StreamWrapperPathStyleTest.php index 6d224716b4..47a7f62801 100644 --- a/tests/S3/StreamWrapperPathStyleTest.php +++ b/tests/S3/StreamWrapperPathStyleTest.php @@ -14,6 +14,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; #[CoversClass(StreamWrapper::class)] class StreamWrapperPathStyleTest extends TestCase @@ -362,9 +363,6 @@ public static function rmdirProvider(): array ]; } - /** - - */ #[DataProvider('rmdirProvider')] public function testCanDeleteObjectWithRmDir($path) { @@ -585,7 +583,7 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, stat('s3://bucket/prefix'); } - public static function fileTypeProvider() + public static function fileTypeProvider(): array { $err = function ($cmd, $r) { return new S3Exception('404', $cmd); }; @@ -618,9 +616,6 @@ public static function fileTypeProvider() ]; } - /** - - */ #[DataProvider('fileTypeProvider')] public function testDeterminesIfFileOrDir($uri, $queue, $result) { diff --git a/tests/S3/StreamWrapperTest.php b/tests/S3/StreamWrapperTest.php index 689006d541..6db538b091 100644 --- a/tests/S3/StreamWrapperTest.php +++ b/tests/S3/StreamWrapperTest.php @@ -15,6 +15,7 @@ use Psr\Http\Message\RequestInterface; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; #[CoversClass(StreamWrapper::class)] class StreamWrapperTest extends TestCase @@ -543,7 +544,7 @@ public function testCanDeleteBucketWithRmDir() $this->assertSame('bucket.s3.amazonaws.com', $entries[0]['request']->getUri()->getHost()); } - public static function rmdirProvider() + public static function rmdirProvider(): array { return [ ['s3://bucket/object/'], @@ -551,9 +552,6 @@ public static function rmdirProvider() ]; } - /** - - */ #[DataProvider('rmdirProvider')] public function testCanDeleteObjectWithRmDir($path) { @@ -847,7 +845,7 @@ function ($cmd, $r) { return new S3Exception('404', $cmd); }, } } - public static function fileTypeProvider() + public static function fileTypeProvider(): array { $err = function ($cmd, $r) { return new S3Exception('404', $cmd); }; @@ -880,9 +878,6 @@ public static function fileTypeProvider() ]; } - /** - - */ #[DataProvider('fileTypeProvider')] public function testDeterminesIfFileOrDir($uri, $queue, $result) { @@ -1168,9 +1163,6 @@ public static function contentProvider(): array ]; } - /** - - */ #[DataProvider('contentProvider')] public function testTriggersErrorOnNoFlushOrClose(string $content) { diff --git a/tests/S3/StreamWrapperV2ExistenceTest.php b/tests/S3/StreamWrapperV2ExistenceTest.php index 0a6461114b..2dc4fef839 100644 --- a/tests/S3/StreamWrapperV2ExistenceTest.php +++ b/tests/S3/StreamWrapperV2ExistenceTest.php @@ -13,6 +13,7 @@ use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\DataProvider; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; @@ -43,9 +44,7 @@ public function tear_down() $this->client = null; } - /** #[CoversNothing] - */ public function testSuccessfulXMode() { $this->addMockResults( @@ -483,7 +482,10 @@ public function testCanDeleteBucketWithRmDir() $this->assertSame('bucket.s3.amazonaws.com', $entries[0]['request']->getUri()->getHost()); } - public static function rmdirProvider() + /** + * @return array> + */ + public static function rmdirProvider(): array { return [ ['s3://bucket/object/'], @@ -777,7 +779,10 @@ function ($cmd, $r) { return new S3Exception( } } - public static function fileTypeProvider() + /** + * @return array> + */ + public static function fileTypeProvider(): array { $err = function ($cmd, $r) { return new S3Exception( '404', diff --git a/tests/S3/TransferTest.php b/tests/S3/TransferTest.php index 184236fb43..9262b75038 100644 --- a/tests/S3/TransferTest.php +++ b/tests/S3/TransferTest.php @@ -378,9 +378,6 @@ function (CommandInterface $cmd, RequestInterface $req) { $this->deleteDirectory($dir); } - /** - - */ #[DataProvider('providedPathsOutsideTarget')] public function testCannotDownloadObjectsOutsideTarget($key) { @@ -410,7 +407,8 @@ public function testCannotDownloadObjectsOutsideTarget($key) $this->deleteDirectory($dir); } - public static function providedPathsOutsideTarget() { + public static function providedPathsOutsideTarget(): array + { return [ ['bar/../a/b'], //ensures if path resolves to target directory @@ -551,13 +549,6 @@ function (CommandInterface $cmd, RequestInterface $req) { $this->deleteDirectory($dir); } - /** - * @param $checksumAlgorithm - * @param $value - * @return void - * - - */ #[DataProvider('flexibleChecksumsProvider')] public function testAddsFlexibleChecksums($checksumAlgorithm) { @@ -616,7 +607,8 @@ function (CommandInterface $cmd, RequestInterface $req) use ($checksumAlgorithm) $this->deleteDirectory($dir); } - public static function flexibleChecksumsProvider() { + public static function flexibleChecksumsProvider(): array + { return [ ['sha256'], ['sha1'], diff --git a/tests/S3/UseArnRegion/ConfigurationProviderTest.php b/tests/S3/UseArnRegion/ConfigurationProviderTest.php index f54aca36d9..12f383a01f 100644 --- a/tests/S3/UseArnRegion/ConfigurationProviderTest.php +++ b/tests/S3/UseArnRegion/ConfigurationProviderTest.php @@ -8,7 +8,7 @@ use Aws\S3\UseArnRegion\ConfigurationProvider; use Aws\S3\UseArnRegion\Exception\ConfigurationException; use GuzzleHttp\Promise; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(ConfigurationProvider::class)] @@ -30,7 +30,7 @@ class ConfigurationProviderTest extends TestCase s3_use_arn_region = true EOT; - public static function set_up_before_class() + public static function setUpBeforeClass(): void { self::$originalEnv = [ 'use_arn_region' => getenv(ConfigurationProvider::ENV_USE_ARN_REGION) ?: '', @@ -55,7 +55,7 @@ private function clearEnv() return $dir; } - public static function tear_down_after_class() + public static function tearDownAfterClass(): void { putenv(ConfigurationProvider::ENV_USE_ARN_REGION . '=' . self::$originalEnv['use_arn_region']); @@ -351,4 +351,3 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } } - diff --git a/tests/S3/UseArnRegion/ConfigurationTest.php b/tests/S3/UseArnRegion/ConfigurationTest.php index 5a365c0537..f2ec7961d4 100644 --- a/tests/S3/UseArnRegion/ConfigurationTest.php +++ b/tests/S3/UseArnRegion/ConfigurationTest.php @@ -6,15 +6,9 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\S3\UseArnRegion\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { - /** - * - * @param $param - * @param $expected - - */ #[DataProvider('correctValueCases')] public function testGetsCorrectValues($param, $expected) { @@ -22,7 +16,7 @@ public function testGetsCorrectValues($param, $expected) $this->assertEquals($expected, $config->isUseArnRegion()); } - public static function correctValueCases() + public static function correctValueCases(): array { return [ [true, true], diff --git a/tests/S3/ValidateResponseChecksumParserTest.php b/tests/S3/ValidateResponseChecksumParserTest.php index 124f7fe9da..d30f39c049 100644 --- a/tests/S3/ValidateResponseChecksumParserTest.php +++ b/tests/S3/ValidateResponseChecksumParserTest.php @@ -18,9 +18,6 @@ class ValidateResponseChecksumParserTest extends TestCase { use UsesServiceTrait; - /** - - */ #[DataProvider('getChosenChecksumCases')] public function testValidatesChoosesRightChecksum( $responseAlgorithms, $checksumHeadersReturned, $expectedChecksum @@ -47,7 +44,7 @@ public function testValidatesChoosesRightChecksum( $this->assertEquals($expectedChecksum, $chosenChecksum); } - public static function getChosenChecksumCases() + public static function getChosenChecksumCases(): array { return [ [['crc32', 'crc32c'], [], null], diff --git a/tests/S3Control/EndpointArnMiddlewareTest.php b/tests/S3Control/EndpointArnMiddlewareTest.php index 6a75ae2715..0e5d3970db 100644 --- a/tests/S3Control/EndpointArnMiddlewareTest.php +++ b/tests/S3Control/EndpointArnMiddlewareTest.php @@ -6,6 +6,7 @@ use Aws\Endpoint\PartitionEndpointProvider; use Aws\Exception\InvalidRegionException; use Aws\Middleware; +use Aws\S3Control\EndpointArnMiddleware; use GuzzleHttp\Promise; use GuzzleHttp\Psr7\Response; use Yoast\PHPUnitPolyfills\TestCases\TestCase; @@ -13,24 +14,11 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\S3Control\EndpointArnMiddleware::class)] +#[CoversClass(EndpointArnMiddleware::class)] class EndpointArnMiddlewareTest extends TestCase { use S3ControlTestingTrait; - /** - * - * @param $cmdName - * @param $cmdParams - * @param $options - * @param $endpoint - * @param $target - * @param $headers - * @param $signingRegion - * @param $signingService - * @throws \Exception - - */ #[DataProvider('providedSuccessCases')] public function testCorrectlyModifiesRequestAndCommand( $cmdName, @@ -72,7 +60,7 @@ public function testCorrectlyModifiesRequestAndCommand( $s3control->execute($command); } - public static function providedSuccessCases() + public static function providedSuccessCases(): array { return [ // Outposts accesspoint ARN @@ -423,15 +411,6 @@ public static function providedSuccessCases() ]; } - /** - * - * @param $cmdName - * @param $cmdParams - * @param $options - * @param $expectedException - * @throws \Exception - - */ #[DataProvider('providedFailureCases')] public function testCorrectlyThrowsForBadInputsOrConfig( $cmdName, @@ -457,7 +436,7 @@ public function testCorrectlyThrowsForBadInputsOrConfig( } } - public static function providedFailureCases() + public static function providedFailureCases(): array { return [ // Outposts accesspoint ARN, different region diff --git a/tests/Script/ComposerTest.php b/tests/Script/ComposerTest.php index 5f8ca87cff..2ac0dacf9c 100644 --- a/tests/Script/ComposerTest.php +++ b/tests/Script/ComposerTest.php @@ -6,11 +6,13 @@ use Symfony\Component\Filesystem\Exception\IOException; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Symfony\Component\Filesystem\Filesystem; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(Composer::class)] class ComposerTest extends TestCase { - public static function invalidServiceNameProvider() + public static function invalidServiceNameProvider(): array { return [ [['foo'], 'foo'], @@ -20,12 +22,6 @@ public static function invalidServiceNameProvider() ]; } - /** - * - * @param $serviceList - * @param $invalidService - - */ #[DataProvider('invalidServiceNameProvider')] public function testListInvalidServiceName($serviceList, $invalidService) { @@ -47,7 +43,7 @@ public function testNoListedServices() Composer::removeUnusedServices($this->getMockEvent([])); } - public static function servicesToKeepProvider() + public static function servicesToKeepProvider(): array { return [ [['S3']], @@ -59,11 +55,6 @@ public static function servicesToKeepProvider() ]; } - /** - * - * @param $servicesToKeep - - */ #[DataProvider('servicesToKeepProvider')] public function testRemoveServices($servicesToKeep) { @@ -116,9 +107,6 @@ public function testRemoveServices($servicesToKeep) } } - /** - - */ #[DataProvider('retryProvider')] public function testRetriesOnException($success, $writeCalls) { @@ -170,7 +158,7 @@ public function testRetriesOnException($success, $writeCalls) ); } - public static function retryProvider() + public static function retryProvider(): array { return [ 'success' => [true , 3], @@ -234,4 +222,4 @@ private function getMockEvent( return $mockEvent; } -} \ No newline at end of file +} diff --git a/tests/SdkTest.php b/tests/SdkTest.php index a990012ee4..53266adbd6 100644 --- a/tests/SdkTest.php +++ b/tests/SdkTest.php @@ -11,7 +11,6 @@ #[CoversClass(Sdk::class)] class SdkTest extends TestCase { - public function testEnsuresMissingMethodThrowsException() { $this->expectException(\BadMethodCallException::class); diff --git a/tests/Ses/SesClientTest.php b/tests/Ses/SesClientTest.php index de6daa45f6..eeb53fee73 100644 --- a/tests/Ses/SesClientTest.php +++ b/tests/Ses/SesClientTest.php @@ -3,8 +3,10 @@ use Aws\Credentials\Credentials; use Aws\Ses\SesClient; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; +#[CoversClass(SesClient::class)] class SesClientTest extends TestCase { public function testCanGenerateSmtpPasswordFromCredentials() diff --git a/tests/Signature/DpopSignatureTest.php b/tests/Signature/DpopSignatureTest.php index dbc9fd2c1c..b151be684b 100644 --- a/tests/Signature/DpopSignatureTest.php +++ b/tests/Signature/DpopSignatureTest.php @@ -141,9 +141,6 @@ public function testDerToRawConvertsValidSignature(): void $this->assertEquals(64, strlen($raw)); } - /** - * Test that derToRaw properly handles DER signatures with various R and S lengths - */ public function testDerToRawHandlesVariableLengthComponents(): void { $dpop = new DpopSignature('signin'); @@ -189,9 +186,6 @@ public function testDerToRawHandlesVariableLengthComponents(): void $this->assertEquals(64, strlen($raw4)); } - /** - * Test that derToRaw throws for invalid DER signatures - */ public function testDerToRawThrowsForInvalidSignatures(): void { $dpop = new DpopSignature('signin'); @@ -261,9 +255,6 @@ public function testDerToRawThrowsForLengthMismatch(): void ); } - /** - * Test that the signature can be verified with openssl - */ public function testSignatureCanBeVerified(): void { $dpop = new DpopSignature('signin'); @@ -313,9 +304,6 @@ public function testSignatureCanBeVerified(): void $this->assertEquals(1, $verified); } - /** - * Test that multiple signatures from the same key produce different JWTs (due to jti) - */ public function testMultipleSignaturesProduceDifferentJwts(): void { $dpop = new DpopSignature('signin'); @@ -338,9 +326,6 @@ public function testMultipleSignaturesProduceDifferentJwts(): void $this->assertEquals($parts1[0], $parts2[0]); } - /** - * Test that a key with specifiedCurve parameters works correctly - */ public function testSignRequestWithSpecifiedCurveKey(): void { $dpop = new DpopSignature('signin'); diff --git a/tests/Signature/S3SignatureV4Test.php b/tests/Signature/S3SignatureV4Test.php index 4d0b803c8e..e4b0beaa43 100644 --- a/tests/Signature/S3SignatureV4Test.php +++ b/tests/Signature/S3SignatureV4Test.php @@ -8,6 +8,7 @@ use PHPUnit\Framework\Attributes\CoversClass; require_once __DIR__ . '/sig_hack.php'; + #[CoversClass(S3SignatureV4::class)] class S3SignatureV4Test extends TestCase { diff --git a/tests/Signature/SignatureProviderTest.php b/tests/Signature/SignatureProviderTest.php index f2be70df94..a2d43fcd8a 100644 --- a/tests/Signature/SignatureProviderTest.php +++ b/tests/Signature/SignatureProviderTest.php @@ -15,7 +15,7 @@ #[CoversClass(SignatureProvider::class)] class SignatureProviderTest extends TestCase { - public static function versionProvider() + public static function versionProvider(): array { return [ ['v4', SignatureV4::class, 'foo'], @@ -36,9 +36,6 @@ public static function versionProvider() ]; } - /** - - */ #[DataProvider('versionProvider')] public function testCreatesSignatureFromVersionString($v, $type, $service) { diff --git a/tests/Signature/SignatureV4Test.php b/tests/Signature/SignatureV4Test.php index 166b7bd8dd..fb81a08e15 100644 --- a/tests/Signature/SignatureV4Test.php +++ b/tests/Signature/SignatureV4Test.php @@ -118,7 +118,7 @@ private function decodeQueryPairs(string $query): array return $pairs; } - public static function getExpiresDateTimeInterfaceInputs() + public static function getExpiresDateTimeInterfaceInputs(): array { return [ [ @@ -130,9 +130,6 @@ public static function getExpiresDateTimeInterfaceInputs() ]; } - /** - - */ #[DataProvider('getExpiresDateTimeInterfaceInputs')] public function testCreatesPresignedDatesFromDateTime($dateTime) { @@ -182,7 +179,7 @@ public function testAddsSecurityTokenIfPresentInPresigned() $this->assertStringContainsString('X-Amz-Expires=518400', $url); } - public static function getStartDateTimeInterfaceInputs() + public static function getStartDateTimeInterfaceInputs(): array { return [ [ @@ -194,9 +191,6 @@ public static function getStartDateTimeInterfaceInputs() ]; } - /** - - */ #[DataProvider('getStartDateTimeInterfaceInputs')] public function testUsesStartDateFromDateTimeIfPresent($dateTime) { @@ -394,7 +388,7 @@ public function testEnsuresContentSha256CanBeCalculatedWhenSeekFails() $signature->signRequest($request, $credentials); } - public static function unsignedPayloadProvider() + public static function unsignedPayloadProvider(): array { return [ // POST headers should be signed. @@ -448,9 +442,6 @@ public static function unsignedPayloadProvider() ]; } - /** - - */ #[DataProvider('unsignedPayloadProvider')] public function testSignRequestUnsignedPayload($req, $sreq, $creq) { @@ -467,10 +458,9 @@ public function testSignRequestUnsignedPayload($req, $sreq, $creq) $ctx = $contextFn->invoke($signature, $parsed, $payload); $this->assertEquals($creq, $ctx['creq']); $this->assertSame($sreq, Psr7\Message::toString($signature->signRequest($request, $credentials))); - $this->assertTrue(true); } - public static function provider() + public static function provider(): array { return [ // POST headers should be signed. @@ -572,9 +562,6 @@ public static function provider() ]; } - /** - - */ #[DataProvider('provider')] public function testSignsRequests($req, $sreq, $creq) { @@ -590,7 +577,6 @@ public function testSignsRequests($req, $sreq, $creq) $ctx = $contextFn->invoke($signature, $parsed, $payload); $this->assertEquals($creq, $ctx['creq']); $this->assertSame($sreq, Psr7\Message::toString($signature->signRequest($request, $credentials))); - $this->assertTrue(true); } public function testRemovesIllegalV4aHeadersBeforeSigning() diff --git a/tests/Sqs/SqsClientTest.php b/tests/Sqs/SqsClientTest.php index ee21ea778e..065dbfad82 100644 --- a/tests/Sqs/SqsClientTest.php +++ b/tests/Sqs/SqsClientTest.php @@ -7,6 +7,7 @@ use Aws\Test\UsesServiceTrait; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; #[CoversClass(SqsClient::class)] class SqsClientTest extends TestCase diff --git a/tests/StreamRequestPayloadMiddlewareTest.php b/tests/StreamRequestPayloadMiddlewareTest.php index 130c2a3d51..295e780444 100644 --- a/tests/StreamRequestPayloadMiddlewareTest.php +++ b/tests/StreamRequestPayloadMiddlewareTest.php @@ -17,18 +17,11 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\StreamRequestPayloadMiddleware::class)] +#[CoversClass(StreamRequestPayloadMiddleware::class)] class StreamRequestPayloadMiddlewareTest extends TestCase { use ArraySubsetAsserts; - /** - * - * @param array $commandDef - * @param array $expectedHeaders - * @param array $expectedNonHeaders - - */ #[DataProvider('addsProperHeadersDataProvider')] public function testAddsProperHeaders( array $commandDef, @@ -287,5 +280,4 @@ private function generateTestService() function () { return []; } ); } - } diff --git a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php index 99505a6254..bf1c566da7 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php @@ -10,11 +10,10 @@ use Aws\Sts\RegionalEndpoints\Exception\ConfigurationException; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; -/** - * git\Sts\RegionalEndpoints\ConfigurationProvider - */ +#[CoversClass(ConfigurationProvider::class)] class ConfigurationProviderTest extends TestCase { private static $originalEnv; @@ -353,7 +352,7 @@ public function testCreatesFromCache() $this->assertSame($expected->toArray(), $result->toArray()); } - public static function getSuccessfulUnwrapData() + public static function getSuccessfulUnwrapData(): array { $expected = new Configuration('regional'); return [ @@ -384,11 +383,6 @@ function () use ($expected) { ]; } - /** - * @param $toUnwrap - * @param ConfigurationInterface $expected - - */ #[DataProvider('getSuccessfulUnwrapData')] public function testSuccessfulUnwraps($toUnwrap, ConfigurationInterface $expected) { diff --git a/tests/Sts/RegionalEndpoints/ConfigurationTest.php b/tests/Sts/RegionalEndpoints/ConfigurationTest.php index c87bfd3759..29f2b9aab8 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationTest.php @@ -6,7 +6,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\CoversClass; -#[CoversClass(\Aws\Sts\RegionalEndpoints\Configuration::class)] +#[CoversClass(Configuration::class)] class ConfigurationTest extends TestCase { public function testGetsCorrectValues() diff --git a/tests/Sts/StsClientTest.php b/tests/Sts/StsClientTest.php index 7932f32841..4b6bc3eb9d 100644 --- a/tests/Sts/StsClientTest.php +++ b/tests/Sts/StsClientTest.php @@ -183,11 +183,6 @@ public function testCanCreateCredentialsObjectFromStsResultWithFederatedUser() $this->assertFalse($credentials->isExpired()); } - /** - * - * @return void - - */ #[DataProvider('stsAssumeRoleOperationsDataProvider')] public function testStsAssumeRoleOperationsWithAccountId($response, $expected) { @@ -233,9 +228,6 @@ public static function stsAssumeRoleOperationsDataProvider(): array ]; } - /** - - */ #[DataProvider('stsAssumeRoleWithSAMLOperationsDataProvider')] public function testStsAssumeRoleWithSAMLOperationsWithAccountId( $response, @@ -293,9 +285,6 @@ public static function stsAssumeRoleWithSAMLOperationsDataProvider(): array ]; } - /** - - */ #[DataProvider('stsAssumeRoleWithWebIdentityOperationsDataProvider')] public function testStsAssumeRoleWithWebIdentityOperationsWithAccountId( $response, @@ -350,9 +339,6 @@ public static function stsAssumeRoleWithWebIdentityOperationsDataProvider(): arr ]; } - /** - - */ #[DataProvider('stsGetFederationTokenOperationsDataProvider')] public function testStsGetFederationTokenOperationsWithAccountId( $response, diff --git a/tests/Token/BearerTokenAuthorizationTest.php b/tests/Token/BearerTokenAuthorizationTest.php index 730febd449..2957934f1c 100644 --- a/tests/Token/BearerTokenAuthorizationTest.php +++ b/tests/Token/BearerTokenAuthorizationTest.php @@ -4,14 +4,15 @@ use Aws\Token\BearerTokenAuthorization; use Aws\Token\Token; use GuzzleHttp\Psr7\Request; -use Yoast\PHPUnitPolyfills\TestCases\TestCase; -use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\TestCase; #[CoversClass(BearerTokenAuthorization::class)] -class BearerTokenAuthorizationTest extends TestCase { - - public static function bearerTestProvider() { +class BearerTokenAuthorizationTest extends TestCase +{ + public static function bearerTestProvider(): array + { return [ "Minimal bearer auth case" => [ @@ -31,13 +32,13 @@ public static function bearerTestProvider() { "token" => "mF_9.B5f-4.1JqM", "expectedHeaders" => ["Authorization" => "Bearer mF_9.B5f-4.1JqM",], ], - ]; + ]; } - #[DataProvider('bearerTestProvider')] - public function testBearerSuccessCases($headers, $tokenString, $expectedHeaders) { - $authorizer = new \Aws\Token\BearerTokenAuthorization(); + public function testBearerSuccessCases($headers, $tokenString, $expectedHeaders) + { + $authorizer = new BearerTokenAuthorization(); $request = new Request('GET', 'http://foo.com'); foreach ($headers as $header => $value) { $request = $request->withHeader($header, $value); @@ -49,12 +50,13 @@ public function testBearerSuccessCases($headers, $tokenString, $expectedHeaders) } } - public function testBearerNullToken() { - $authorizer = new \Aws\Token\BearerTokenAuthorization(); + public function testBearerNullToken() + { + $authorizer = new BearerTokenAuthorization(); $request = new Request('GET', 'http://foo.com'); $token = new Token(null); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage("Cannot authorize a request with an empty token"); $authorizer->authorizeRequest($request, $token); } -} \ No newline at end of file +} diff --git a/tests/Token/BedrockTokenProviderTest.php b/tests/Token/BedrockTokenProviderTest.php index 18a69104c4..dc2ed554f5 100644 --- a/tests/Token/BedrockTokenProviderTest.php +++ b/tests/Token/BedrockTokenProviderTest.php @@ -13,8 +13,10 @@ use Aws\Token\TokenSource; use GuzzleHttp\Promise; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +#[CoversClass(BedrockTokenProvider::class)] class BedrockTokenProviderTest extends TestCase { use UsesServiceTrait; @@ -238,12 +240,6 @@ public function testMemoization(): void /** * Test integration with Bedrock Clients - * - * @param $serviceName - * @param $envVars - * @param $clientArgs - * @param $expectations - * @param $iniConfig */ #[DataProvider('integrationWithClientProvider')] public function testIntegrationWithClient( @@ -317,7 +313,7 @@ public function testIntegrationWithClient( public static function integrationWithClientProvider(): \Generator { - static $services = [ + $services = [ 'bedrock', 'bedrock-agent', 'bedrock-agent-runtime', @@ -394,9 +390,7 @@ public static function integrationWithClientProvider(): \Generator /** * Test that token source is added to user agent header - * - - */ + */ #[DataProvider('tokenSourceUserAgentProvider')] public function testTokenSourceInUserAgent( string $service, diff --git a/tests/Token/SsoTokenProviderTest.php b/tests/Token/SsoTokenProviderTest.php index 1374bc5b01..9286fad54c 100644 --- a/tests/Token/SsoTokenProviderTest.php +++ b/tests/Token/SsoTokenProviderTest.php @@ -1,7 +1,6 @@ homepath); } - public function testSsoTokenProviderSuccess() { $dir = $this->clearEnv(); diff --git a/tests/Token/TokenProviderTest.php b/tests/Token/TokenProviderTest.php index 7eb7a66b5c..a95dc97d17 100644 --- a/tests/Token/TokenProviderTest.php +++ b/tests/Token/TokenProviderTest.php @@ -161,8 +161,6 @@ public static function tokenProviderSuccessCases(): array ]; } - /** - */ #[DataProvider('tokenProviderSuccessCases')] public function testTokenProviderCachedSuccess($cachedToken, $expectedToken) { @@ -263,8 +261,6 @@ public static function tokenProviderSuccessCasesWithRefresh(): array ]; } - /** - */ #[DataProvider('tokenProviderSuccessCasesWithRefresh')] public function testTokenProviderCachedSuccessWithRefresh( $currentTime, @@ -397,8 +393,6 @@ public static function tokenProviderFailureCases(): array ]; } - /** - */ #[DataProvider('tokenProviderFailureCases')] public function testTokenProviderFailureCases($cachedToken, $expectedException) { @@ -459,4 +453,4 @@ public function testCacheWritesAndReadsCorrectFormat() $this->assertEquals(1, $providerCallCount, 'Provider should not be called again'); $this->assertEquals('test-token', $result2->getToken()); } -} \ No newline at end of file +} diff --git a/tests/TraceMiddlewareTest.php b/tests/TraceMiddlewareTest.php index 4c3b400160..57abeb6708 100644 --- a/tests/TraceMiddlewareTest.php +++ b/tests/TraceMiddlewareTest.php @@ -128,13 +128,6 @@ public function testTracksAwsSpecificExceptions() $this->assertStringContainsString('string(5) "error"', $str); } - /** - * - * @param string $key - * @param string $signature - * @param array $headers - - */ #[DataProvider('authStringProvider')] public function testScrubsAuthStrings($key, $signature, array $headers) { @@ -240,7 +233,7 @@ public function testEmitsForMiddlewareThatDoesNotReturnRequest() $this->assertEquals('success', $result[0]); } - public static function authStringProvider() + public static function authStringProvider(): array { return [ // v4 signature example from http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-auth-using-authorization-header.html diff --git a/tests/WaiterTest.php b/tests/WaiterTest.php index 5143ab7dff..b4f25baf55 100644 --- a/tests/WaiterTest.php +++ b/tests/WaiterTest.php @@ -22,6 +22,7 @@ use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\CoversNothing; #[CoversClass(Waiter::class)] class WaiterTest extends TestCase @@ -148,9 +149,6 @@ public function testCanWait() $this->assertSame(6000, $waitTime, 'Did not delay long enough.'); } - /** - - */ #[DataProvider('waiterWorkflowDataProvider')] public function testWaiterWorkflow($results, $expectedException) { @@ -282,9 +280,6 @@ private function getApiProvider() }; } - /** - - */ #[DataProvider('matcherDataProvider')] public function testMatchers($matcher, $result, $acceptor, $expected) { @@ -300,9 +295,6 @@ public function testMatchers($matcher, $result, $acceptor, $expected) )); } - /** - * @return array - */ public static function matcherDataProvider(): array { return [ @@ -478,7 +470,6 @@ private function getMockResult($data = []) return new Result($data + ['@metadata' => ['statusCode' => 200]]); } - /** * Tests the waiter expects not error. * This means the operation should succeed. diff --git a/tests/WrappedHttpHandlerTest.php b/tests/WrappedHttpHandlerTest.php index 7dae072295..dd2bcde89c 100644 --- a/tests/WrappedHttpHandlerTest.php +++ b/tests/WrappedHttpHandlerTest.php @@ -91,16 +91,6 @@ public function testCanRejectWithoutResponse() } } - /** - * - * @param Response $res - * @param string $serviceName - * @param string $errorParserClass - * @param string|null $expectedCode - * @param string|null $expectedId - * @param array $expectedArray - - */ #[DataProvider('responseAndParserProvider')] public function testCanRejectWithAndParseResponse( Response $res, From 0927f7903d1b24017d728df696d3f438456e6f63 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 11:58:10 -0800 Subject: [PATCH 13/19] fix: format issues --- tests/S3/S3MultiRegionClientTest.php | 2 +- tests/UserAgentMiddlewareTest.php | 244 ++++++++++++++------------- 2 files changed, 127 insertions(+), 119 deletions(-) diff --git a/tests/S3/S3MultiRegionClientTest.php b/tests/S3/S3MultiRegionClientTest.php index 99b5e7c298..7f366a4f99 100644 --- a/tests/S3/S3MultiRegionClientTest.php +++ b/tests/S3/S3MultiRegionClientTest.php @@ -16,7 +16,7 @@ use GuzzleHttp\Promise\RejectedPromise; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; use Psr\Http\Message\RequestInterface; #[CoversClass(S3MultiRegionClient::class)] diff --git a/tests/UserAgentMiddlewareTest.php b/tests/UserAgentMiddlewareTest.php index d661dfa412..1c3848d27a 100644 --- a/tests/UserAgentMiddlewareTest.php +++ b/tests/UserAgentMiddlewareTest.php @@ -38,17 +38,15 @@ use GuzzleHttp\Promise\Create; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; +use PHPUnit\Framework\Attributes\RunClassInSeparateProcess; use Psr\Http\Message\RequestInterface; use GuzzleHttp\Psr7\Request; use Yoast\PHPUnitPolyfills\TestCases\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\CoversClass; -/** - * @runInSeparateProcess - - */ #[CoversClass(\Aws\UserAgentMiddleware::class)] +#[RunClassInSeparateProcess] class UserAgentMiddlewareTest extends TestCase { use MetricsBuilderTestTrait; @@ -409,70 +407,75 @@ public function testUserAgentCaptureS3TransferMetric() */ public function testUserAgentCaptureS3CryptoV1Metric() { - $kms = $this->getTestKmsClient(); - $list = $kms->getHandlerList(); - $list->setHandler(function ($cmd, $req) { - // Verify decryption command has correct parameters - $this->assertSame('cek', $cmd['CiphertextBlob']); - $this->assertEquals( - [ - 'kms_cmk_id' => '11111111-2222-3333-4444-555555555555' - ], - $cmd['EncryptionContext'] - ); - return Create::promiseFor( - new Result(['Plaintext' => random_bytes(32)]) - ); - }); - $provider = new KmsMaterialsProvider($kms, 'foo'); + set_error_handler(function ($errno, $errstr) {}, E_USER_WARNING); + try { + $kms = $this->getTestKmsClient(); + $list = $kms->getHandlerList(); + $list->setHandler(function ($cmd, $req) { + // Verify decryption command has correct parameters + $this->assertSame('cek', $cmd['CiphertextBlob']); + $this->assertEquals( + [ + 'kms_cmk_id' => '11111111-2222-3333-4444-555555555555' + ], + $cmd['EncryptionContext'] + ); + return Create::promiseFor( + new Result(['Plaintext' => random_bytes(32)]) + ); + }); + $provider = new KmsMaterialsProvider($kms, 'foo'); - $responded = false; - $s3Client = new S3Client([ - 'region' => 'us-east-2', - 'handler' => function ( - CommandInterface $_, - RequestInterface $request - ) { + $responded = false; + $s3Client = new S3Client([ + 'region' => 'us-east-2', + 'handler' => function ( + CommandInterface $_, + RequestInterface $request + ) { - $metrics = $this->getMetricsAsArray($request); + $metrics = $this->getMetricsAsArray($request); - $this->assertTrue( - in_array(MetricsBuilder::S3_CRYPTO_V2, $metrics) - ); + $this->assertTrue( + in_array(MetricsBuilder::S3_CRYPTO_V2, $metrics) + ); - return new Result([ - 'Body' => 'This is a test body' - ]); - }, - 'http_handler' => function () use ($provider, &$responded) { - if ($responded) { + return new Result([ + 'Body' => 'This is a test body' + ]); + }, + 'http_handler' => function () use ($provider, &$responded) { + if ($responded) { + return new FulfilledPromise(new Response( + 200, + [], + json_encode( + $this->getValidV1GcmMetadataFields($provider) + ) + )); + } + + $responded = true; return new FulfilledPromise(new Response( 200, [], - json_encode( - $this->getValidV1GcmMetadataFields($provider) - ) + 'test' )); - } - - $responded = true; - return new FulfilledPromise(new Response( - 200, - [], - 'test' - )); - }, - ]); - $encryptionClient = @new S3EncryptionClient( - $s3Client, - InstructionFileMetadataStrategy::DEFAULT_FILE_SUFFIX - ); - $result = $encryptionClient->getObject([ - 'Bucket' => 'foo', - 'Key' => 'foo', - '@MaterialsProvider' => $provider, - ]); - $this->assertInstanceOf(AesGcmDecryptingStream::class, $result['Body']); + }, + ]); + $encryptionClient = @new S3EncryptionClient( + $s3Client, + InstructionFileMetadataStrategy::DEFAULT_FILE_SUFFIX + ); + $result = $encryptionClient->getObject([ + 'Bucket' => 'foo', + 'Key' => 'foo', + '@MaterialsProvider' => $provider, + ]); + $this->assertInstanceOf(AesGcmDecryptingStream::class, $result['Body']); + } finally { + restore_error_handler(); + } } /** @@ -482,72 +485,77 @@ public function testUserAgentCaptureS3CryptoV1Metric() */ public function testUserAgentCaptureS3CryptoV2Metric() { - $kms = $this->getTestKmsClient(); - $list = $kms->getHandlerList(); - $list->setHandler(function ($cmd, $req) { - // Verify decryption command has correct parameters - $this->assertSame('cek', $cmd['CiphertextBlob']); - $this->assertEquals( - [ - 'aws:x-amz-cek-alg' => 'AES/GCM/NoPadding' - ], - $cmd['EncryptionContext'] - ); - return Create::promiseFor( - new Result(['Plaintext' => random_bytes(32)]) - ); - }); - $provider = new KmsMaterialsProviderV2($kms, 'foo'); + set_error_handler(function ($errno, $errstr) {}, E_USER_WARNING); + try { + $kms = $this->getTestKmsClient(); + $list = $kms->getHandlerList(); + $list->setHandler(function ($cmd, $req) { + // Verify decryption command has correct parameters + $this->assertSame('cek', $cmd['CiphertextBlob']); + $this->assertEquals( + [ + 'aws:x-amz-cek-alg' => 'AES/GCM/NoPadding' + ], + $cmd['EncryptionContext'] + ); + return Create::promiseFor( + new Result(['Plaintext' => random_bytes(32)]) + ); + }); + $provider = new KmsMaterialsProviderV2($kms, 'foo'); - $responded = false; - $s3Client = new S3Client([ - 'region' => 'us-east-2', - 'handler' => function ( - CommandInterface $_, - RequestInterface $request - ) { + $responded = false; + $s3Client = new S3Client([ + 'region' => 'us-east-2', + 'handler' => function ( + CommandInterface $_, + RequestInterface $request + ) { - $metrics = $this->getMetricsAsArray($request); + $metrics = $this->getMetricsAsArray($request); - $this->assertTrue( - in_array(MetricsBuilder::S3_CRYPTO_V2, $metrics) - ); + $this->assertTrue( + in_array(MetricsBuilder::S3_CRYPTO_V2, $metrics) + ); - return new Result([ - 'Body' => 'This is a test body' - ]); - }, - 'http_handler' => function () use ($provider, &$responded) { - if ($responded) { + return new Result([ + 'Body' => 'This is a test body' + ]); + }, + 'http_handler' => function () use ($provider, &$responded) { + if ($responded) { + return new FulfilledPromise(new Response( + 200, + [], + json_encode( + $this->getValidV2GcmMetadataFields($provider) + ) + )); + } + + $responded = true; return new FulfilledPromise(new Response( 200, [], - json_encode( - $this->getValidV2GcmMetadataFields($provider) - ) + 'test' )); - } - - $responded = true; - return new FulfilledPromise(new Response( - 200, - [], - 'test' - )); - }, - ]); - $encryptionClient = @new S3EncryptionClientV2( - $s3Client, - InstructionFileMetadataStrategy::DEFAULT_FILE_SUFFIX - ); - $result = $encryptionClient->getObject([ - 'Bucket' => 'foo', - 'Key' => 'foo', - '@MaterialsProvider' => $provider, - '@SecurityProfile' => 'V2', - '@CommitmentPolicy' => 'FORBID_ENCRYPT_ALLOW_DECRYPT' - ]); - $this->assertInstanceOf(AesGcmDecryptingStream::class, $result['Body']); + }, + ]); + $encryptionClient = @new S3EncryptionClientV2( + $s3Client, + InstructionFileMetadataStrategy::DEFAULT_FILE_SUFFIX + ); + $result = $encryptionClient->getObject([ + 'Bucket' => 'foo', + 'Key' => 'foo', + '@MaterialsProvider' => $provider, + '@SecurityProfile' => 'V2', + '@CommitmentPolicy' => 'FORBID_ENCRYPT_ALLOW_DECRYPT' + ]); + $this->assertInstanceOf(AesGcmDecryptingStream::class, $result['Body']); + } finally { + restore_error_handler(); + } } /** From dac8a364be26c1a04dd197b212cbf7709d778c9a Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 12:09:36 -0800 Subject: [PATCH 14/19] fix: format issues v2 --- tests/Api/Serializer/RestJsonSerializerTest.php | 5 ++--- tests/S3/TransferTest.php | 2 +- tests/S3/UseArnRegion/ConfigurationProviderTest.php | 7 +++---- tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php | 7 +++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/Api/Serializer/RestJsonSerializerTest.php b/tests/Api/Serializer/RestJsonSerializerTest.php index 092676cbc9..1906f1822d 100644 --- a/tests/Api/Serializer/RestJsonSerializerTest.php +++ b/tests/Api/Serializer/RestJsonSerializerTest.php @@ -254,14 +254,13 @@ public function testPreparesRequestsWithEndpointWithRequestUriAndPath(): void public function testPreparesRequestsWithJsonValueTraitString(): void { - $jsonValueArgs = '{"a":"b" - - $this->assertTrue(true);}'; + $jsonValueArgs = '{"a":"b"}'; $request = $this->getRequest('foobar', ['baz' => $jsonValueArgs]); $this->assertSame('IntcImFcIjpcImJcIn0i', $request->getHeaderLine('baz')); $this->assertSame('POST', $request->getMethod()); $this->assertSame('http://foo.com/', (string) $request->getUri()); $this->assertSame('', $request->getHeaderLine('Content-Type')); + $this->assertTrue(true); } public function testPreparesRequestsWithJsonValueTraitArray(): void diff --git a/tests/S3/TransferTest.php b/tests/S3/TransferTest.php index 9262b75038..95d9754058 100644 --- a/tests/S3/TransferTest.php +++ b/tests/S3/TransferTest.php @@ -518,7 +518,7 @@ public function testAddContentMd5EmitsDeprecationWarning() $this->addMockResults($s3, []); set_error_handler(function ($err, $message) { throw new \RuntimeException($message); - }); + }, E_USER_DEPRECATED); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('S3 no longer supports MD5 checksums.'); $s3->getHandlerList()->appendSign(Middleware::tap( diff --git a/tests/S3/UseArnRegion/ConfigurationProviderTest.php b/tests/S3/UseArnRegion/ConfigurationProviderTest.php index 12f383a01f..241b02b65b 100644 --- a/tests/S3/UseArnRegion/ConfigurationProviderTest.php +++ b/tests/S3/UseArnRegion/ConfigurationProviderTest.php @@ -215,16 +215,15 @@ public function testEnsuresFileIsNotEmpty() public function testEnsuresIniFileIsValid() { $this->expectExceptionMessage("Invalid config file:"); - $this->expectException(\Aws\S3\UseArnRegion\Exception\ConfigurationException::class); + $this->expectException(ConfigurationException::class); $dir = $this->clearEnv(); file_put_contents($dir . '/config', "wef \n=\nwef"); putenv('HOME=' . dirname($dir)); try { - @call_user_func(ConfigurationProvider::ini())->wait(); - } catch (\Exception $e) { + call_user_func(ConfigurationProvider::ini())->wait(); + } finally { unlink($dir . '/config'); - throw $e; } } diff --git a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php index bf1c566da7..70c59afa03 100644 --- a/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php +++ b/tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php @@ -216,16 +216,15 @@ public function testEnsuresFileIsNotEmpty() public function testEnsuresIniFileIsValid() { $this->expectExceptionMessage("Invalid config file:"); - $this->expectException(\Aws\Sts\RegionalEndpoints\Exception\ConfigurationException::class); + $this->expectException(ConfigurationException::class); $dir = $this->clearEnv(); file_put_contents($dir . '/config', "wef \n=\nwef"); putenv('HOME=' . dirname($dir)); try { - @call_user_func(ConfigurationProvider::ini())->wait(); - } catch (\Exception $e) { + call_user_func(ConfigurationProvider::ini())->wait(); + } finally { unlink($dir . '/config'); - throw $e; } } From e1fb2020e58b92557a93cf4b4fd00a247f66b99f Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 12:40:51 -0800 Subject: [PATCH 15/19] fix: format issues v3 --- tests/Crypto/AesEncryptingStreamTest.php | 7 +++- tests/Crypto/AesEncryptionStreamTestTrait.php | 36 ++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/tests/Crypto/AesEncryptingStreamTest.php b/tests/Crypto/AesEncryptingStreamTest.php index 2f2a0514ab..d9b8c3754d 100644 --- a/tests/Crypto/AesEncryptingStreamTest.php +++ b/tests/Crypto/AesEncryptingStreamTest.php @@ -149,8 +149,13 @@ public function testDoesNotSupportSeekingFromEnd(CipherMethod $cipherMethod) #[DataProvider('seekableCipherMethodProvider')] public function testSupportsSeekingFromCurrentPosition( - CipherMethod $cipherMethod + ?CipherMethod $cipherMethod, + bool $skipTest ) { + if ($skipTest) { + $this->markTestSkipped(); + } + $stream = new AesEncryptingStream( Psr7\Utils::streamFor(openssl_random_pseudo_bytes(2 * self::MB)), 'foo', diff --git a/tests/Crypto/AesEncryptionStreamTestTrait.php b/tests/Crypto/AesEncryptionStreamTestTrait.php index 300a457b2c..09ff684fbf 100644 --- a/tests/Crypto/AesEncryptionStreamTestTrait.php +++ b/tests/Crypto/AesEncryptionStreamTestTrait.php @@ -7,11 +7,11 @@ trait AesEncryptionStreamTestTrait { - public function cartesianJoinInputCipherMethodProvider() + public function cartesianJoinInputCipherMethodProvider(): array { $toReturn = []; - $plainTexts = $this->unwrapProvider([$this, 'plainTextProvider']); - $ivs = $this->unwrapProvider([$this, 'cipherMethodProvider']); + $plainTexts = self::unwrapProvider([__CLASS__, 'plainTextProvider']); + $ivs = self::unwrapProvider([__CLASS__, 'cipherMethodProvider']); for ($i = 0; $i < count($plainTexts); $i++) { for ($j = 0; $j < count($ivs); $j++) { @@ -22,11 +22,11 @@ public function cartesianJoinInputCipherMethodProvider() return $toReturn; } - public function cartesianJoinInputKeySizeProvider() + public static function cartesianJoinInputKeySizeProvider(): array { $toReturn = []; - $plainTexts = $this->unwrapProvider([$this, 'plainTextProvider']); - $keySizes = $this->unwrapProvider([$this, 'keySizeProvider']); + $plainTexts = self::unwrapProvider([__CLASS__, 'plainTextProvider']); + $keySizes = self::unwrapProvider([__CLASS__, 'keySizeProvider']); for ($i = 0; $i < count($plainTexts); $i++) { for ($j = 0; $j < count($keySizes); $j++) { @@ -40,10 +40,10 @@ public function cartesianJoinInputKeySizeProvider() return $toReturn; } - public function cipherMethodProvider() + public static function cipherMethodProvider(): array { $toReturn = []; - foreach ($this->unwrapProvider([$this, 'keySizeProvider']) as $keySize) { + foreach (self::unwrapProvider([__CLASS__, 'keySizeProvider']) as $keySize) { $toReturn []= [new Cbc( openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc')), $keySize @@ -53,14 +53,24 @@ public function cipherMethodProvider() return $toReturn; } - public function seekableCipherMethodProvider(): array + public static function seekableCipherMethodProvider(): array { - return array_filter($this->cipherMethodProvider(), function (array $args) { + $data = array_filter(self::cipherMethodProvider(), function (array $args) { return !($args[0] instanceof Cbc); }); + + if (empty($data)) { + return [ + 'empty_data' => [null, true] + ]; + } + + return array_map(function ($entry) { + return [$entry[0], false]; + }, $data); } - public function keySizeProvider() + public static function keySizeProvider(): array { return [ [128], @@ -69,7 +79,7 @@ public function keySizeProvider() ]; } - public function plainTextProvider() + public static function plainTextProvider(): array { return [ [Psr7\Utils::streamFor('The rain in Spain falls mainly on the plain.')], @@ -79,7 +89,7 @@ public function plainTextProvider() ]; } - private function unwrapProvider(callable $provider) + private static function unwrapProvider(callable $provider): array { return array_map(function (array $wrapped) { return $wrapped[0]; From 6a3c601fb01458c079ec6f696b568618322ec352 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 13:00:26 -0800 Subject: [PATCH 16/19] fix: format issues v4 --- tests/Script/ComposerTest.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/Script/ComposerTest.php b/tests/Script/ComposerTest.php index 2ac0dacf9c..8fcc464378 100644 --- a/tests/Script/ComposerTest.php +++ b/tests/Script/ComposerTest.php @@ -116,17 +116,18 @@ public function testRetriesOnException($success, $writeCalls) 'Removal failed after several attempts. Last error: Simulated Exception' ); } - $exception = new IOException('Simulated Exception'); $filesystem = $this->getMockBuilder(Filesystem::class) ->disableOriginalConstructor() ->getMock(); $filesystem->expects($this->any()) ->method('remove') - ->will($this->onConsecutiveCalls( - $this->throwException($exception), - $this->throwException($exception), - $success ? $this->returnValue(true) : $this->throwException($exception) - )); + ->willReturnCallback(function () use ($success) { + if ($success) { + return true; + } + + throw new IOException('Simulated Exception'); + }); $filesystem->expects($this->any()) ->method('exists') ->willReturn(true); @@ -161,7 +162,7 @@ public function testRetriesOnException($success, $writeCalls) public static function retryProvider(): array { return [ - 'success' => [true , 3], + 'success' => [true , 1], 'failure' => [false, 2] ]; } From a0812f28dffc523819a8f06fff805187782262a9 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 13:07:43 -0800 Subject: [PATCH 17/19] chore: remove XDEBUG_MODE --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index af570a96ef..325be04923 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,6 @@ test: AWS_REGION= \ AWS_ENDPOINT_URL= \ AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \ - XDEBUG_MODE=coverage \ vendor/bin/phpunit --testsuite=unit $(TEST) test-phar: package From d83228e1f2c147c3b25db2819024c025c0f3c9e1 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 13:13:54 -0800 Subject: [PATCH 18/19] chore: skip tests coverage report --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 325be04923..5782039b43 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ test: AWS_REGION= \ AWS_ENDPOINT_URL= \ AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \ - vendor/bin/phpunit --testsuite=unit $(TEST) + vendor/bin/phpunit --no-coverage --testsuite=unit $(TEST) test-phar: package [ -f build/artifacts/behat.phar ] || (cd build/artifacts && \ From 9c0eb84a075b3796ef40762ca5512bd17d9f1c28 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Fri, 30 Jan 2026 13:19:19 -0800 Subject: [PATCH 19/19] fix: remove call to removed method --- src/ClientResolver.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/ClientResolver.php b/src/ClientResolver.php index ce8eb2bc23..4e41bd6389 100644 --- a/src/ClientResolver.php +++ b/src/ClientResolver.php @@ -1247,12 +1247,6 @@ public static function _apply_suppress_php_deprecation_warning($value, &$args) $args['suppress_php_deprecation_warning'] = \Aws\boolean_value($_ENV["AWS_SUPPRESS_PHP_DEPRECATION_WARNING"]); } - - if ($args['suppress_php_deprecation_warning'] === false - && PHP_VERSION_ID < 80100 - ) { - self::emitDeprecationWarning(); - } } public static function _default_endpoint(array &$args)