Example #1
0
 /**
  * @magentoAppIsolation enabled
  * @magentoAppArea frontend
  */
 public function testInitProductLayout()
 {
     $uniqid = uniqid();
     /** @var $product \Magento\Catalog\Model\Product */
     $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product');
     $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE)->setId(99)->setUrlKey($uniqid);
     /** @var $objectManager \Magento\TestFramework\ObjectManager */
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $objectManager->get('Magento\\Framework\\Registry')->register('product', $product);
     $this->_helper->initProductLayout($product, $this->_controller);
     $rootBlock = $this->_layout->getBlock('root');
     $this->assertInstanceOf('Magento\\Theme\\Block\\Html', $rootBlock);
     $this->assertContains("product-{$uniqid}", $rootBlock->getBodyClass());
     $handles = $this->_layout->getUpdate()->getHandles();
     $this->assertContains('catalog_product_view_type_simple', $handles);
 }
Example #2
0
 /**
  * @magentoAppIsolation enabled
  * @magentoAppArea frontend
  */
 public function testInitProductLayout()
 {
     $uniqid = uniqid();
     /** @var $product \Magento\Catalog\Model\Product */
     $product = $this->objectManager->create('Magento\\Catalog\\Model\\Product');
     $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE)->setId(99)->setUrlKey($uniqid);
     /** @var $objectManager \Magento\TestFramework\ObjectManager */
     $objectManager = $this->objectManager;
     $objectManager->get('Magento\\Framework\\Registry')->register('product', $product);
     $this->_helper->initProductLayout($product, $this->_controller);
     /** @var \Magento\Framework\View\Page\Config $pageConfig */
     $pageConfig = $this->objectManager->get('Magento\\Framework\\View\\Page\\Config');
     $bodyClass = $pageConfig->getElementAttribute(\Magento\Framework\View\Page\Config::ELEMENT_TYPE_BODY, 'classes');
     $this->assertContains("product-{$uniqid}", $bodyClass);
     $handles = $this->_layout->getUpdate()->getHandles();
     $this->assertContains('catalog_product_view_type_simple', $handles);
 }