/**
  * @return static
  */
 public function withOption()
 {
     $option = $this->entity->getOption();
     if ($option !== null) {
         $this->entityDTO->option = $this->dtoBuilderFactory->getOptionDTOBuilder($option)->build();
     }
     return $this;
 }
 public function testCreate()
 {
     $pricing = $this->dummyData->getPricing();
     $option = $this->dummyData->getOption();
     $product = $this->dummyData->getProduct();
     $product->setSku('SM');
     $product->setName('Small Shirt');
     $optionProduct = new OptionProduct($option, $product);
     $optionProduct->setSortOrder(0);
     $this->assertEntityValid($optionProduct);
     $this->assertSame('SM', $optionProduct->getSku());
     $this->assertSame('Small Shirt', $optionProduct->getName());
     $this->assertSame(16, $optionProduct->getShippingWeight());
     $this->assertSame(0, $optionProduct->getSortOrder());
     $this->assertSame($option, $optionProduct->getOption());
     $this->assertSame($product, $optionProduct->getProduct());
     $this->assertTrue($optionProduct->getPrice($pricing) instanceof Price);
 }
Exemple #3
0
 public function getOptionProduct(Option $option = null, Product $product = null)
 {
     if ($option === null) {
         $option = $this->getOption();
     }
     if ($product === null) {
         $product = $this->getProduct();
     }
     $optionProduct = new OptionProduct($option, $product);
     $optionProduct->setSortOrder(0);
     return $optionProduct;
 }
 public function getShippingWeight()
 {
     return $this->optionProduct->getShippingWeight();
 }