public function testCreateWithGlobalDefaults()
 {
     $entityManager = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry', array(), array(), '', false);
     $manager = new PageManager('Sonata\\PageBundle\\Tests\\Model\\Page', $entityManager, array(), array('my_route' => array('decorate' => false, 'name' => 'Salut!')));
     $page = $manager->create(array('name' => 'My Name', 'routeName' => 'my_route'));
     $this->assertEquals('My Name', $page->getName());
     $this->assertFalse($page->getDecorate());
 }
 public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 {
     //        AppDebug::_dx($criteria);
     if ($criteria == array('enabled' => 1)) {
         $repository = $this->getRepository();
         /* @var $repository \Doctrine\ORM\EntityRepository */
         return $repository->createQueryBuilder('s')->orderBy('s.isDefault', 'DESC')->andWhere('s.enabled=true')->getQuery()->useResultCache(true, 300)->execute();
     }
     return parent::findBy($criteria, $orderBy, $limit, $offset);
     // TODO: Change the autogenerated stub
 }
 public function testFixUrl()
 {
     $manager = new PageManager($this->getMock('Doctrine\\ORM\\EntityManager', array(), array(), '', false));
     $page1 = new Page();
     $page1->setName('Salut comment ca va ?');
     $page2 = new Page();
     $page2->setName('Super! et toi ?');
     $page1->addChildren($page2);
     $manager->fixUrl($page1);
     $this->assertEquals($page1->getSlug(), 'salut-comment-ca-va');
     $this->assertEquals($page1->getUrl(), '/salut-comment-ca-va');
     $parent = new Page();
     $parent->setRouteName('homepage');
     $parent->addChildren($page1);
     $manager->fixUrl($parent);
     $this->assertEquals($parent->getSlug(), null);
     // homepage is a specific route name
     $this->assertEquals($parent->getUrl(), '/');
     $this->assertEquals($page1->getSlug(), 'salut-comment-ca-va');
     $this->assertEquals($page1->getUrl(), '/salut-comment-ca-va');
     $this->assertEquals($page2->getSlug(), 'super-et-toi');
     $this->assertEquals($page2->getUrl(), '/salut-comment-ca-va/super-et-toi');
 }