Conversation
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.
Enhance data providers within test cases to avoid the usage of instance members since they become now static functions.
- 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.
- Remove constructor override for TestCase extension. - Remove CoverClass from methods.
ef2a511 to
ac41a42
Compare
stobrien89
left a comment
There was a problem hiding this comment.
Looks good for the most part, mostly minor things that are easy to miss in such a large PR
| )->wait(); | ||
| $this->assertSame('foo', $c->getAccessKeyId()); | ||
| $this->assertSame('baz', $c->getSecretKey()); | ||
| $this->assertNull($c->getSecurityToken()); | ||
| $this->assertSame($t, $c->getExpiration()); | ||
| } | ||
|
|
||
| /** @doesNotPerformAssertions */ | ||
| #[CoversNothing] |
There was a problem hiding this comment.
We should use #[DoesNotPerformAssertions] for these cases and remove the assertTrue(true)
| @@ -260,6 +260,7 @@ public function testPreparesRequestsWithJsonValueTraitString(): void | |||
| $this->assertSame('POST', $request->getMethod()); | |||
| $this->assertSame('http://foo.com/', (string) $request->getUri()); | |||
| $this->assertSame('', $request->getHeaderLine('Content-Type')); | |||
| $this->assertTrue(true); | |||
There was a problem hiding this comment.
This line should be removed. I would audit anywhere we've added this- chances are, they will need to be removed
| @@ -182,6 +188,7 @@ public function testPassesComplianceTest( | |||
| $this->assertNotTrue($request->hasHeader($header)); | |||
| } | |||
| } | |||
| $this->assertTrue(true); | |||
|
|
||
| /** | ||
| * @covers Aws\Api\Shape | ||
| * @covers Aws\Api\AbstractModel |
There was a problem hiding this comment.
need to add this coverage back
| */ | ||
|
|
||
| */ | ||
| #[DataProvider('returnsExpiredCredsProvider')] | ||
| public function testExtendsExpirationAndSendsRequestIfImdsYieldsExpiredCreds($client) |
There was a problem hiding this comment.
Pretty sure the behavior change here short-circuits this test
| }, array_keys($s3Operations)); | ||
|
|
||
| foreach ($commands as $command) { | ||
| $command = new Command('CreateBucket', ['Bucket' => 'bucket']); |
There was a problem hiding this comment.
This overwrites $command and uses CreateBucket every time
|
|
||
| /** | ||
| * @covers Aws\S3\S3Client | ||
| * @covers Aws\S3\S3ClientTrait |
| @@ -40,6 +41,7 @@ public function tear_down() | |||
| { | |||
| stream_wrapper_unregister('s3'); | |||
| $this->client = null; | |||
| restore_exception_handler(); // In case it was not restored | |||
There was a problem hiding this comment.
Should probably be restore_error_handler()
| /** | ||
| * @dataProvider retryProvider | ||
| */ | ||
| #[DataProvider('retryProvider')] | ||
| public function testRetriesOnException($success, $writeCalls) |
There was a problem hiding this comment.
The success test case changed writeCalls from 3 to 1- the retry-then-succeed path is no longer tested. The original test verified the retry mechanism actually works (fail twice, succeed third time).
|
|
||
| $this->expectDeprecation(); | ||
| $this->expectDeprecationMessage('S3 no longer supports MD5 checksums.'); | ||
| set_error_handler(function ($err, $message) { |
There was a problem hiding this comment.
no restoration of error handler
| AWS_ENDPOINT_URL= \ | ||
| AWS_SUPPRESS_PHP_DEPRECATION_WARNING=true \ | ||
| vendor/bin/phpunit --testsuite=unit $(TEST) | ||
| vendor/bin/phpunit --no-coverage --testsuite=unit $(TEST) |
There was a problem hiding this comment.
What's the rationale for skipping coverage here?
There was a problem hiding this comment.
I meant to use this locally to get faster results when testing. Will revert it.
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.