From 4ef31717d95ed7e1d83197d083b660c7fbc51920 Mon Sep 17 00:00:00 2001 From: Andrej Hudec Date: Wed, 6 May 2015 08:32:46 +0200 Subject: [PATCH] Fixed unit tests in CRUDControllerTest --- Tests/Controller/CRUDControllerTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/Controller/CRUDControllerTest.php b/Tests/Controller/CRUDControllerTest.php index 2bf3b42f93..07cc7b17bd 100644 --- a/Tests/Controller/CRUDControllerTest.php +++ b/Tests/Controller/CRUDControllerTest.php @@ -1612,6 +1612,10 @@ public function testEditActionWithModelManagerException($expectedToStringValue, ->with($this->equalTo('EDIT')) ->will($this->returnValue(true)); + $this->admin->expects($this->any()) + ->method('getClass') + ->will($this->returnValue('stdClass')); + $form = $this->getMockBuilder('Symfony\Component\Form\Form') ->disableOriginalConstructor() ->getMock(); @@ -1631,6 +1635,9 @@ public function testEditActionWithModelManagerException($expectedToStringValue, $this->expectTranslate('flash_edit_error', array('%name%' => $expectedToStringValue), 'SonataAdminBundle'); + $form->expects($this->once()) + ->method('isSubmitted') + ->will($this->returnValue(true)); $this->request->setMethod('POST'); $formView = $this->getMock('Symfony\Component\Form\FormView'); @@ -1732,6 +1739,10 @@ public function testPreCreate() ->with($this->equalTo('CREATE')) ->will($this->returnValue(true)); + $this->admin->expects($this->any()) + ->method('getClass') + ->will($this->returnValue('stdClass')); + $this->admin->expects($this->once()) ->method('getNewInstance') ->will($this->returnValue($object)); @@ -1977,6 +1988,10 @@ public function testCreateActionWithModelManagerException($expectedToStringValue ->with($this->equalTo('CREATE')) ->will($this->returnValue(true)); + $this->admin->expects($this->any()) + ->method('getClass') + ->will($this->returnValue('stdClass')); + $object = new \stdClass(); $this->admin->expects($this->once()) @@ -2002,6 +2017,10 @@ public function testCreateActionWithModelManagerException($expectedToStringValue $this->expectTranslate('flash_create_error', array('%name%' => $expectedToStringValue), 'SonataAdminBundle'); + $form->expects($this->once()) + ->method('isSubmitted') + ->will($this->returnValue(true)); + $this->request->setMethod('POST'); $formView = $this->getMock('Symfony\Component\Form\FormView');