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()); }