Skip to content

Commit

Permalink
Updated tests to cover 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
andypieters committed Oct 18, 2018
1 parent 4d01d13 commit 691f2f3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vendor/*
.idea/*
docs/samples/*
samples/*
logs/*
composer.lock
composer.lock
build/*
31 changes: 30 additions & 1 deletion tests/Message/CompletePurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Omnipay\Paynl\Test\Message;


use Omnipay\Paynl\Message\Request\CompletePurchaseRequest;
use Omnipay\Paynl\Message\Response\CompletePurchaseResponse;
use Omnipay\Tests\TestCase;
Expand Down Expand Up @@ -43,6 +42,36 @@ public function testSendSuccessVerify()
$this->assertEquals(1, $response->getAmount(), 'Amount should be 1 USD');
$this->assertEquals('USD', $response->getCurrency(), 'Amount should be 1 USD');
}
public function testReturn(){
$transactionId = uniqid();
$_GET['orderId'] = $transactionId;

$data = $this->request->getData();

$this->assertEquals($transactionId, $data['transactionId']);

//unset to prevent influencing other tests
unset($_GET['orderId']);
}
public function testExchange(){
$transactionId = uniqid();
$_REQUEST['order_id'] = $transactionId;

$data = $this->request->getData();

$this->assertEquals($transactionId, $data['transactionId']);

//unset to prevent influencing other tests
unset($_REQUEST['order_id']);
}

/**
* @expectedException Omnipay\Common\Exception\InvalidRequestException
*/
public function testNoTransactionId(){

$this->request->getData();
}

protected function setUp()
{
Expand Down
13 changes: 13 additions & 0 deletions tests/Message/FetchPaymentMethodsRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ public function testSendSuccess()
$this->assertContainsOnlyInstancesOf(PaymentMethod::class, $paymentMethods);
}

public function testSendError()
{
$this->setMockHttpResponse('FetchPaymentMethodsError.txt');

$response = $this->request->send();

$this->assertInstanceOf(FetchPaymentMethodsResponse::class, $response);
$this->assertFalse($response->isSuccessful());

$this->assertNotEmpty($response->getMessage());
$this->assertNull($response->getPaymentMethods());
}

protected function setUp()
{
$this->request = new FetchPaymentMethodsRequest($this->getHttpClient(), $this->getHttpRequest());
Expand Down
25 changes: 25 additions & 0 deletions tests/Mock/FetchPaymentMethodsError.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
HTTP/1.1 200 OK
Date: Thu, 18 Oct 2018 14:46:07 GMT;
Server: Apache;
Expires: Mon, 26 Jul 1990 05:00:00 GMT;
Last-Modified: Thu, 18 Oct 2018 14:46:07 GMT;
Cache-Control: post-check=0, pre-check=0;
Pragma: no-cache;
X-Frame-Options: SAMEORIGIN;
X-XSS-Protection: 1; mode=block;
X-Content-Type-Options: nosniff;
Content-Length: 145;
Connection: close;
Content-Type: application/json;

{
"request": {
"result": "0",
"errorId": "PAY-404",
"errorMessage": "Service not found"
},
"merchant": "",
"service": "",
"settings": "",
"countryOptionList": ""
}

0 comments on commit 691f2f3

Please sign in to comment.