Ejemplo n.º 1
0
 public function testGetRootCode()
 {
     $admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\\Entity\\Post', 'SonataNewsBundle:PostAdmin');
     $this->assertSame('sonata.post.admin.post', $admin->getRootCode());
     $parentAdmin = new PostAdmin('sonata.post.admin.post.parent', 'NewsBundle\\Entity\\PostParent', 'SonataNewsBundle:PostParentAdmin');
     $parentFieldDescription = $this->getMock('Sonata\\AdminBundle\\Admin\\FieldDescriptionInterface');
     $parentFieldDescription->expects($this->once())->method('getAdmin')->will($this->returnValue($parentAdmin));
     $this->assertNull($admin->getParentFieldDescription());
     $admin->setParentFieldDescription($parentFieldDescription);
     $this->assertSame($parentFieldDescription, $admin->getParentFieldDescription());
     $this->assertSame('sonata.post.admin.post.parent', $admin->getRootCode());
 }