From eb01acfc2c7221f6f26798b1665b64b3c709539a Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Tue, 25 Oct 2016 19:25:15 -0600 Subject: [PATCH] Adds customer attaching tests to vault credit card methods --- tests/VaultTest.php | 52 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/tests/VaultTest.php b/tests/VaultTest.php index e0f101d..74952b0 100644 --- a/tests/VaultTest.php +++ b/tests/VaultTest.php @@ -1,7 +1,8 @@ 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' => 'example@email.com', + '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' => 'example@email.com', + '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 = 'example2@email.com'; + + $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('example2@email.com', $receipt->read('data')['email']); + } + /** @test */ public function it_can_delete_a_credit_card_from_the_moneris_vault_and_returns_a_data_key_for_storage() {