Ejemplo n.º 1
0
 /**
  * @covers Sonata\AdminBundle\Admin\Admin::configure
  */
 public function testConfigure()
 {
     $admin = new PostAdmin('sonata.post.admin.post', 'Application\\Sonata\\NewsBundle\\Entity\\Post', 'SonataNewsBundle:PostAdmin');
     $this->assertNotNull($admin->getUniqid());
     $admin->initialize();
     $this->assertNotNull($admin->getUniqid());
     $this->assertSame('Post', $admin->getClassnameLabel());
     $admin = new CommentAdmin('sonata.post.admin.comment', 'Application\\Sonata\\NewsBundle\\Entity\\Comment', 'SonataNewsBundle:CommentAdmin');
     $admin->setClassnameLabel('postcomment');
     $admin->initialize();
     $this->assertSame('postcomment', $admin->getClassnameLabel());
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider provideGetBaseRouteName
  */
 public function testGetBaseRouteNameWithChildAdmin($objFqn, $expected)
 {
     $routeGenerator = new DefaultRouteGenerator($this->getMock('Symfony\\Component\\Routing\\RouterInterface'), new RoutesCache($this->cacheTempFolder, true));
     $pathInfo = new \Sonata\AdminBundle\Route\PathInfoBuilder($this->getMock('Sonata\\AdminBundle\\Model\\AuditManagerInterface'));
     $postAdmin = new PostAdmin('sonata.post.admin.post', $objFqn, 'SonataNewsBundle:PostAdmin');
     $postAdmin->setRouteBuilder($pathInfo);
     $postAdmin->setRouteGenerator($routeGenerator);
     $postAdmin->initialize();
     $commentAdmin = new CommentAdmin('sonata.post.admin.comment', 'Application\\Sonata\\NewsBundle\\Entity\\Comment', 'SonataNewsBundle:CommentAdmin');
     $commentAdmin->setRouteBuilder($pathInfo);
     $commentAdmin->setRouteGenerator($routeGenerator);
     $commentAdmin->initialize();
     $postAdmin->addChild($commentAdmin);
     $this->assertSame($expected . '_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->assertTrue($postAdmin->hasRoute('sonata.post.admin.comment.list'));
     $this->assertFalse($postAdmin->hasRoute('sonata.post.admin.post|sonata.post.admin.comment.edit'));
     $this->assertFalse($commentAdmin->hasRoute('edit'));
 }