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

Commit

Permalink
Adds customer attaching tests to vault credit card methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Oct 26, 2016
1 parent db07e97 commit eb01acf
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion tests/VaultTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use CraigPaul\Moneris\Moneris;
use CraigPaul\Moneris\Vault;
use CraigPaul\Moneris\Moneris;
use CraigPaul\Moneris\Customer;
use CraigPaul\Moneris\CreditCard;

class VaultTest extends TestCase
Expand Down Expand Up @@ -70,6 +71,29 @@ public function it_can_add_a_credit_card_to_the_moneris_vault_and_returns_a_data
$this->assertNotNull($receipt->read('key'));
}

/** @test */
public function it_can_add_a_credit_card_with_an_attached_customer_to_the_moneris_vault_and_returns_a_data_key_for_storage()
{
$params = [
'id' => uniqid('customer-', true),
'email' => '[email protected]',
'phone' => '555-555-5555',
'note' => 'Customer note',
];
$customer = Customer::create($params);
$card = $this->card->attach($customer);

$response = $this->vault->add($card);
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->read('key'));
$this->assertEquals($params['id'], $receipt->read('data')['customer_id']);
$this->assertEquals($params['phone'], $receipt->read('data')['phone']);
$this->assertEquals($params['email'], $receipt->read('data')['email']);
$this->assertEquals($params['note'], $receipt->read('data')['note']);
}

/** @test */
public function it_can_update_a_credit_card_in_the_moneris_vault_and_returns_a_data_key_for_storage()
{
Expand All @@ -89,6 +113,32 @@ public function it_can_update_a_credit_card_in_the_moneris_vault_and_returns_a_d
$this->assertEquals('2112', $response->transaction->params['expdate']);
}

/** @test */
public function it_can_update_a_credit_card_with_an_attached_customer_to_the_moneris_vault_and_returns_a_data_key_for_storage()
{
$params = [
'id' => uniqid('customer-', true),
'email' => '[email protected]',
'phone' => '555-555-5555',
'note' => 'Customer note',
];
$customer = Customer::create($params);
$card = $this->card->attach($customer);

$response = $this->vault->add($card);
$key = $response->receipt()->read('key');

$this->card->customer->email = '[email protected]';

$response = $this->vault->update($key, $this->card);
$receipt = $response->receipt();

$this->assertTrue($response->successful);
$this->assertNotNull($receipt->read('key'));
$this->assertEquals($key, $receipt->read('key'));
$this->assertEquals('[email protected]', $receipt->read('data')['email']);
}

/** @test */
public function it_can_delete_a_credit_card_from_the_moneris_vault_and_returns_a_data_key_for_storage()
{
Expand Down

0 comments on commit eb01acf

Please sign in to comment.