|
@@ -71,7 +71,28 @@ class PoolTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
public function testGetAdminByAdminCode()
|
|
|
{
|
|
|
- $this->assertEquals('adminUserClass', $this->pool->getAdminByAdminCode('sonata.user.admin.group1'));
|
|
|
+ $this->assertEquals('adminUserClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post'));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testGetAdminByAdminCodeForChildClass()
|
|
|
+ {
|
|
|
+ $adminMock = $this->getMock('Sonata\AdminBundle\Admin', array('hasChild', 'getChild'));
|
|
|
+ $adminMock->expects($this->any())
|
|
|
+ ->method('hasChild')
|
|
|
+ ->will($this->returnValue(true));
|
|
|
+ $adminMock->expects($this->once())
|
|
|
+ ->method('getChild')
|
|
|
+ ->with($this->equalTo('sonata.news.admin.comment'))
|
|
|
+ ->will($this->returnValue('commentAdminClass'));
|
|
|
+
|
|
|
+ $containerMock = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
|
|
+ $containerMock->expects($this->any())
|
|
|
+ ->method('get')
|
|
|
+ ->will($this->returnValue($adminMock));
|
|
|
+
|
|
|
+ $this->pool = new Pool($containerMock);
|
|
|
+
|
|
|
+ $this->assertEquals('commentAdminClass', $this->pool->getAdminByAdminCode('sonata.news.admin.post|sonata.news.admin.comment'));
|
|
|
}
|
|
|
|
|
|
public function testGetAdminClasses()
|
|
@@ -92,6 +113,11 @@ class PoolTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals(array('sonata.user.admin.group1', 'sonata.user.admin.group2'), $this->pool->getAdminServiceIds());
|
|
|
}
|
|
|
|
|
|
+ public function testGetContainer()
|
|
|
+ {
|
|
|
+ $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $this->pool->getContainer());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return Symfony\Component\DependencyInjection\ContainerInterface - the mock of container interface
|
|
|
*/
|