protected function setUp()
 {
     $this->container = new Container();
     $this->breadcrumbManager = $this->getMockBuilder('Oro\\Bundle\\NavigationBundle\\Menu\\BreadcrumbManager')->disableOriginalConstructor()->getMock();
     $this->helper = $this->getMockBuilder('Knp\\Menu\\Twig\\Helper')->disableOriginalConstructor()->setMethods(['render'])->getMock();
     $this->factory = $this->getMockBuilder('Knp\\Menu\\MenuFactory')->setMethods(['getRouteInfo', 'processRoute'])->getMock();
     $this->factory->expects($this->any())->method('getRouteInfo')->will($this->returnValue(false));
     $this->factory->expects($this->any())->method('processRoute')->will($this->returnSelf());
     /** @var $eventDispatcher EventDispatcherInterface */
     $eventDispatcher = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->getMock();
     $provider = new BuilderChainProvider($this->factory, $eventDispatcher);
     $this->builder = new ConfigurationBuilder();
     $this->builder->setContainer($this->container);
     $provider->addBuilder($this->builder);
     $this->menuExtension = new MenuExtension($this->helper, $provider, $this->breadcrumbManager, $this->container);
 }
 public function testGetCached()
 {
     $options = array();
     $alias = 'test_menu';
     $items = array('name' => $alias);
     $menu = $this->getMockBuilder('Knp\\Menu\\ItemInterface')->getMock();
     $cache = $this->getMockBuilder('Doctrine\\Common\\Cache\\ArrayCache')->getMock();
     $cache->expects($this->once())->method('contains')->with($alias)->will($this->returnValue(true));
     $cache->expects($this->once())->method('fetch')->with($alias)->will($this->returnValue($items));
     $this->factory->expects($this->once())->method('createFromArray')->with($items)->will($this->returnValue($menu));
     $this->factory->expects($this->never())->method('createItem');
     $builder = $this->getMenuBuilderMock();
     $builder->expects($this->never())->method('build');
     $this->eventDispatcher->expects($this->never())->method('dispatch');
     $this->provider->addBuilder($builder, $alias);
     $this->provider->setCache($cache);
     $this->assertAttributeCount(1, 'menus', $this->provider);
 }