Exemplo n.º 1
0
 public function testFactory()
 {
     $product = new \Magento\Framework\DataObject();
     $product->setTypeId(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE);
     $type = $this->_productType->factory($product);
     $this->assertInstanceOf('\\Magento\\GroupedProduct\\Model\\Product\\Type\\Grouped', $type);
 }
Exemplo n.º 2
0
 /**
  * @param sring|null $typeId
  * @dataProvider factoryReturnsSingletonDataProvider
  */
 public function testFactoryReturnsSingleton($typeId)
 {
     $product = new \Magento\Framework\DataObject();
     if ($typeId) {
         $product->setTypeId($typeId);
     }
     $type = $this->_productType->factory($product);
     $otherType = $this->_productType->factory($product);
     $this->assertSame($otherType, $type);
 }
Exemplo n.º 3
0
 /**
  * Retrieve Product Type Instances
  * as key - type code, value - instance model
  *
  * @return array
  */
 protected function getProductTypeInstances()
 {
     if (empty($this->productTypes)) {
         $productEmulator = new \Magento\Framework\DataObject();
         foreach (array_keys($this->productType->getTypes()) as $typeId) {
             $productEmulator->setTypeId($typeId);
             $this->productTypes[$typeId] = $this->productType->factory($productEmulator);
         }
     }
     return $this->productTypes;
 }
 /**
  * Retrieve Product Emulator (Magento Object)
  *
  * @param string $typeId
  * @return \Magento\Framework\DataObject
  */
 private function getProductEmulator($typeId)
 {
     if (!isset($this->productEmulators[$typeId])) {
         $productEmulator = new \Magento\Framework\DataObject();
         $productEmulator->setTypeId($typeId);
         $this->productEmulators[$typeId] = $productEmulator;
     }
     return $this->productEmulators[$typeId];
 }