예제 #1
0
 /** @test */
 public function should_run_closure_of_actions()
 {
     $this->product->action(function ($product) {
         $product->quantity(3);
         $product->freebie(true);
         $product->taxable(false);
     });
     $this->assertEquals(3, $this->product->quantity);
     $this->assertTrue($this->product->freebie);
     $this->assertFalse($this->product->taxable);
 }
예제 #2
0
 /**
  * Add a product to the basket
  *
  * @param string $sku
  * @param string $name
  * @param Money $price
  * @param Closure $action
  * @return void
  */
 public function add($sku, $name, Money $price, Closure $action = null)
 {
     $product = new Product($sku, $name, $price, $this->rate);
     if ($action) {
         $product->action($action);
     }
     $this->products->add($sku, $product);
 }