Exemplo n.º 1
0
 /**
  * @return void
  */
 public function testGetCacheKeyByName()
 {
     $nameInLayout = 'testBlock';
     $this->block->setNameInLayout($nameInLayout);
     $cacheKey = sha1($nameInLayout);
     $this->assertEquals(AbstractBlock::CACHE_KEY_PREFIX . $cacheKey, $this->block->getCacheKey());
 }
Exemplo n.º 2
0
 public function testSetGetNameInLayout()
 {
     // Basic setting/getting
     $this->assertEmpty($this->_block->getNameInLayout());
     $name = uniqid('name');
     $this->_block->setNameInLayout($name);
     $this->assertEquals($name, $this->_block->getNameInLayout());
     // Setting second time, along with the layout
     $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface');
     $layout->createBlock('Magento\\Framework\\View\\Element\\Template', $name);
     $block = $layout->getBlock($name);
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $block);
     $block->setNameInLayout($name);
     $this->assertInstanceOf('Magento\\Framework\\View\\Element\\AbstractBlock', $layout->getBlock($name));
     $this->assertEquals($name, $block->getNameInLayout());
     $this->assertTrue($layout->hasElement($name));
     $newName = 'new_name';
     $block->setNameInLayout($newName);
     $this->assertTrue($layout->hasElement($newName));
     $this->assertFalse($layout->hasElement($name));
 }