This repository has been archived by the owner on Oct 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds customer attaching tests to vault credit card methods
- Loading branch information
Craig Paul
committed
Oct 26, 2016
1 parent
db07e97
commit eb01acf
Showing
1 changed file
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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() | ||
{ | ||
|
@@ -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() | ||
{ | ||
|