Skip to content
Closed
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
30 changes: 17 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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']
php-versions: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
composer-options: ['', '--prefer-lowest']
#set the name for each job
name: PHP ${{ matrix.php-versions }} ${{ matrix.composer-options }}
Expand All @@ -39,28 +39,32 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

#downgrade to supported php unit and remove incompatible xdebug file if it exists
#remove incompatible xdebug file if it exists
- if: ${{ matrix.php-versions == '5.5' }}
name: PHP 5.5 specific setup
name: PHP 5.5
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

#run tests
#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 <= 7.4 && matrix.composer-options == '' }}
#static analysis
- if: ${{ matrix.php-versions >= '7.1' && matrix.php-versions < '8.0' && matrix.composer-options == '' }}
name: Static analysis
run: |
composer require --dev nette/neon "^3.0"
Expand All @@ -73,6 +77,6 @@ jobs:
run: make package

#generate code coverage
- if: ${{ matrix.php-versions == '7.1' && matrix.composer-options == '' }}
- if: ${{ (matrix.php-versions == '7.1' || matrix.php-versions == '8.0') && matrix.composer-options == '' }}
name: Code coverage
run: bash <(curl -s https://codecov.io/bash)
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_services.json
/Makefile
.idea
.php_cs.cache
.phpunit.result.cache
atlassian-ide-plugin.xml
aws-sdk-php.iml
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ext-dom": "*",
"ext-pcntl": "*",
"ext-sockets": "*",
"phpunit/phpunit": "^4.8.35|^5.4.3",
"phpunit/phpunit": "^4.8.35|^5.4.3|^9.5",
"behat/behat": "~3.0",
"doctrine/cache": "~1.4",
"aws/aws-php-sns-message-validator": "~1.0",
Expand All @@ -40,7 +40,7 @@
"psr/cache": "^1.0",
"psr/simple-cache": "^1.0",
"paragonie/random_compat": ">= 2",
"sebastian/comparator": "^1.2.3"
"sebastian/comparator": "^1.2.3|^4.0"
},
"suggest": {
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
Expand Down
53 changes: 22 additions & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true">

<php>
<!-- Specify the path to your CloudFront private key -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed in favour of a change to the suite that enables this to run without any configuration

<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 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>
6 changes: 5 additions & 1 deletion src/Api/DateTimeResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class DateTimeResult extends \DateTime implements \JsonSerializable
*/
public static function fromEpoch($unixTimestamp)
{
return new self(gmdate('c', $unixTimestamp));
if (!is_numeric($unixTimestamp)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same change as in #2331

throw new ParserException('Invalid timestamp value passed to DateTimeResult::fromEpoch');
}

return new self(gmdate('c', (int) $unixTimestamp));
}

/**
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'], $resultOrQueue);
call_user_func_array([$this, 'append'], array_values($resultOrQueue));
}
}

Expand Down
7 changes: 4 additions & 3 deletions tests/AbstractConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Aws\LruArrayCache;
use Aws\Result;
use Aws\ResultInterface;
use Aws\Test\Polyfill\PHPUnit\PHPUnitCompatTrait;
use GuzzleHttp\Promise;
use PHPUnit\Framework\TestCase;

Expand All @@ -13,6 +14,8 @@
*/
class AbstractConfigurationProviderTest extends TestCase
{
use PHPUnitCompatTrait;

/** @var \PHPUnit_Framework_MockObject_MockObject */
private $provider;

Expand Down Expand Up @@ -65,11 +68,9 @@ public function testChainsConfiguration()
$this->assertSame($expected, $result);
}

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

Expand Down
17 changes: 9 additions & 8 deletions tests/Api/ApiProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

use Aws\Api\ApiProvider;
use Aws\Exception\UnresolvedApiException;
use Aws\Test\Polyfill\PHPUnit\PHPUnitCompatTrait;
use PHPUnit\Framework\TestCase;

/**
* @covers Aws\Api\ApiProvider
*/
class ApiProviderTest extends TestCase
{
use PHPUnitCompatTrait;

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

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

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

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

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

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

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

public function testThrowsOnBadVersion()
{
$this->setExpectedException(UnresolvedApiException::class);
$this->expectException(UnresolvedApiException::class);
$p = $this->getTestApiProvider();
ApiProvider::resolve($p, 'api', 'dynamodb', 'derp');
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Api/ErrorParser/XmlErrorParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Aws\Test\Api\ErrorParser;

use Aws\Api\ErrorParser\XmlErrorParser;
use Aws\Test\Polyfill\PHPUnit\PHPUnitCompatTrait;
use Aws\Test\TestServiceTrait;
use GuzzleHttp\Psr7;
use PHPUnit\Framework\TestCase;
Expand All @@ -11,6 +12,7 @@
*/
class XmlErrorParserTest extends TestCase
{
use PHPUnitCompatTrait;
use TestServiceTrait;

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

use Aws\Api\ShapeMap;
use Aws\Api\ListShape;
use Aws\Test\Polyfill\PHPUnit\PHPUnitCompatTrait;
use PHPUnit\Framework\TestCase;

/**
* @covers \Aws\Api\ListShape
*/
class ListShapeTest extends TestCase
{
use PHPUnitCompatTrait;

public function testReturnsMember()
{
$s = new ListShape(
Expand All @@ -23,11 +26,9 @@ public function testReturnsMember()
$this->assertSame('string', $m->getType());
}

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

use Aws\Api\ShapeMap;
use Aws\Api\MapShape;
use Aws\Test\Polyfill\PHPUnit\PHPUnitCompatTrait;
use PHPUnit\Framework\TestCase;

/**
* @covers \Aws\Api\MapShape
*/
class MapShapeTest extends TestCase
{
use PHPUnitCompatTrait;

public function testReturnsValue()
{
$s = new MapShape(['value' => ['type' => 'string']], new ShapeMap([]));
Expand All @@ -19,11 +22,9 @@ public function testReturnsValue()
$this->assertSame($v, $s->getValue());
}

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

Expand Down
7 changes: 5 additions & 2 deletions tests/Api/OperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

use Aws\Api\ShapeMap;
use Aws\Api\Operation;
use Aws\Test\Polyfill\PHPUnit\PHPUnitCompatTrait;
use PHPUnit\Framework\TestCase;

/**
* @covers \Aws\Api\Operation
*/
class OperationTest extends TestCase
{
use PHPUnitCompatTrait;

public function testCreatesDefaultMethodAndUri()
{
$o = new Operation([], new ShapeMap([]));
Expand All @@ -22,7 +25,7 @@ public function testReturnsEmptyShapes()
$o = new Operation([], new ShapeMap([]));
$this->assertInstanceOf('Aws\Api\Shape', $o->getInput());
$this->assertInstanceOf('Aws\Api\Shape', $o->getOutput());
$this->assertInternalType('array', $o->getErrors());
$this->assertIsArray($o->getErrors());
}

public function testReturnsInputShape()
Expand Down Expand Up @@ -60,7 +63,7 @@ public function testReturnsErrorsShapeArray()
'b' => ['type' => 'list'],
]));
$e = $o->getErrors();
$this->assertInternalType('array', $e);
$this->assertIsArray($e);
$this->assertInstanceOf('Aws\Api\Shape', $e[0]);
$this->assertInstanceOf('Aws\Api\Shape', $e[1]);
$this->assertSame('structure', $e[0]->getType());
Expand Down
1 change: 1 addition & 0 deletions tests/Api/Parser/ComplianceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ComplianceTest extends TestCase
{
use UsesServiceTrait;

/** @doesNotPerformAssertions */
public function testCaseProvider()
{
$cases = [];
Expand Down
Loading