/** * @magentoDataFixture Magento/Sales/_files/quote.php */ protected function setUp() { $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $quote = $this->_objectManager->create('Magento\\Quote\\Model\\Quote')->load(1); $sessionQuoteMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session\\Quote')->disableOriginalConstructor()->setMethods(['getCustomerId', 'getStore', 'getStoreId', 'getQuote'])->getMock(); $sessionQuoteMock->expects($this->any())->method('getCustomerId')->will($this->returnValue(1)); $sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quote)); /** @var \Magento\Framework\View\LayoutInterface $layout */ $layout = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface'); $this->_accountBlock = $layout->createBlock('Magento\\Sales\\Block\\Adminhtml\\Order\\Create\\Form\\Account', 'address_block' . rand(), ['sessionQuote' => $sessionQuoteMock]); parent::setUp(); }
/** * @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); }