Skip to content

Commit

Permalink
Added a new test so we can get 100% test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Caswell committed Mar 13, 2017
1 parent cecc35a commit 26a83d9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
15 changes: 15 additions & 0 deletions tests/Message/AbstractRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ public function setUp()
}
}

/**
* Get a valid card with the specific data needed to test on Plug 'N Pay
*
* @return array
*/
protected function getTestableCard()
{
$card = $this->getValidCard();
$card['expiryMonth'] = '01';
$card['expiryYear'] = '19';
$card['cvv'] = '810';

return $card;
}

/**
* Test the endpoint
*/
Expand Down
21 changes: 17 additions & 4 deletions tests/Message/AuthorizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace tests\Message;


use Omnipay\Common\CreditCard;
use Omnipay\PlugNPay\Message\AuthorizeRequest;
use Omnipay\PlugNPay\Message\AuthorizeResponse;

Expand All @@ -24,10 +25,7 @@ public function setUp()
{
parent::setUp();
$this->request = new AuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
$card = $this->getValidCard();
$card['expiryMonth'] = '01';
$card['expiryYear'] = '19';
$card['cvv'] = '810';
$card = $this->getTestableCard();
$this->request->initialize([
'username'=>$this->username,
'password'=>$this->password,
Expand Down Expand Up @@ -70,6 +68,21 @@ public function testGetData()
$this->assertSame($expectedData, $this->request->getData());
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Name missing from credit card.
*/
public function testEmptyName()
{
$card = $this->getTestableCard();
$card['firstName'] = '';
$card['lastName'] = '';

$this->request->setCard(new CreditCard($card));

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

/**
* Test a successful Authorize
*/
Expand Down
5 changes: 1 addition & 4 deletions tests/Message/PurchaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ public function setUp()
{
parent::setUp();
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
$card = $this->getValidCard();
$card['expiryMonth'] = '01';
$card['expiryYear'] = '19';
$card['cvv'] = '810';
$card = $this->getTestableCard();
$this->request->initialize([
'username'=>$this->username,
'password'=>$this->password,
Expand Down

0 comments on commit 26a83d9

Please sign in to comment.