/** * {@inheritdoc} */ protected function setUp() { $this->treeManager = $this->getMock('Tadcka\\Component\\Tree\\Model\\Manager\\TreeManagerInterface'); $this->treeManager->expects($this->any())->method('create')->will($this->returnValue(new Tree())); $this->treeManager->expects($this->any())->method('getClass')->will($this->returnValue('Tadcka\\Component\\Tree\\Model\\Tree')); $this->treeRegistry = $this->getMock('Tadcka\\Component\\Tree\\Registry\\Tree\\TreeRegistry'); $this->treeRegistry->expects($this->any())->method('getConfigs')->will($this->returnValue(array(new TreeConfig('Test', 'test'), new TreeConfig('Mock', 'mock')))); $this->treeProvider = new TreeProvider($this->treeManager, $this->treeRegistry); }
/** * {@inheritdoc} */ public function getTree($slug) { $config = $this->getTreeConfig($slug); if (null === $config) { throw new TreeNotFoundException(); } $tree = $this->treeManager->findTreeBySlug($config->getSlug()); if (null === $tree) { $tree = $this->treeManager->create(); $tree->setSlug($config->getSlug()); $this->treeManager->add($tree); } return $tree; }