Exemplo n.º 1
0
 public function testSetListCollection()
 {
     /** @var $childBlock \Magento\Framework\View\Element\Text */
     $childBlock = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'search_result_list', 'block');
     $this->assertEmpty($childBlock->getCollection());
     $this->_block->setListCollection();
     $this->assertInstanceOf('Magento\\CatalogSearch\\Model\\ResourceModel\\Advanced\\Collection', $childBlock->getCollection());
 }
Exemplo n.º 2
0
 public function testToHtmlWithContainer()
 {
     $listName = $this->_block->getNameInLayout();
     $block1 = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', '', $listName);
     $this->_layout->addContainer('container', 'Container', [], $listName);
     $block2 = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', '', 'container');
     $block3 = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', '', $listName);
     $block1->setText('text1');
     $block2->setText('text2');
     $block3->setText('text3');
     $html = $this->_block->toHtml();
     $this->assertEquals('text1text2text3', $html);
 }
Exemplo n.º 3
0
 public function testGetInvoiceCommentsHtml()
 {
     $childBlock = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'invoice_comments', 'block');
     $expectedHtml = '<b>Any html</b>';
     $this->assertEmpty($childBlock->getEntity());
     $this->assertEmpty($childBlock->getTitle());
     $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceCommentsHtml($this->_invoice));
     $childBlock->setText($expectedHtml);
     $actualHtml = $this->_block->getInvoiceCommentsHtml($this->_invoice);
     $this->assertSame($this->_invoice, $childBlock->getEntity());
     $this->assertNotEmpty($childBlock->getTitle());
     $this->assertEquals($expectedHtml, $actualHtml);
 }
Exemplo n.º 4
0
 public function testToHtmlPropagatesUrl()
 {
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setAreaCode('frontend');
     $this->_block->setShouldPrepareInfoTabs(true);
     $childOne = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'child1', 'block');
     $this->_layout->addToParentGroup('child1', 'info_tabs');
     $childTwo = $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'child2', 'block');
     $this->_layout->addToParentGroup('child2', 'info_tabs');
     $this->assertEmpty($childOne->getViewUrl());
     $this->assertEmpty($childTwo->getViewUrl());
     $this->_block->toHtml();
     $this->assertNotEmpty($childOne->getViewUrl());
     $this->assertNotEmpty($childTwo->getViewUrl());
 }
Exemplo n.º 5
0
 /**
  * Create Block with Layout
  *
  * @param string $name
  * @param null|string $alias
  * @param null|string $type
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 protected function _createBlockWithLayout($name = 'block', $alias = null, $type = 'Magento\\Framework\\View\\Element\\AbstractBlock')
 {
     $typePart = explode('\\', $type);
     $mockClass = array_pop($typePart) . 'Mock';
     if (!isset(self::$_mocks[$mockClass])) {
         self::$_mocks[$mockClass] = $this->getMockForAbstractClass($type, [\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\Element\\Context'), ['module_name' => 'Magento_Theme']], $mockClass);
     }
     if ($this->_layout === null) {
         $this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface');
     }
     $block = $this->_layout->addBlock($mockClass, $name, '', $alias);
     return $block;
 }
Exemplo n.º 6
0
 protected function setUp()
 {
     $this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface');
     $this->_block = $this->_layout->addBlock('Magento\\Wishlist\\Block\\Customer\\Wishlist\\Item\\Column', 'test');
     $this->_layout->addBlock('Magento\\Framework\\View\\Element\\Text', 'child', 'test');
 }
Exemplo n.º 7
0
 /**
  * Emulate 'account links' block with persistent data
  *
  * @return void
  */
 protected function _applyAccountLinksPersistentData()
 {
     if (!$this->_layout->getBlock('header.additional')) {
         $this->_layout->addBlock('Magento\\Persistent\\Block\\Header\\Additional', 'header.additional');
     }
 }