Пример #1
0
 public function testGetBaseRouteNameWithChildAdmin()
 {
     $postAdmin = new PostAdmin('sonata.post.admin.post', 'Application\\Sonata\\NewsBundle\\Entity\\Post', 'SonataNewsBundle:PostAdmin');
     $postAdmin->configure();
     $commentAdmin = new CommentAdmin('sonata.post.admin.comment', 'Application\\Sonata\\NewsBundle\\Entity\\Comment', 'SonataNewsBundle:CommentAdmin');
     $commentAdmin->configure();
     $postAdmin->addChild($commentAdmin);
     $this->assertEquals('admin_sonata_news_post_comment', $commentAdmin->getBaseRouteName());
     $this->assertTrue($postAdmin->hasRoute('show'));
     $this->assertTrue($postAdmin->hasRoute('sonata.post.admin.post.show'));
     $this->assertTrue($postAdmin->hasRoute('sonata.post.admin.post|sonata.post.admin.comment.show'));
     $this->assertFalse($postAdmin->hasRoute('sonata.post.admin.post|sonata.post.admin.comment.edit'));
     $this->assertFalse($commentAdmin->hasRoute('edit'));
 }
Пример #2
0
 public function testGetBaseRouteNameWithChildAdmin()
 {
     $pathInfo = new \Sonata\AdminBundle\Route\PathInfoBuilder($this->getMock('Sonata\\AdminBundle\\Model\\AuditManagerInterface'));
     $postAdmin = new PostAdmin('sonata.post.admin.post', 'Application\\Sonata\\NewsBundle\\Entity\\Post', 'SonataNewsBundle:PostAdmin');
     $postAdmin->setRouteBuilder($pathInfo);
     $postAdmin->initialize();
     $commentAdmin = new CommentAdmin('sonata.post.admin.comment', 'Application\\Sonata\\NewsBundle\\Entity\\Comment', 'SonataNewsBundle:CommentAdmin');
     $commentAdmin->setRouteBuilder($pathInfo);
     $commentAdmin->initialize();
     $postAdmin->addChild($commentAdmin);
     $this->assertEquals('admin_sonata_news_post_comment', $commentAdmin->getBaseRouteName());
     $this->assertTrue($postAdmin->hasRoute('show'));
     $this->assertTrue($postAdmin->hasRoute('sonata.post.admin.post.show'));
     $this->assertTrue($postAdmin->hasRoute('sonata.post.admin.post|sonata.post.admin.comment.show'));
     $this->assertFalse($postAdmin->hasRoute('sonata.post.admin.post|sonata.post.admin.comment.edit'));
     $this->assertFalse($commentAdmin->hasRoute('edit'));
 }