public function test_creates_property_if_it_does_not_exist()
 {
     $productName = 'GitHub T-Shirt';
     $this->productBuilder->build($productName)->addProperty('Collection', 2015)->save();
     $product = Product::firstOrCreateByName($productName);
     $properties = $product->getProperties();
     $this->assertEquals(2015, $properties->first()->getValue());
     $this->assertEquals('Collection', $properties->first()->getProperty()->name);
 }
 public function test_creates_product()
 {
     $productName = 'GitHub T-Shirt';
     $SKU = 'SKU99';
     $price = 100;
     $stock = 100;
     $this->productBuilder->build($productName, $SKU, $price, $stock)->addAttribute('description', 'Awesome description')->save();
     $this->product = Product::firstOrCreateByName($productName);
     $this->assertEquals($productName, $this->product->name);
     $this->assertEquals($price, $this->product->getPrice());
     $this->assertEquals($SKU, $this->product->getSku());
     $this->assertEquals(true, $this->product->getMasterVariant()->isInStock());
 }
 /**
  * {@inheritdoc}
  */
 public function build($name, $sku, $price, $stockQty)
 {
     DB::beginTransaction();
     $this->product = Product::firstOrCreateByName($name);
     // Set Base Varient
     $variant = new Variant();
     $variant->sku = $sku;
     $variant->price = $price;
     $variant->on_hand = $stockQty;
     $variant->product_id = $this->product->id;
     $variant->master = true;
     $variant->available_on_demand = false;
     $variant->save();
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function build($name)
 {
     DB::beginTransaction();
     $this->product = Product::firstOrCreateByName($name);
     return $this;
 }