Exemple #1
0
 /**
  * Test load from cache cache
  */
 public function testFullCache()
 {
     $node = new Node();
     $node->setSubnodes(new ArrayCollection())->setId(1);
     $menu = new Menu();
     $menu->setSubnodes(new ArrayCollection())->addSubnode($node);
     $this->menuRepository->expects($this->any())->method('findOneBy');
     $this->cacheProvider->expects($this->once())->method('fetch')->will($this->returnValue('{"1":{"id":1,"name":null,"url":null,"subnodes":[]}}'));
     $this->cacheProvider->expects($this->any())->method('save');
     /**
      * Data is required twice to test how many times data is fetched from
      * cache provider, and to test than both times, returned data is the
      * same
      */
     $this->assertEquals($this->menuManager->loadMenuByCode('admin'), [1 => ['id' => 1, 'name' => null, 'url' => null, 'subnodes' => []]]);
     $this->assertEquals($this->menuManager->loadMenuByCode('admin'), [1 => ['id' => 1, 'name' => null, 'url' => null, 'subnodes' => []]]);
 }
Exemple #2
0
 /**
  * Test IsExpanded.
  */
 public function testIsExpanded()
 {
     $node = new Node();
     $this->assertFalse($node->isExpanded('whatever'));
     $anotherNode = new Node();
     $anotherNode->setActiveUrls(['http://localhost:0001', 'http://localhost:0002']);
     $this->assertFalse($node->isExpanded('http://localhost:0001'));
     $node->setSubnodes(new ArrayCollection());
     $node->addSubnode($anotherNode);
     $this->assertFalse($node->isExpanded('http://localhost:0000'));
     $this->assertTrue($node->isExpanded('http://localhost:0001'));
 }