diff --git a/.travis.yml b/.travis.yml index 9eebcbd..0f68a7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: php +env: + global: + - XDEBUG_MODE=coverage + cache: directories: - $HOME/.composer/cache diff --git a/Action/CaptureAction.php b/Action/CaptureAction.php index 696f723..acbc89f 100644 --- a/Action/CaptureAction.php +++ b/Action/CaptureAction.php @@ -10,7 +10,7 @@ use Karser\PayumSaferpay\Request\Api\InitPaymentPage; use Karser\PayumSaferpay\Request\Api\InitTransaction; use League\Uri\Http as HttpUri; -use League\Uri\Modifiers\MergeQuery; +use League\Uri\UriModifier; use Payum\Core\Action\ActionInterface; use Payum\Core\ApiAwareInterface; use Payum\Core\ApiAwareTrait; @@ -135,17 +135,9 @@ private function handleTransactionInterface(Capture $request) private function composeReturnUrls(string $url): array { - $successUrl = HttpUri::createFromString($url); - $modifier = new MergeQuery('success=1'); - $successUrl = $modifier->process($successUrl); - - $failedUrl = HttpUri::createFromString($url); - $modifier = new MergeQuery('fail=1'); - $failedUrl = $modifier->process($failedUrl); - - $cancelUri = HttpUri::createFromString($url); - $modifier = new MergeQuery('abort=1'); - $cancelUri = $modifier->process($cancelUri); + $successUrl = UriModifier::mergeQuery(HttpUri::createFromString($url), 'success=1'); + $failedUrl = UriModifier::mergeQuery(HttpUri::createFromString($url), 'fail=1'); + $cancelUri = UriModifier::mergeQuery(HttpUri::createFromString($url), 'abort=1'); return [ 'Success' => (string) $successUrl, diff --git a/Action/InsertCardAliasAction.php b/Action/InsertCardAliasAction.php index 4b02d83..391670a 100644 --- a/Action/InsertCardAliasAction.php +++ b/Action/InsertCardAliasAction.php @@ -7,7 +7,7 @@ use Karser\PayumSaferpay\Request\Api\InsertAlias; use Karser\PayumSaferpay\Request\InsertCardAlias; use League\Uri\Http as HttpUri; -use League\Uri\Modifiers\MergeQuery; +use League\Uri\UriModifier; use Payum\Core\Action\ActionInterface; use Payum\Core\Bridge\Spl\ArrayObject; use Payum\Core\Exception\RequestNotSupportedException; @@ -53,17 +53,9 @@ private function insertAliasAction(InsertCardAlias $request, ArrayObject $model) if (empty($model['ReturnUrls'])) { $token = $request->getToken(); - $successUrl = HttpUri::createFromString($token->getTargetUrl()); - $modifier = new MergeQuery('success=1'); - $successUrl = $modifier->process($successUrl); - - $failedUrl = HttpUri::createFromString($token->getTargetUrl()); - $modifier = new MergeQuery('fail=1'); - $failedUrl = $modifier->process($failedUrl); - - $cancelUri = HttpUri::createFromString($token->getTargetUrl()); - $modifier = new MergeQuery('abort=1'); - $cancelUri = $modifier->process($cancelUri); + $successUrl = UriModifier::mergeQuery(HttpUri::createFromString($token->getTargetUrl()), 'success=1'); + $failedUrl = UriModifier::mergeQuery(HttpUri::createFromString($token->getTargetUrl()), 'fail=1'); + $cancelUri = UriModifier::mergeQuery(HttpUri::createFromString($token->getTargetUrl()), 'abort=1'); $model['ReturnUrls'] = [ 'Success' => (string) $successUrl, diff --git a/Tests/Unit/Action/CaptureActionTest.php b/Tests/Unit/Action/CaptureActionTest.php index 93975c1..d7ed271 100644 --- a/Tests/Unit/Action/CaptureActionTest.php +++ b/Tests/Unit/Action/CaptureActionTest.php @@ -32,14 +32,13 @@ public function shouldImplementGatewayAwareInterface(): void $this->assertTrue($rc->implementsInterface(GatewayAwareInterface::class)); } - public function provideSupportedRequests(): array + public function provideSupportedRequests(): \Iterator { ($r1 = new Capture(new Token()))->setModel(array()); ($r2 = new Capture(new Token()))->setModel(new \ArrayObject()); - return [ - [$r1], - [$r2], - ]; + + yield [$r1]; + yield [$r2]; } /** diff --git a/Tests/Unit/Action/CaptureReferencedActionTest.php b/Tests/Unit/Action/CaptureReferencedActionTest.php index 9534bb3..4aab56d 100644 --- a/Tests/Unit/Action/CaptureReferencedActionTest.php +++ b/Tests/Unit/Action/CaptureReferencedActionTest.php @@ -44,11 +44,9 @@ public function couldBeConstructedWithoutAnyArguments(): void /** * Overridden because CaptureAction requires request to have TOKEN */ - public function provideSupportedRequests(): array + public function provideSupportedRequests(): \Iterator { - return [ - [new CaptureReferenced(new Payment())], - ]; + yield [new CaptureReferenced(new Payment())]; } } diff --git a/Tests/Unit/Action/ConvertPaymentActionTest.php b/Tests/Unit/Action/ConvertPaymentActionTest.php index c9fc4e3..d3c2498 100644 --- a/Tests/Unit/Action/ConvertPaymentActionTest.php +++ b/Tests/Unit/Action/ConvertPaymentActionTest.php @@ -33,25 +33,24 @@ public function couldBeConstructedWithoutAnyArguments(): void self::assertNotNull(new $this->actionClass()); } - public function provideSupportedRequests() + public function provideSupportedRequests(): \Iterator { - return array( - array(new $this->requestClass(new Payment(), 'array')), - array(new $this->requestClass($this->createMock(PaymentInterface::class), 'array')), - array(new $this->requestClass(new Payment(), 'array', $this->createMock('Payum\Core\Security\TokenInterface'))), - ); + yield [new $this->requestClass(new Payment(), 'array')]; + yield [new $this->requestClass($this->createMock(PaymentInterface::class), 'array')]; + yield [new $this->requestClass(new Payment(), 'array', $this->createMock('Payum\Core\Security\TokenInterface'))]; + } - public function provideNotSupportedRequests() + + public function provideNotSupportedRequests(): \Iterator { - return array( - array('foo'), - array(array('foo')), - array(new \stdClass()), - array($this->getMockForAbstractClass(Generic::class, array(array()))), - array(new $this->requestClass(new \stdClass(), 'array')), - array(new $this->requestClass(new Payment(), 'foobar')), - array(new $this->requestClass($this->createMock(PaymentInterface::class), 'foobar')), - ); + yield ['foo']; + yield [['foo']]; + yield [new \stdClass()]; + yield [$this->getMockForAbstractClass(Generic::class, [[]])]; + yield [new $this->requestClass(new \stdClass(), 'array')]; + yield [new $this->requestClass(new Payment(), 'foobar')]; + yield [new $this->requestClass($this->createMock(PaymentInterface::class), 'foobar')]; + } /** diff --git a/Tests/Unit/Action/InsertCardAliasActionTest.php b/Tests/Unit/Action/InsertCardAliasActionTest.php index 12d3fdb..70b7e16 100644 --- a/Tests/Unit/Action/InsertCardAliasActionTest.php +++ b/Tests/Unit/Action/InsertCardAliasActionTest.php @@ -42,7 +42,7 @@ public function couldBeConstructedWithoutAnyArguments(): void self::assertNotNull(new $this->actionClass()); } - public function provideSupportedRequests(): array + public function provideSupportedRequests(): \Iterator { function getRequest($details) { $alias = new CardAlias(); @@ -52,9 +52,7 @@ function getRequest($details) { return $request; } - return [ - [getRequest(array())], - [getRequest(new \ArrayObject())], - ]; + yield [getRequest([])]; + yield [getRequest(new \ArrayObject())]; } } diff --git a/composer.json b/composer.json index a026b02..3ef97b8 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ ], "require": { "php": "^7.2.0", - "payum/core": "^1.5" + "payum/core": "^1.6" }, "require-dev": { "fabpot/goutte": "^3.3",