From e91e5c3e05fd183c629f168a03a6fa2392273eed Mon Sep 17 00:00:00 2001 From: Andreas Lange Date: Mon, 13 Jun 2022 10:16:34 +0200 Subject: [PATCH 1/6] PHP 8.x compatibility (#2) --- .editorconfig | 10 ++ .github/workflows/unit.yaml | 39 ++++++++ .gitignore | 2 + AmazonPay/Client.php | 23 +---- AmazonPay/HttpCurl.php | 2 - AmazonPay/IpnHandler.php | 18 +--- AmazonPay/ResponseParser.php | 2 - Psr/Log/AbstractLogger.php | 128 ------------------------ Psr/Log/InvalidArgumentException.php | 7 -- Psr/Log/LogLevel.php | 18 ---- Psr/Log/LoggerAwareInterface.php | 18 ---- Psr/Log/LoggerAwareTrait.php | 26 ----- Psr/Log/LoggerInterface.php | 123 ----------------------- Psr/Log/LoggerTrait.php | 140 --------------------------- Psr/Log/NullLogger.php | 28 ------ Psr/Log/Test/LoggerInterfaceTest.php | 133 ------------------------- README.md | 7 ++ composer.json | 23 ++++- create-amazon-pay-phar.php | 8 -- phpunit.xml | 22 +++++ tst/unit/ClientTest.php | 38 ++++---- tst/unit/IpnHandlerTest.php | 22 ++--- 22 files changed, 133 insertions(+), 704 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/unit.yaml delete mode 100755 Psr/Log/AbstractLogger.php delete mode 100755 Psr/Log/InvalidArgumentException.php delete mode 100755 Psr/Log/LogLevel.php delete mode 100755 Psr/Log/LoggerAwareInterface.php delete mode 100755 Psr/Log/LoggerAwareTrait.php delete mode 100755 Psr/Log/LoggerInterface.php delete mode 100755 Psr/Log/LoggerTrait.php delete mode 100755 Psr/Log/NullLogger.php delete mode 100755 Psr/Log/Test/LoggerInterfaceTest.php delete mode 100644 create-amazon-pay-phar.php create mode 100644 phpunit.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1b3cae9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 120 diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml new file mode 100644 index 0000000..11cc75c --- /dev/null +++ b/.github/workflows/unit.yaml @@ -0,0 +1,39 @@ +name: Testing + +on: [push] + +jobs: + + phpunit: + strategy: + matrix: + php-versions: [ '8.0', '8.1' ] + name: 'PHPUnit [PHP ${{ matrix.php-versions }}]' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: composer:v2 + extensions: 'json curl xml openssl' + env: + update: true + - name: Get Composer Cache Directory + id: composer-cache + run: 'echo "::set-output name=dir::$(composer config cache-files-dir)"' + - name: Cache Composer Dependencies + uses: actions/cache@v2 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + - name: Installing Composer Packages + run: 'composer install --no-scripts --prefer-dist' + - name: Unit Tests + run: composer test:coverage -- --coverage-clover clover.xml + - name: Upload to codecov + uses: codecov/codecov-action@v2 + with: + files: ./clover.xml diff --git a/.gitignore b/.gitignore index b99772f..4336cd2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ vendor composer.lock amazon-pay.phar build + +.idea diff --git a/AmazonPay/Client.php b/AmazonPay/Client.php index 59c1cf1..7e72b5f 100644 --- a/AmazonPay/Client.php +++ b/AmazonPay/Client.php @@ -7,22 +7,13 @@ * returns Response Object */ -require_once 'ResponseParser.php'; -require_once 'HttpCurl.php'; -require_once 'ClientInterface.php'; -require_once 'Regions.php'; -if (!interface_exists('\Psr\Log\LoggerAwareInterface')) { - require_once(__DIR__.'/../Psr/Log/LoggerAwareInterface.php'); -} - -if (!interface_exists('\Psr\Log\LoggerInterface')) { - require_once(__DIR__.'/../Psr/Log/LoggerInterface.php'); -} use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerInterface; +use Psr\Log\LoggerAwareTrait; class Client implements ClientInterface, LoggerAwareInterface { + use LoggerAwareTrait; + const SDK_VERSION = '3.7.1'; const MWS_VERSION = '2013-01-01'; const MAX_ERROR_RETRY = 3; @@ -62,9 +53,6 @@ class Client implements ClientInterface, LoggerAwareInterface private $profileEndpointUrls; private $regionMappings; - // Implement a logging library that utilizes the PSR 3 logger interface - private $logger = null; - // Boolean variable to check if the API call was a success public $success = false; @@ -101,11 +89,6 @@ public function __construct($config = null) } - public function setLogger(LoggerInterface $logger = null) { - $this->logger = $logger; - } - - /* Helper function to log data within the Client */ private function logMessage($message) { if ($this->logger) { diff --git a/AmazonPay/HttpCurl.php b/AmazonPay/HttpCurl.php index 0fb0fdf..545200d 100644 --- a/AmazonPay/HttpCurl.php +++ b/AmazonPay/HttpCurl.php @@ -5,8 +5,6 @@ * Handles Curl POST function for all requests */ -require_once 'HttpCurlInterface.php'; - class HttpCurl implements HttpCurlInterface { private $config = array(); diff --git a/AmazonPay/IpnHandler.php b/AmazonPay/IpnHandler.php index 801bc87..747ea14 100644 --- a/AmazonPay/IpnHandler.php +++ b/AmazonPay/IpnHandler.php @@ -6,19 +6,12 @@ * verifies that the IPN is from the right resource and has the valid data */ -require_once 'HttpCurl.php'; -require_once 'IpnHandlerInterface.php'; -if (!interface_exists('\Psr\Log\LoggerAwareInterface')) { - require_once(__DIR__.'/../Psr/Log/LoggerAwareInterface.php'); -} -if (!interface_exists('\Psr\Log\LoggerInterface')) { - require_once(__DIR__.'/../Psr/Log/LoggerInterface.php'); -} use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerInterface; +use Psr\Log\LoggerAwareTrait; class IpnHandler implements IpnHandlerInterface, LoggerAwareInterface { + use LoggerAwareTrait; private $headers = null; private $body = null; @@ -29,9 +22,6 @@ class IpnHandler implements IpnHandlerInterface, LoggerAwareInterface private $expectedCnName = 'sns.amazonaws.com'; private $defaultHostPattern = '/^sns\.[a-zA-Z0-9\-]{3,}\.amazonaws\.com(\.cn)?$/'; - // Implement a logging library that utilizes the PSR 3 logger interface - private $logger = null; - private $ipnConfig = array('cabundle_file' => null, 'proxy_host' => null, 'proxy_port' => -1, @@ -86,10 +76,6 @@ private function checkConfigKeys($ipnConfig) } } - public function setLogger(LoggerInterface $logger = null) { - $this->logger = $logger; - } - /* Helper function to log data within the Client */ private function logMessage($message) { diff --git a/AmazonPay/ResponseParser.php b/AmazonPay/ResponseParser.php index 8e5978b..9a0c8d2 100644 --- a/AmazonPay/ResponseParser.php +++ b/AmazonPay/ResponseParser.php @@ -5,8 +5,6 @@ * Methods provided to convert the Response from the POST to XML, Array or JSON */ -require_once 'ResponseInterface.php'; - class ResponseParser implements ResponseInterface { public $response = null; diff --git a/Psr/Log/AbstractLogger.php b/Psr/Log/AbstractLogger.php deleted file mode 100755 index 5a68a23..0000000 --- a/Psr/Log/AbstractLogger.php +++ /dev/null @@ -1,128 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } -} diff --git a/Psr/Log/InvalidArgumentException.php b/Psr/Log/InvalidArgumentException.php deleted file mode 100755 index 67f852d..0000000 --- a/Psr/Log/InvalidArgumentException.php +++ /dev/null @@ -1,7 +0,0 @@ -logger = $logger; - } -} diff --git a/Psr/Log/LoggerInterface.php b/Psr/Log/LoggerInterface.php deleted file mode 100755 index 16c04ad..0000000 --- a/Psr/Log/LoggerInterface.php +++ /dev/null @@ -1,123 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } - - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - * - * @return null - */ - abstract public function log($level, $message, array $context = array()); -} diff --git a/Psr/Log/NullLogger.php b/Psr/Log/NullLogger.php deleted file mode 100755 index 3fc5100..0000000 --- a/Psr/Log/NullLogger.php +++ /dev/null @@ -1,28 +0,0 @@ -logger) { }` - * blocks. - */ -class NullLogger extends AbstractLogger -{ - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - * - * @return null - */ - public function log($level, $message, array $context = array()) - { - // noop - } -} diff --git a/Psr/Log/Test/LoggerInterfaceTest.php b/Psr/Log/Test/LoggerInterfaceTest.php deleted file mode 100755 index 06f250d..0000000 --- a/Psr/Log/Test/LoggerInterfaceTest.php +++ /dev/null @@ -1,133 +0,0 @@ - ". - * - * Example ->error('Foo') would yield "error Foo". - * - * @return string[] - */ - abstract public function getLogs(); - - public function testImplements() - { - $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); - } - - /** - * @dataProvider provideLevelsAndMessages - */ - public function testLogsAtAllLevels($level, $message) - { - $logger = $this->getLogger(); - $logger->{$level}($message, array('user' => 'Bob')); - $logger->log($level, $message, array('user' => 'Bob')); - - $expected = array( - $level.' message of level '.$level.' with context: Bob', - $level.' message of level '.$level.' with context: Bob', - ); - $this->assertEquals($expected, $this->getLogs()); - } - - public function provideLevelsAndMessages() - { - return array( - LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), - LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), - LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), - LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), - LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), - LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), - LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), - LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), - ); - } - - /** - * @expectedException \Psr\Log\InvalidArgumentException - */ - public function testThrowsOnInvalidLevel() - { - $logger = $this->getLogger(); - $logger->log('invalid level', 'Foo'); - } - - public function testContextReplacement() - { - $logger = $this->getLogger(); - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); - - $expected = array('info {Message {nothing} Bob Bar a}'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testObjectCastToString() - { - $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString')); - $dummy->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('DUMMY')); - - $this->getLogger()->warning($dummy); - - $expected = array('warning DUMMY'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextCanContainAnything() - { - $context = array( - 'bool' => true, - 'null' => null, - 'string' => 'Foo', - 'int' => 0, - 'float' => 0.5, - 'nested' => array('with object' => new DummyTest), - 'object' => new \DateTime, - 'resource' => fopen('php://memory', 'r'), - ); - - $this->getLogger()->warning('Crazy context data', $context); - - $expected = array('warning Crazy context data'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextExceptionKeyCanBeExceptionOrOtherValues() - { - $logger = $this->getLogger(); - $logger->warning('Random message', array('exception' => 'oops')); - $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); - - $expected = array( - 'warning Random message', - 'critical Uncaught Exception!' - ); - $this->assertEquals($expected, $this->getLogs()); - } -} - -class DummyTest -{ -} diff --git a/README.md b/README.md index af41be7..7dd59b9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +This fork only works, when this is used via composer and implements fixes for PHP 8.1 + +- Removed psr files from repository +- Removed phar file creation tool +- Added missing php extension requirements +- Supports only PHP 8.0+ + # Amazon Pay SDK (PHP) Amazon Pay API Integration diff --git a/composer.json b/composer.json index eebf610..5e953cc 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "amzn/amazon-pay-sdk-php", + "name": "connox/amazon-pay-sdk-php", "type": "library", - "description": "Amazon Pay SDK (PHP)", + "description": "Fixed fork of Amazon Pay SDK (PHP)", "version": "3.7.1", "keywords": [ "amazon", @@ -25,11 +25,26 @@ "AmazonPay\\": "AmazonPay/" } }, + "autoload-dev": { + "psr-4": { + "AmazonPay\\": "tst/unit" + } + }, "require": { + "php": "8.0.* || 8.1.*", "ext-curl": "*", - "php": ">=5.5.0" + "ext-openssl": "*", + "ext-simplexml": "*", + "psr/log": "^2.0 || ^3.0" }, "require-dev": { - "phpunit/phpunit": "^4" + "phpunit/phpunit": "^9.5" + }, + "replace": { + "amzn/amazon-pay-sdk-php": ">=3.7.1" + }, + "scripts": { + "test:unit": "phpunit --no-coverage", + "test:coverage": "phpunit --coverage-text" } } diff --git a/create-amazon-pay-phar.php b/create-amazon-pay-phar.php deleted file mode 100644 index 1631f3d..0000000 --- a/create-amazon-pay-phar.php +++ /dev/null @@ -1,8 +0,0 @@ -startBuffering(); - $p->setStub(''); - $p->buildFromDirectory('.', '$(.*)\.php$'); - $p->stopBuffering(); - echo "Phar created: amazon-pay.phar\n"; -?> diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..6465e62 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,22 @@ + + + + + + tst/unit + + + + + AmazonPay + + + diff --git a/tst/unit/ClientTest.php b/tst/unit/ClientTest.php index 1b117c5..3d7e021 100644 --- a/tst/unit/ClientTest.php +++ b/tst/unit/ClientTest.php @@ -1,11 +1,9 @@ 'MERCHANT1234567', @@ -37,7 +35,7 @@ public function testConfigArray() try { $client = new Client(array('sandbox' => 'false')); } catch (\Exception $expected) { - $this->assertRegExp('/should be a boolean value/i', strval($expected)); + $this->assertMatchesRegularExpression('/should be a boolean value/i', strval($expected)); } $client = new Client(array('sandbox' => true)); @@ -46,7 +44,7 @@ public function testConfigArray() try { $client = new Client(array('sandbox' => 'true')); } catch (\Exception $expected) { - $this->assertRegExp('/should be a boolean value/i', strval($expected)); + $this->assertMatchesRegularExpression('/should be a boolean value/i', strval($expected)); } // Test that string trimming is working as intended @@ -64,7 +62,7 @@ public function testConfigArray() try { $client = new Client($this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/is not a Json File or the Json File./i', strval($expected)); + $this->assertMatchesRegularExpression('/is not a Json File or the Json File./i', strval($expected)); } // Test passing in invalid keys to constructor @@ -75,7 +73,7 @@ public function testConfigArray() ); $client = new Client($configParams); } catch (\Exception $expected) { - $this->assertRegExp('/is either not part of the configuration or has incorrect Key name./i', strval($expected)); + $this->assertMatchesRegularExpression('/is either not part of the configuration or has incorrect Key name./i', strval($expected)); } // Test passing in override service URL for MWS API endpoint @@ -87,7 +85,7 @@ public function testConfigArray() $configParams = array(); $client = new Client($configParams); } catch (\Exception $expected) { - $this->assertRegExp('/$config cannot be null./i', strval($expected)); + $this->assertMatchesRegularExpression('/$config cannot be null./i', strval($expected)); } } @@ -111,7 +109,7 @@ public function testJsonFile() $configParams = "tst/unit/config/sandbox_true_string.json"; $client = new Client($configParams); } catch (\Exception $expected) { - $this->assertRegExp('/should be a boolean value/i', strval($expected)); + $this->assertMatchesRegularExpression('/should be a boolean value/i', strval($expected)); } $configParams = "tst/unit/config/sandbox_false_bool.json"; @@ -126,14 +124,14 @@ public function testJsonFile() $configParams = "tst/unit/config/sandbox_false_string.json"; $client = new Client($configParams); } catch (\Exception $expected) { - $this->assertRegExp('/should be a boolean value/i', strval($expected)); + $this->assertMatchesRegularExpression('/should be a boolean value/i', strval($expected)); } try { $configParams = "abc.json"; $client = new Client($configParams); } catch (\Exception $expected) { - $this->assertRegExp('/is not a Json File path or the Json File./i', strval($expected)); + $this->assertMatchesRegularExpression('/is not a Json File path or the Json File./i', strval($expected)); } } @@ -143,13 +141,13 @@ public function testSandboxSetter() try { $client->setSandbox(true); } catch (\Exception $expected) { - $this->assertRegExp('/and should be a boolean value./i', strval($expected)); + $this->assertMatchesRegularExpression('/and should be a boolean value./i', strval($expected)); } try { $client->setSandbox('string value'); } catch (\Exception $expected) { - $this->assertRegExp('/and should be a boolean value./i', strval($expected)); + $this->assertMatchesRegularExpression('/and should be a boolean value./i', strval($expected)); } } @@ -483,7 +481,7 @@ public function testConfirmOrderReferenceWithExpectImmediateAuthorizationValueAs $response = $client->confirmOrderReference($apiCallParams); } catch (\Exception $expected) { - $this->assertRegExp('/should be a boolean value/i', strval($expected)); + $this->assertMatchesRegularExpression('/should be a boolean value/i', strval($expected)); } } @@ -1121,7 +1119,7 @@ public function testCharge() $apiCallParams = array('amazon_reference_id' => ''); $client->charge($apiCallParams); } catch (\Exception $expected) { - $this->assertRegExp('/key amazon_order_reference_id or amazon_billing_agreement_id is null and is a required parameter./i', strval($expected)); + $this->assertMatchesRegularExpression('/key amazon_order_reference_id or amazon_billing_agreement_id is null and is a required parameter./i', strval($expected)); } try { @@ -1129,7 +1127,7 @@ public function testCharge() $apiCallParams = array('amazon_reference_id' => 'T01'); $client->charge($apiCallParams); } catch (\Exception $expected) { - $this->assertRegExp('/Invalid Amazon Reference ID./i', strval($expected)); + $this->assertMatchesRegularExpression('/Invalid Amazon Reference ID./i', strval($expected)); } } @@ -1140,7 +1138,7 @@ public function testGetUserInfo() $client = new Client($this->configParams); $client->getUserInfo('Atza'); } catch (\Exception $expected) { - $this->assertRegExp('/is a required parameter./i', strval($expected)); + $this->assertMatchesRegularExpression('/is a required parameter./i', strval($expected)); } try { @@ -1148,7 +1146,7 @@ public function testGetUserInfo() $client = new Client($this->configParams); $client->getUserInfo(null); } catch (\Exception $expected) { - $this->assertRegExp('/Access Token is a required parameter and is not set./i', strval($expected)); + $this->assertMatchesRegularExpression('/Access Token is a required parameter and is not set./i', strval($expected)); } } @@ -1184,7 +1182,7 @@ public function test500or503() $this->callPrivateMethod($client, 'invokePost', null); } catch (\Exception $expected) { - $this->assertRegExp('/Maximum number of retry attempts./i', strval($expected)); + $this->assertMatchesRegularExpression('/Maximum number of retry attempts./i', strval($expected)); } } diff --git a/tst/unit/IpnHandlerTest.php b/tst/unit/IpnHandlerTest.php index 5c5cea4..273dcbd 100644 --- a/tst/unit/IpnHandlerTest.php +++ b/tst/unit/IpnHandlerTest.php @@ -1,9 +1,9 @@ null, @@ -23,7 +23,7 @@ public function testConstructor() $ipnHandler = new IpnHandler($headers,$body,$this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/Error with message - header./i', strval($expected)); + $this->assertMatchesRegularExpression('/Error with message - header./i', strval($expected)); } try { $headers['x-amz-sns-message-type'] = 'Notification'; @@ -32,7 +32,7 @@ public function testConstructor() $ipnHandler = new IpnHandler($headers,$body,$this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/Error with message - content is not in json format./i', strval($expected)); + $this->assertMatchesRegularExpression('/Error with message - content is not in json format./i', strval($expected)); } try { $ConfigParams = array( @@ -43,7 +43,7 @@ public function testConstructor() $ipnHandler = new IpnHandler(array(),null,$ConfigParams); } catch (\Exception $expected) { - $this->assertRegExp('/is either not part of the configuration or has incorrect Key name./i', strval($expected)); + $this->assertMatchesRegularExpression('/is either not part of the configuration or has incorrect Key name./i', strval($expected)); } } @@ -54,42 +54,42 @@ public function testValidateUrl() $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"http://sns.us-east-1.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}'; $ipnHandler = new IpnHandler($headers, $body, $this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected)); + $this->assertMatchesRegularExpression('/The certificate is located on an invalid domain./i', strval($expected)); } try { $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us-east-1.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.exe"}'; $ipnHandler = new IpnHandler($headers, $body, $this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected)); + $this->assertMatchesRegularExpression('/The certificate is located on an invalid domain./i', strval($expected)); } try { $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us-east-1.example.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}'; $ipnHandler = new IpnHandler($headers, $body, $this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected)); + $this->assertMatchesRegularExpression('/The certificate is located on an invalid domain./i', strval($expected)); } try { $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sni.us-east-1.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}'; $ipnHandler = new IpnHandler($headers, $body, $this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected)); + $this->assertMatchesRegularExpression('/The certificate is located on an invalid domain./i', strval($expected)); } try { $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us.amazonaws.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}'; $ipnHandler = new IpnHandler($headers, $body, $this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected)); + $this->assertMatchesRegularExpression('/The certificate is located on an invalid domain./i', strval($expected)); } try { $body = '{"Type":"Notification", "Message":"Test", "MessageId":"Test", "Timestamp":"Test", "Subject":"Test", "TopicArn":"Test", "Signature":"Test", "SigningCertURL":"https://sns.us-east-1.amazonaws.com.com/SimpleNotificationService-bb750dd426d95ee9390147a5624348ee.pem"}'; $ipnHandler = new IpnHandler($headers, $body, $this->configParams); } catch (\Exception $expected) { - $this->assertRegExp('/The certificate is located on an invalid domain./i', strval($expected)); + $this->assertMatchesRegularExpression('/The certificate is located on an invalid domain./i', strval($expected)); } } } From 8877cbc57b04816317e3dca25114a4e21fa858b0 Mon Sep 17 00:00:00 2001 From: Andreas Lange Date: Mon, 13 Jun 2022 10:22:32 +0200 Subject: [PATCH 2/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5e953cc..c466a8c 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "connox/amazon-pay-sdk-php", "type": "library", "description": "Fixed fork of Amazon Pay SDK (PHP)", - "version": "3.7.1", + "version": "3.7.1.1", "keywords": [ "amazon", "pay", From 221d4d5c88aee68bcd46a8afd6906b0a3b058a4a Mon Sep 17 00:00:00 2001 From: Andreas Lange Date: Mon, 13 Jun 2022 10:25:14 +0200 Subject: [PATCH 3/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c466a8c..473e24b 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "connox/amazon-pay-sdk-php", "type": "library", "description": "Fixed fork of Amazon Pay SDK (PHP)", - "version": "3.7.1.1", + "version": "3.7.1.2", "keywords": [ "amazon", "pay", From fe83969af3fd3e9dca85f1982ba19be07d0285f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Schl=C3=A4pfer?= Date: Fri, 18 Nov 2022 13:05:13 +0100 Subject: [PATCH 4/6] update composer.json to php ^8.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 473e24b..3ef4bad 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ } }, "require": { - "php": "8.0.* || 8.1.*", + "php": "^8.0", "ext-curl": "*", "ext-openssl": "*", "ext-simplexml": "*", From 636be635ffa1631b65e469861bed49bf58e00b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Schl=C3=A4pfer?= Date: Fri, 18 Nov 2022 13:06:28 +0100 Subject: [PATCH 5/6] run tests with php 8.2 --- .github/workflows/unit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml index 11cc75c..e16eafc 100644 --- a/.github/workflows/unit.yaml +++ b/.github/workflows/unit.yaml @@ -7,7 +7,7 @@ jobs: phpunit: strategy: matrix: - php-versions: [ '8.0', '8.1' ] + php-versions: [ '8.0', '8.1', '8.2' ] name: 'PHPUnit [PHP ${{ matrix.php-versions }}]' runs-on: ubuntu-latest steps: From cc99d2eeffbfbe9fe36a44c277189fcf6fb18b2e Mon Sep 17 00:00:00 2001 From: Andreas Lange Date: Wed, 17 May 2023 12:11:28 +0200 Subject: [PATCH 6/6] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 473e24b..0faa17f 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ } }, "require": { - "php": "8.0.* || 8.1.*", + "php": "8.0.* || 8.1.* || 8.2.*", "ext-curl": "*", "ext-openssl": "*", "ext-simplexml": "*",