Skip to content

Commit

Permalink
Revert "PHP 8.0, 8.1, PHPUnit 9 support + automated check for php com…
Browse files Browse the repository at this point in the history
…patibility (#2403)"

This reverts commit af584e7.
  • Loading branch information
stobrien89 authored Sep 12, 2022
1 parent af584e7 commit e9a6e5a
Show file tree
Hide file tree
Showing 161 changed files with 1,795 additions and 1,392 deletions.
7 changes: 0 additions & 7 deletions .changes/nextrelease/php8

This file was deleted.

26 changes: 11 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
#for each of the following versions of PHP, with and without --prefer-lowest
matrix:
php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
composer-options: ['', '--prefer-lowest']
#set the name for each job
name: PHP ${{ matrix.php-versions }} ${{ matrix.composer-options }}
Expand All @@ -42,32 +42,28 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

#remove incompatible xdebug file if it exists
#downgrade to supported php unit and remove incompatible xdebug file if it exists
- if: ${{ matrix.php-versions == '5.5' }}
name: PHP 5.5
name: PHP 5.5 specific setup
run: |
sudo rm -f /etc/php5/cli/conf.d/20-xdebug.ini
composer require --dev --ignore-platform-reqs phpunit/phpunit "4.8.36"
#downgrade to supported php unit
- if: ${{ matrix.php-versions <= '7.1' && matrix.php-versions > 5.5}}
name: PHP 5.6-7.1 specific setup
run: composer require --dev --ignore-platform-reqs phpunit/phpunit "^5.7.11"

#get dependencies
- name: Install dependencies
run: composer update ${{ matrix.composer-options }} --no-interaction --prefer-source

#php 8.x requirements
- if: ${{ matrix.php-versions >= '8.0' && matrix.composer-options != '' }}
name: PHP 8.x
run: composer require --dev phpunit/phpunit "^9.5" --no-interaction --prefer-source --with-all-dependencies

#php 8.1 requirements
- if: ${{ matrix.php-versions >= '8.1' && matrix.composer-options != '' }}
name: PHP 8.1
run: composer require --dev guzzlehttp/guzzle "^7.3" --no-interaction --prefer-source --with-all-dependencies

#run tests
- name: Run test suite
run: make test

#static analysis
- if: ${{ matrix.php-versions >= '7.1' && matrix.php-versions < '8.0' && matrix.composer-options == '' }}
- if: ${{ matrix.php-versions >= '7.1' && matrix.php-versions <= 7.4 && matrix.composer-options == '' }}
name: Static analysis
run: |
composer require --dev nette/neon "^3.0"
Expand All @@ -83,6 +79,6 @@ jobs:
make package
#generate code coverage
- if: ${{ (matrix.php-versions == '7.1' || matrix.php-versions == '8.0') && matrix.composer-options == '' }}
- if: ${{ matrix.php-versions == '7.1' && matrix.composer-options == '' }}
name: Code coverage
run: bash <(curl -s https://codecov.io/bash)
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test_services.json
/Makefile
.idea
.php_cs.cache
.phpunit.result.cache
atlassian-ide-plugin.xml
aws-sdk-php.iml
.DS_Store
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"ext-dom": "*",
"ext-pcntl": "*",
"ext-sockets": "*",
"phpunit/phpunit": "^4.8.35 || ^5.6.3 || ^9.5",
"phpunit/phpunit": "^4.8.35 || ^5.6.3",
"behat/behat": "~3.0",
"doctrine/cache": "~1.4",
"aws/aws-php-sns-message-validator": "~1.0",
Expand All @@ -41,9 +41,7 @@
"psr/cache": "^1.0",
"psr/simple-cache": "^1.0",
"paragonie/random_compat": ">= 2",
"sebastian/comparator": "^1.2.3 || ^4.0",
"yoast/phpunit-polyfills": "^1.0",
"dms/phpunit-arraysubset-asserts": "^0.4.0"
"sebastian/comparator": "^1.2.3"
},
"suggest": {
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
Expand Down
53 changes: 31 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
<?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">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/data</directory>
</exclude>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/</directory>
<exclude>tests/Integ</exclude>
</testsuite>
<testsuite name="integ">
<directory suffix="Test.php">tests/Integ</directory>
</testsuite>
</testsuites>
<logging/>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true">

<php>
<!-- Specify the path to your CloudFront private key -->
<server name="CF_PRIVATE_KEY" value="changeme" />
<!-- Specify the CloudFront key pair ID to use when testing -->
<server name="CF_KEY_PAIR_ID" value="change_me" />
</php>

<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/</directory>
<exclude>tests/Integ</exclude>
</testsuite>
<testsuite name="integ">
<directory suffix="Test.php">tests/Integ</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory>src/data</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="clover.xml"/>
</logging>
</phpunit>
2 changes: 1 addition & 1 deletion src/Api/Parser/AbstractRestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private function extractHeaders(
// Check if the headers are prefixed by a location name
$result[$name] = [];
$prefix = $shape['locationName'];
$prefixLen = $prefix !== null ? strlen($prefix) : 0;
$prefixLen = strlen($prefix);

foreach ($response->getHeaders() as $k => $values) {
if (!$prefixLen) {
Expand Down
13 changes: 2 additions & 11 deletions src/Api/Serializer/JsonBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,8 @@ public function __construct(Service $api)
*/
public static function getContentType(Service $service)
{
if ($service->getMetadata('protocol') === 'rest-json') {
return 'application/json';
}

$jsonVersion = $service->getMetadata('jsonVersion');
if (empty($jsonVersion)) {
throw new \InvalidArgumentException('invalid json');
} else {
return 'application/x-amz-json-'
. @number_format($service->getMetadata('jsonVersion'), 1);
}
return 'application/x-amz-json-'
. number_format($service->getMetadata('jsonVersion'), 1);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Serializer/RestJsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
JsonBody $jsonFormatter = null
) {
parent::__construct($api, $endpoint);
$this->contentType = JsonBody::getContentType($api);
$this->contentType = 'application/json';
$this->jsonFormatter = $jsonFormatter ?: new JsonBody($api);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Arn/ArnParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ArnParser
*/
public static function isArn($string)
{
return $string !== null && strpos($string, 'arn:') === 0;
return strpos($string, 'arn:') === 0;
}

/**
Expand Down
12 changes: 4 additions & 8 deletions src/CloudFront/Signer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@ public function __construct($keyPairId, $privateKey, $passphrase = "")
if (!$this->pkHandle = openssl_pkey_get_private($privateKey, $passphrase)) {
if (!file_exists($privateKey)) {
throw new \InvalidArgumentException("PK file not found: $privateKey");
}

$this->pkHandle = openssl_pkey_get_private("file://$privateKey", $passphrase);
if (!$this->pkHandle) {
$errorMessages = [];
while(($newMessage = openssl_error_string()) !== false){
$errorMessages[] = $newMessage;
} else {
$this->pkHandle = openssl_pkey_get_private("file://$privateKey", $passphrase);
if (!$this->pkHandle) {
throw new \InvalidArgumentException(openssl_error_string());
}
throw new \InvalidArgumentException(implode("\n",$errorMessages));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/MockHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
$this->onRejected = $onRejected;

if ($resultOrQueue) {
call_user_func_array([$this, 'append'], array_values($resultOrQueue));
call_user_func_array([$this, 'append'], $resultOrQueue);
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/S3/S3Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,6 @@ public function __construct(array $args)
*/
public static function isBucketDnsCompatible($bucket)
{
if (!is_string($bucket)) {
return false;
}
$bucketLen = strlen($bucket);

return ($bucketLen >= 3 && $bucketLen <= 63) &&
Expand Down
6 changes: 4 additions & 2 deletions tests/AbstractConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Aws\Result;
use Aws\ResultInterface;
use GuzzleHttp\Promise;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use PHPUnit\Framework\TestCase;

/**
* @covers \Aws\AbstractConfigurationProvider
Expand Down Expand Up @@ -65,9 +65,11 @@ public function testChainsConfiguration()
$this->assertSame($expected, $result);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testChainThrowsExceptionOnEmptyArgs()
{
$this->expectException(\InvalidArgumentException::class);
call_user_func([$this->provider, 'chain']);
}

Expand Down
18 changes: 10 additions & 8 deletions tests/Api/ApiProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Aws\Api\ApiProvider;
use Aws\Exception\UnresolvedApiException;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use PHPUnit\Framework\TestCase;

/**
* @covers Aws\Api\ApiProvider
Expand All @@ -30,7 +30,7 @@ public function testCanResolveProvider()
$this->assertEquals($result, ApiProvider::resolve($p, 't', 's', 'v'));

$p = function ($a, $b, $c) {return null;};
$this->expectException(UnresolvedApiException::class);
$this->setExpectedException(UnresolvedApiException::class);
ApiProvider::resolve($p, 't', 's', 'v');
}

Expand All @@ -53,7 +53,7 @@ public function testCanGetServiceVersions()
public function testCanGetDefaultProvider()
{
$p = ApiProvider::defaultProvider();
$this->assertArrayHasKey('s3', $this->getPropertyValue($p, 'manifest'));
$this->assertArrayHasKey('s3', $this->readAttribute($p, 'manifest'));
}

public function testManifestProviderReturnsNullForMissingService()
Expand All @@ -66,13 +66,15 @@ public function testManifestProviderCanLoadData()
{
$p = $this->getTestApiProvider();
$data = $p('api', 'dynamodb', 'latest');
$this->assertIsArray($data);
$this->assertInternalType('array', $data);
$this->assertArrayHasKey('foo', $data);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testFilesystemProviderEnsuresDirectoryIsValid()
{
$this->expectException(\InvalidArgumentException::class);
ApiProvider::filesystem('/path/to/invalid/dir');
}

Expand Down Expand Up @@ -114,21 +116,21 @@ public function testReturnsWaiterConfigsForLatestCompatibleVersion()

public function testThrowsOnBadType()
{
$this->expectException(UnresolvedApiException::class);
$this->setExpectedException(UnresolvedApiException::class);
$p = $this->getTestApiProvider();
ApiProvider::resolve($p, 'foo', 's3', 'latest');
}

public function testThrowsOnBadService()
{
$this->expectException(UnresolvedApiException::class);
$this->setExpectedException(UnresolvedApiException::class);
$p = $this->getTestApiProvider();
ApiProvider::resolve($p, 'api', '', 'latest');
}

public function testThrowsOnBadVersion()
{
$this->expectException(UnresolvedApiException::class);
$this->setExpectedException(UnresolvedApiException::class);
$p = $this->getTestApiProvider();
ApiProvider::resolve($p, 'api', 'dynamodb', 'derp');
}
Expand Down
4 changes: 1 addition & 3 deletions tests/Api/ErrorParser/XmlErrorParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@

use Aws\Api\ErrorParser\XmlErrorParser;
use Aws\Test\TestServiceTrait;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use GuzzleHttp\Psr7;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use PHPUnit\Framework\TestCase;

/**
* @covers Aws\Api\ErrorParser\XmlErrorParser
*/
class XmlErrorParserTest extends TestCase
{
use ArraySubsetAsserts;
use TestServiceTrait;

/**
Expand Down
6 changes: 4 additions & 2 deletions tests/Api/ListShapeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Aws\Api\ShapeMap;
use Aws\Api\ListShape;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use PHPUnit\Framework\TestCase;

/**
* @covers \Aws\Api\ListShape
Expand All @@ -23,9 +23,11 @@ public function testReturnsMember()
$this->assertSame('string', $m->getType());
}

/**
* @expectedException \RuntimeException
*/
public function testFailsWhenMemberIsMissing()
{
$this->expectException(\RuntimeException::class);
(new ListShape([], new ShapeMap([])))->getMember();
}
}
6 changes: 4 additions & 2 deletions tests/Api/MapShapeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Aws\Api\ShapeMap;
use Aws\Api\MapShape;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
use PHPUnit\Framework\TestCase;

/**
* @covers \Aws\Api\MapShape
Expand All @@ -19,9 +19,11 @@ public function testReturnsValue()
$this->assertSame($v, $s->getValue());
}

/**
* @expectedException \RuntimeException
*/
public function testFailsWhenValueIsMissing()
{
$this->expectException(\RuntimeException::class);
(new MapShape([], new ShapeMap([])))->getValue();
}

Expand Down
Loading

0 comments on commit e9a6e5a

Please sign in to comment.