예제 #1
0
 public function testInjectBlocks()
 {
     $layout = new Layout($this->updaterMock, $this->blockPool);
     $layout->attachGenerator('blocks', $this->blocksGenerator);
     $layoutModel = new ViewModel();
     $layout->setRoot($layoutModel);
     $layout->load();
     $this->assertEquals('new/layout', $layoutModel->getTemplate());
     $this->assertCount(3, $layoutModel->getChildren());
     $this->assertCount(1, $layout->getBlock('widget.1')->getChildren());
 }
예제 #2
0
 public function testIsAllowed()
 {
     $layout = new Layout($this->blockFactory, $this->updaterMock);
     $layout->getEventManager()->getSharedManager()->attach('ConLayout\\Layout\\Layout', 'isAllowed', function ($e) {
         $blockId = $e->getParam('block_id');
         if ($blockId === 'widget.1') {
             return false;
         }
         return true;
     });
     $layout->addBlock('mr.widget', new ViewModel());
     $root = new ViewModel();
     $layout->setRoot($root);
     $layout->load();
     $this->assertCount(2, $root->getChildren());
 }