From d5e56f705d3811b285294d9b091cfc763194ee03 Mon Sep 17 00:00:00 2001 From: Erik Storli Date: Mon, 11 Feb 2019 11:33:17 +0100 Subject: [PATCH] Omnipay v3 compatibility and removed unecessary var_dump in a test. (#13) * Omnipay v3 compatibility and removed unecessary var_dump in a test. * Adding php_codesniffer * Remove PHP 5.4 & 5.5 from travis.yml. * Removing PHP 5.3 and adding 7.2 & 7.3. --- .travis.yml | 9 ++------ composer.json | 5 +++-- phpunit.xml.dist | 3 --- src/Message/AnnulRequest.php | 4 ++-- src/Message/CaptureRequest.php | 4 ++-- src/Message/CompletePurchaseRequest.php | 4 ++-- src/Message/CreditRequest.php | 4 ++-- src/Message/PurchaseRequest.php | 4 ++-- tests/GatewayTest.php | 2 -- tests/Message/ResponseTest.php | 30 ++++++++++++++++--------- 10 files changed, 35 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2dd872..dcbe845 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,11 @@ language: php php: - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 - -matrix: - include: - - php: 5.3 - dist: precise + - 7.2 + - 7.3 before_script: - composer install -n --dev --prefer-source diff --git a/composer.json b/composer.json index fa68808..11e8c12 100644 --- a/composer.json +++ b/composer.json @@ -26,10 +26,11 @@ "psr-4": { "Omnipay\\Netaxept\\" : "src/" } }, "require": { - "omnipay/common": "~2.0" + "omnipay/common": "~3.0" }, "require-dev": { - "omnipay/tests": "~2.0" + "omnipay/tests": "~3.0", + "squizlabs/php_codesniffer": "^3" }, "extra": { "branch-alias": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a35b736..535809e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,9 +14,6 @@ ./tests/ - - - ./src diff --git a/src/Message/AnnulRequest.php b/src/Message/AnnulRequest.php index 29da0ad..11912f6 100644 --- a/src/Message/AnnulRequest.php +++ b/src/Message/AnnulRequest.php @@ -31,8 +31,8 @@ public function getData() public function sendData($data) { $url = $this->getEndpoint().'/Netaxept/Process.aspx?'; - $httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); + $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data)); - return $this->response = new Response($this, $httpResponse->xml()); + return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents())); } } diff --git a/src/Message/CaptureRequest.php b/src/Message/CaptureRequest.php index 6dabfe0..fe88400 100644 --- a/src/Message/CaptureRequest.php +++ b/src/Message/CaptureRequest.php @@ -30,8 +30,8 @@ public function getData() public function sendData($data) { $url = $this->getEndpoint().'/Netaxept/Process.aspx?'; - $httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); + $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data)); - return $this->response = new Response($this, $httpResponse->xml()); + return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents())); } } diff --git a/src/Message/CompletePurchaseRequest.php b/src/Message/CompletePurchaseRequest.php index d2554e4..7b73a52 100644 --- a/src/Message/CompletePurchaseRequest.php +++ b/src/Message/CompletePurchaseRequest.php @@ -32,8 +32,8 @@ public function sendData($data) } $url = $this->getEndpoint().'/Netaxept/Process.aspx?'; - $httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); + $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data)); - return $this->response = new Response($this, $httpResponse->xml()); + return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents())); } } diff --git a/src/Message/CreditRequest.php b/src/Message/CreditRequest.php index 5019cc2..bed8168 100644 --- a/src/Message/CreditRequest.php +++ b/src/Message/CreditRequest.php @@ -31,8 +31,8 @@ public function getData() public function sendData($data) { $url = $this->getEndpoint().'/Netaxept/Process.aspx?'; - $httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); + $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data)); - return $this->response = new Response($this, $httpResponse->xml()); + return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents())); } } diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 1064f86..0419912 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -74,9 +74,9 @@ public function getData() public function sendData($data) { $url = $this->getEndpoint().'/Netaxept/Register.aspx?'; - $httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); + $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data)); - return $this->response = new Response($this, $httpResponse->xml()); + return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents())); } public function getEndpoint() diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php index 531b740..7cfa850 100644 --- a/tests/GatewayTest.php +++ b/tests/GatewayTest.php @@ -100,8 +100,6 @@ public function testCompletePurchaseFailure() $this->assertFalse($response->isRedirect()); $this->assertNull($response->getTransactionReference()); - var_dump($response->getMessage()); - $this->assertSame('Unable to find transaction', $response->getMessage()); } diff --git a/tests/Message/ResponseTest.php b/tests/Message/ResponseTest.php index dcaea21..47bcd9c 100644 --- a/tests/Message/ResponseTest.php +++ b/tests/Message/ResponseTest.php @@ -9,7 +9,8 @@ class ResponseTest extends TestCase public function testPurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); @@ -20,7 +21,8 @@ public function testPurchaseSuccess() public function testPurchaseFailure() { $httpResponse = $this->getMockHttpResponse('PurchaseFailure.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -33,7 +35,8 @@ public function testPurchaseFailure() public function testCompletePurchaseSuccess() { $httpResponse = $this->getMockHttpResponse('CompletePurchaseSuccess.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -44,7 +47,8 @@ public function testCompletePurchaseSuccess() public function testCompletePurchaseFailure() { $httpResponse = $this->getMockHttpResponse('CompletePurchaseFailure.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -55,7 +59,8 @@ public function testCompletePurchaseFailure() public function testCaptureSuccess() { $httpResponse = $this->getMockHttpResponse('CaptureSuccess.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -66,7 +71,8 @@ public function testCaptureSuccess() public function testCaptureFailure() { $httpResponse = $this->getMockHttpResponse('CaptureFailure.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -77,7 +83,8 @@ public function testCaptureFailure() public function testAnnulSuccess() { $httpResponse = $this->getMockHttpResponse('AnnulSuccess.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -88,7 +95,8 @@ public function testAnnulSuccess() public function testAnnullFailure() { $httpResponse = $this->getMockHttpResponse('AnnulFailure.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -99,7 +107,8 @@ public function testAnnullFailure() public function testCreditSuccess() { $httpResponse = $this->getMockHttpResponse('CreditSuccess.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertTrue($response->isSuccessful()); $this->assertFalse($response->isRedirect()); @@ -110,7 +119,8 @@ public function testCreditSuccess() public function testCreditFailure() { $httpResponse = $this->getMockHttpResponse('CreditFailure.txt'); - $response = new Response($this->getMockRequest(), $httpResponse->xml()); + $xml = simplexml_load_string($httpResponse->getBody()->getContents()); + $response = new Response($this->getMockRequest(), $xml); $this->assertFalse($response->isSuccessful()); $this->assertFalse($response->isRedirect());