Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Updates expiring test to have a mocked response to overcome Moneris A…
Browse files Browse the repository at this point in the history
…pi limits
  • Loading branch information
Craig Paul committed Oct 26, 2016
1 parent ac85c82 commit d3a813d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tests/VaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
use CraigPaul\Moneris\Vault;
use CraigPaul\Moneris\Moneris;
use CraigPaul\Moneris\Customer;
use CraigPaul\Moneris\Processor;
use CraigPaul\Moneris\CreditCard;
use CraigPaul\Moneris\Transaction;

class VaultTest extends TestCase
{
Expand Down Expand Up @@ -249,19 +251,35 @@ public function it_can_peek_into_the_vault_and_retrieve_a_full_credit_card_from_
public function it_can_retrieve_all_expiring_credit_cards_from_the_moneris_vault()
{
$expiry = date('ym', strtotime('today + 10 days'));
$cards = [];

$card = CreditCard::create($this->visa, $expiry);
$this->vault->add($card);
$cards[] = $this->vault->add($card);
$card = CreditCard::create($this->mastercard, $expiry);
$this->vault->add($card);
$cards[] = $this->vault->add($card);
$card = CreditCard::create($this->amex, $expiry);
$this->vault->add($card);
$cards[] = $this->vault->add($card);

$response = $this->vault->expiring();
$client = mock_handler((new VaultExpiringStub())->render($cards));

$params = ['type' => 'res_get_expiring'];
$transaction = new Transaction($this->vault, $params);
$this->vault->transaction = $transaction;
$processor = new Processor($client);

$response = $processor->process($transaction);
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertGreaterThan(0, count($receipt->read('data')));

foreach($cards as $index => $card) {
/** @var \CraigPaul\Moneris\Receipt $card */
$card = $card->receipt();

$this->assertEquals($card->read('key'), $receipt->read('data')[$index]['data_key']);
$this->assertEquals($card->read('data')['masked_pan'], $receipt->read('data')[$index]['masked_pan']);
}
}

/** @test */
Expand Down

0 comments on commit d3a813d

Please sign in to comment.