Skip to content

Commit

Permalink
Test failed transactions.
Browse files Browse the repository at this point in the history
Test failed transactions storage.
  • Loading branch information
amostajo committed Nov 18, 2015
1 parent 4cc2188 commit 883af2d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/order/PurchaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 883af2d

Please sign in to comment.