Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +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 \
vendor/bin/phpunit --testsuite=unit $(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 \
vendor/bin/phpunit --no-coverage --testsuite=unit $(TEST)

test-phar: package
[ -f build/artifacts/behat.phar ] || (cd build/artifacts && \
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
21 changes: 9 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./tests/bootstrap.php"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
convertDeprecationsToExceptions="true"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/data</directory>
</exclude>
<report>
<clover outputFile="clover.xml"/>
</report>
Expand All @@ -26,4 +15,12 @@
</testsuite>
</testsuites>
<logging/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/data</directory>
</exclude>
</source>
</phpunit>
23 changes: 0 additions & 23 deletions src/AwsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions src/ClientResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1440,21 +1434,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
);
}
}
16 changes: 9 additions & 7 deletions tests/AbstractConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

namespace Aws\Test;

use Aws\AbstractConfigurationProvider;
use Aws\LruArrayCache;
use Aws\Result;
use Aws\ResultInterface;
use GuzzleHttp\Promise;
use PHPUnit\Framework\MockObject\MockObject;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @covers \Aws\AbstractConfigurationProvider
*/
#[CoversClass(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()
Expand Down
9 changes: 5 additions & 4 deletions tests/Api/ApiProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
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
{
/**
Expand All @@ -25,7 +24,9 @@ private function getTestApiProvider($useManifest = true)

public function testCanResolveProvider()
{
$p = function ($a, $b, $c) {return [];};
$p = function ($a, $b, $c) {
return [];
};
$result = ['metadata'=> ['serviceIdentifier' => 's']];
$this->assertEquals($result, ApiProvider::resolve($p, 't', 's', 'v'));

Expand Down
14 changes: 5 additions & 9 deletions tests/Api/DateTimeResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use Aws\Api\DateTimeResult;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @covers \Aws\Api\DateTimeResult
*/
#[CoversClass(DateTimeResult::class)]
class DateTimeResultTest extends TestCase
{
public function testCreatesFromEpoch()
Expand Down Expand Up @@ -50,18 +50,14 @@ public function testJsonSerialzesAsIso8601()
$this->assertSame('"' . gmdate('c', $t). '"', json_encode($d));
}

/**
* @return void
*
* @dataProvider nanosecondPrecisionProvider
*/
#[DataProvider('nanosecondPrecisionProvider')]
public function testIso8601NanosecondPrecision($timestamp, $expected)
{
$parsed = DateTimeResult::fromISO8601($timestamp);
$this->assertEquals($expected, (string) $parsed);
}

public function nanosecondPrecisionProvider()
public static function nanosecondPrecisionProvider(): array
{
return [
['2024-07-31T19:05:47.1234567Z', '2024-07-31T19:05:47+00:00'],
Expand Down
77 changes: 39 additions & 38 deletions tests/Api/ErrorParser/JsonRpcErrorParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,46 @@
namespace Aws\Test\Api\ErrorParser;

use Aws\Api\ErrorParser\JsonRpcErrorParser;
use Aws\Api\ErrorParser\RestJsonErrorParser;
use Aws\Api\StructureShape;
use Aws\Api\ErrorParser\JsonParserTrait;
use Aws\Test\TestServiceTrait;
use GuzzleHttp\Promise\Promise;
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(JsonRpcErrorParser::class)]
#[CoversClass(JsonParserTrait::class)]
class JsonRpcErrorParserTest extends TestCase
{
use TestServiceTrait;

/**
* @dataProvider errorResponsesProvider
*
* @param $response
* @param $command
* @param $parser
* @param $expected
*/
#[DataProvider('errorResponsesProvider')]
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(
Expand All @@ -49,26 +60,16 @@ public function testParsesClientErrorResponses(
}
}

public 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
[
"HTTP/1.1 400 Bad Request\r\n" .
"x-amzn-requestid: xyz\r\n\r\n" .
'{ "__Type": "foo", "Message": "lorem ipsum" }',
null,
new JsonRpcErrorParser(),
false,
[
'code' => 'foo',
'message' => 'lorem ipsum',
Expand All @@ -89,8 +90,8 @@ public 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',
Expand All @@ -113,7 +114,7 @@ public function errorResponsesProvider()
'TestStatus' => 400,
],
'message' => 'Test Message',
'error_shape' => $errorShape
'error_shape' => true
]
],
// Unmodeled shape, with service
Expand All @@ -125,7 +126,7 @@ public 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',
Expand All @@ -148,7 +149,7 @@ public 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',
Expand All @@ -168,7 +169,7 @@ public 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',
Expand All @@ -188,7 +189,7 @@ public function errorResponsesProvider()
"x-amzn-query-error: \r\n\r\n" .
'{ "__Type": "foo", "Message": "lorem ipsum" }',
null,
new JsonRpcErrorParser(),
false,
[
'code' => 'foo',
'message' => 'lorem ipsum',
Expand Down
Loading