Beispiel #1
0
 /**
  * Tests item in cart functionality.
  */
 public function testItemInCart()
 {
     $product = App\TestProduct::create(['price' => 9.99, 'sku' => str_random(15), 'name' => str_random(64), 'description' => str_random(500)]);
     $user = factory('App\\User')->create();
     $cart = App\Cart::findByUser($user->id)->add($product)->add(['sku' => 'TEST0001', 'price' => 1.99]);
     foreach ($cart->items as $item) {
         if ($item->sku == 'TEST0001') {
             $this->assertFalse($item->hasObject);
             $this->assertNull($item->object);
             $this->assertEquals($item->shopUrl, '#');
         } else {
             $this->assertTrue($item->hasObject);
             $this->assertNotEmpty($item->object);
             $this->assertNotEquals($item->shopUrl, '#');
         }
     }
     $user->delete();
     $product->delete();
 }
Beispiel #2
0
 /**
  * Tests if cart is being created correctly.
  */
 public function testCreationBasedOnNull()
 {
     $cart = App\Cart::findByUser(null);
     $this->assertNotEmpty($cart);
 }