/** * @covers Sonata\AdminBundle\Admin\Admin::hasChild * @covers Sonata\AdminBundle\Admin\Admin::addChild * @covers Sonata\AdminBundle\Admin\Admin::getChild * @covers Sonata\AdminBundle\Admin\Admin::isChild * @covers Sonata\AdminBundle\Admin\Admin::hasChildren * @covers Sonata\AdminBundle\Admin\Admin::getChildren */ public function testChildren() { $postAdmin = new PostAdmin('sonata.post.admin.post', 'Application\Sonata\NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin'); $this->assertFalse($postAdmin->hasChildren()); $this->assertFalse($postAdmin->hasChild('comment')); $commentAdmin = new CommentAdmin('sonata.post.admin.comment', 'Application\Sonata\NewsBundle\Entity\Comment', 'SonataNewsBundle:CommentAdmin'); $postAdmin->addChild($commentAdmin); $this->assertTrue($postAdmin->hasChildren()); $this->assertTrue($postAdmin->hasChild('sonata.post.admin.comment')); $this->assertEquals('sonata.post.admin.comment', $postAdmin->getChild('sonata.post.admin.comment')->getCode()); $this->assertEquals('sonata.post.admin.post|sonata.post.admin.comment', $postAdmin->getChild('sonata.post.admin.comment')->getBaseCodeRoute()); $this->assertEquals($postAdmin, $postAdmin->getChild('sonata.post.admin.comment')->getParent()); $this->assertFalse($postAdmin->isChild()); $this->assertTrue($commentAdmin->isChild()); $this->assertEquals(array('sonata.post.admin.comment' => $commentAdmin), $postAdmin->getChildren()); }
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')); }
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')); }