From 883af2da405722f4eb0ca83ac78d039decef6d55 Mon Sep 17 00:00:00 2001 From: Alejandro Mostajo Date: Tue, 17 Nov 2015 18:03:41 -0600 Subject: [PATCH] Test failed transactions. Test failed transactions storage. --- tests/order/PurchaseTest.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/order/PurchaseTest.php b/tests/order/PurchaseTest.php index 1845cad..eb6d6b0 100644 --- a/tests/order/PurchaseTest.php +++ b/tests/order/PurchaseTest.php @@ -97,6 +97,37 @@ public function testFailPurchase() $this->assertEquals(Shop::exception()->getMessage(), 'Payment failed.'); + $user->delete(); + } + /** + * Tests if failed transactions are being created. + */ + public function testFailedTransactions() + { + // Prepare + + $user = factory('App\User')->create(['password' => Hash::make('laravel-shop')]); + + $bool = Auth::attempt(['email' => $user->email, 'password' => 'laravel-shop']); + + $cart = App\Cart::current() + ->add(['sku' => '0001', 'price' => 1.99]) + ->add(['sku' => '0002', 'price' => 2.99]); + + Shop::setGateway('testFail'); + + // Beging test + + $order = Shop::placeOrder(); + + $this->assertNotNull($order); + + $this->assertNotEmpty($order->id); + + $this->assertTrue($order->hasFailed); + + $this->assertEquals(count($order->transactions), 1); + $user->delete(); } } \ No newline at end of file