From b95b9fb3828f6f8ae18f7c619f8d773ffb1235ee Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Wed, 26 Oct 2016 16:14:16 -0600 Subject: [PATCH] Adds item attached to a purchase test --- tests/VaultTest.php | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/VaultTest.php b/tests/VaultTest.php index cdaea5e..7f52730 100644 --- a/tests/VaultTest.php +++ b/tests/VaultTest.php @@ -29,6 +29,11 @@ class VaultTest extends TestCase */ protected $customer; + /** + * @var array + */ + protected $items; + /** * @var array */ @@ -71,11 +76,26 @@ public function setUp() 'tax3' => '1.03', 'shipping_cost' => '9.99', ]; + $this->items = [ + [ + 'name' => $faker->sentence(mt_rand(3, 6)), + 'quantity' => '1', + 'product_code' => $faker->isbn10, + 'extended_amount' => $faker->randomFloat(2, 0.01, 999.99), + ], + [ + 'name' => $faker->sentence(mt_rand(3, 6)), + 'quantity' => '1', + 'product_code' => $faker->isbn10, + 'extended_amount' => $faker->randomFloat(2, 0.01, 999.99), + ] + ]; $this->customer = [ 'email' => 'example@email.com', 'instructions' => $faker->sentence(mt_rand(3, 6)), 'billing' => $this->billing, - 'shipping' => $this->billing + 'shipping' => $this->billing, + 'items' => $this->items, ]; } @@ -273,12 +293,13 @@ public function it_can_retrieve_all_expiring_credit_cards_from_the_moneris_vault $this->assertTrue($response->successful); $this->assertGreaterThan(0, count($receipt->read('data'))); - foreach($cards as $index => $card) { - /** @var \CraigPaul\Moneris\Receipt $card */ - $card = $card->receipt(); + /** @var \CraigPaul\Moneris\Response $card */ + foreach ($cards as $index => $card) { + /** @var \CraigPaul\Moneris\Receipt $rec */ + $rec = $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']); + $this->assertEquals($rec->read('key'), $receipt->read('data')[$index]['data_key']); + $this->assertEquals($rec->read('data')['masked_pan'], $receipt->read('data')[$index]['masked_pan']); } }