Skip to content

Commit

Permalink
Improve support for postgresql when objectId="" and not null
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Rabaix committed Apr 16, 2014
1 parent b0a7773 commit 8d665ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Controller/HelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ public function getShortObjectDescriptionAction(Request $request)
if ($uniqid) {
$admin->setUniqid($uniqid);
}
if(!$objectId){

if (!$objectId){
$objectId = null;
}

Expand Down
27 changes: 27 additions & 0 deletions Tests/Controller/HelperControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,33 @@ public function testgetShortObjectDescriptionActionObjectDoesNotExist()
$controller->getShortObjectDescriptionAction($request);
}

public function testgetShortObjectDescriptionActionEmptyObjectId()
{
$admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
$admin->expects($this->once())->method('setUniqid');
$admin->expects($this->once())->method('getObject')->with($this->identicalTo(null))->will($this->returnValue(false));

$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container->expects($this->any())->method('get')->will($this->returnValue($admin));

$twig = new Twig;
$request = new Request(array(
'code' => 'sonata.post.admin',
'objectId' => "",
'uniqid' => 'asdasd123',
'_format' => 'html'
));

$pool = new Pool($container, 'title', 'logo');

$helper = new AdminHelper($pool);

$validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
$controller = new HelperController($twig, $pool, $helper, $validator);

$controller->getShortObjectDescriptionAction($request);
}

public function testgetShortObjectDescriptionActionObject()
{
$mockTemplate = 'AdminHelperTest:mock-short-object-description.html.twig';
Expand Down

0 comments on commit 8d665ac

Please sign in to comment.