diff --git a/Tests/Form/FormFlowBcMethodsTest.php b/Tests/Form/FormFlowBcMethodsTest.php index a7579bd4..00320b06 100644 --- a/Tests/Form/FormFlowBcMethodsTest.php +++ b/Tests/Form/FormFlowBcMethodsTest.php @@ -25,10 +25,9 @@ public function testBcMethodDelegation_getCurrentStep() { $flow ->expects($this->once()) ->method('getCurrentStepNumber') - ->will($this->returnValue(1)) ; - $this->assertSame(1, $flow->getCurrentStep()); + $flow->getCurrentStep(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getCurrentStep', 'getCurrentStepNumber')), $this->getDeprecationNotices()); } @@ -38,10 +37,9 @@ public function testBcMethodDelegation_getCurrentStepDescription() { $flow ->expects($this->once()) ->method('getCurrentStepLabel') - ->will($this->returnValue('summary')) ; - $this->assertSame('summary', $flow->getCurrentStepDescription()); + $flow->getCurrentStepDescription(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getCurrentStepDescription', 'getCurrentStepLabel')), $this->getDeprecationNotices()); } @@ -51,10 +49,9 @@ public function testBcMethodDelegation_getMaxSteps() { $flow ->expects($this->once()) ->method('getStepCount') - ->will($this->returnValue(3)) ; - $this->assertSame(3, $flow->getMaxSteps()); + $flow->getMaxSteps(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getMaxSteps', 'getStepCount')), $this->getDeprecationNotices()); } @@ -64,10 +61,9 @@ public function testBcMethodDelegation_getStepDescriptions() { $flow ->expects($this->once()) ->method('getStepLabels') - ->will($this->returnValue(array('step1', 'step2'))) ; - $this->assertSame(array('step1', 'step2'), $flow->getStepDescriptions()); + $flow->getStepDescriptions(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getStepDescriptions', 'getStepLabels')), $this->getDeprecationNotices()); } @@ -77,10 +73,9 @@ public function testBcMethodDelegation_getFirstStep() { $flow ->expects($this->once()) ->method('getFirstStepNumber') - ->will($this->returnValue(2)) ; - $this->assertSame(2, $flow->getFirstStep()); + $flow->getFirstStep(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getFirstStep', 'getFirstStepNumber')), $this->getDeprecationNotices()); } @@ -90,23 +85,24 @@ public function testBcMethodDelegation_getLastStep() { $flow ->expects($this->once()) ->method('getLastStepNumber') - ->will($this->returnValue(5)) ; - $this->assertSame(5, $flow->getLastStep()); + $flow->getLastStep(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getLastStep', 'getLastStepNumber')), $this->getDeprecationNotices()); } public function testBcMethodDelegation_hasSkipStep() { $flow = $this->getFlowWithMockedMethods(array('getName', 'isStepSkipped')); + $stepNumber = 1; + $flow ->expects($this->once()) ->method('isStepSkipped') - ->will($this->returnValueMap(array(array(1, true)))) + ->with($this->equalTo($stepNumber)) ; - $this->assertTrue($flow->hasSkipStep(1)); + $flow->hasSkipStep($stepNumber); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'hasSkipStep', 'isStepSkipped')), $this->getDeprecationNotices()); } diff --git a/Tests/IntegrationTestBundle/Controller/FormFlowController.php b/Tests/IntegrationTestBundle/Controller/FormFlowController.php index 0a3431b0..269a3d0d 100644 --- a/Tests/IntegrationTestBundle/Controller/FormFlowController.php +++ b/Tests/IntegrationTestBundle/Controller/FormFlowController.php @@ -10,7 +10,6 @@ use Craue\FormFlowBundle\Tests\IntegrationTestBundle\Entity\Topic; use Craue\FormFlowBundle\Tests\IntegrationTestBundle\Entity\Vehicle; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\JsonResponse; @@ -23,7 +22,6 @@ class FormFlowController extends Controller { /** * @Route("/create-topic/", name="_FormFlow_createTopic") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function createTopicAction() { return $this->processFlow(new Topic(), $this->get('integrationTestBundle.form.flow.createTopic')); @@ -31,7 +29,6 @@ public function createTopicAction() { /** * @Route("/create-topic-redirect-after-submit/", name="_FormFlow_createTopic_redirectAfterSubmit") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function createTopicRedirectAfterSubmitAction() { $flow = $this->get('integrationTestBundle.form.flow.createTopic'); @@ -43,7 +40,6 @@ public function createTopicRedirectAfterSubmitAction() { /** * @Route("/create-vehicle/", name="_FormFlow_createVehicle") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function createVehicleAction() { return $this->processFlow(new Vehicle(), $this->get('integrationTestBundle.form.flow.createVehicle')); @@ -51,15 +47,13 @@ public function createVehicleAction() { /** * @Route("/demo1/", name="_FormFlow_demo1") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function demo1Action() { - return $this->processFlow((object) array(), $this->get('integrationTestBundle.form.flow.demo1')); + return $this->processFlow(new \stdClass(), $this->get('integrationTestBundle.form.flow.demo1')); } /** * @Route("/issue64/", name="_FormFlow_issue64") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function issue64Action() { return $this->processFlow(new Issue64Data(), $this->get('integrationTestBundle.form.flow.issue64')); @@ -68,15 +62,13 @@ public function issue64Action() { /** * No trailing slash here to add the step only when needed. * @Route("/issue87/{step}", defaults={"step"=1}, name="_FormFlow_issue87") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function issue87Action() { - return $this->processFlow((object) array(), $this->get('integrationTestBundle.form.flow.issue87')); + return $this->processFlow(new \stdClass(), $this->get('integrationTestBundle.form.flow.issue87')); } /** * @Route("/issue149/", name="_FormFlow_issue149") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function issue149Action() { return $this->processFlow(new Issue149Data(), $this->get('integrationTestBundle.form.flow.issue149')); @@ -85,7 +77,6 @@ public function issue149Action() { /** * @Route("/revalidatePreviousSteps/enabled/", defaults={"enabled"=true}, name="_FormFlow_revalidatePreviousSteps_enabled") * @Route("/revalidatePreviousSteps/disabled/", defaults={"enabled"=false}, name="_FormFlow_revalidatePreviousSteps_disabled") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function revalidatePreviousStepsAction($enabled) { $flow = $this->get('integrationTestBundle.form.flow.revalidatePreviousSteps'); @@ -96,37 +87,34 @@ public function revalidatePreviousStepsAction($enabled) { /** * @Route("/skipFirstStepUsingClosure/", name="_FormFlow_skipFirstStepUsingClosure") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function skipFirstStepUsingClosureAction() { - return $this->processFlow((object) array(), $this->get('integrationTestBundle.form.flow.skipFirstStepUsingClosure')); + return $this->processFlow(new \stdClass(), $this->get('integrationTestBundle.form.flow.skipFirstStepUsingClosure')); } /** * @Route("/removeSecondStepSkipMarkOnReset/", name="_FormFlow_removeSecondStepSkipMarkOnReset") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function removeSecondStepSkipMarkOnResetAction() { - return $this->processFlow((object) array(), $this->get('integrationTestBundle.form.flow.removeSecondStepSkipMarkOnReset')); + return $this->processFlow(new \stdClass(), $this->get('integrationTestBundle.form.flow.removeSecondStepSkipMarkOnReset')); } /** * @Route("/onlyOneStep/", name="_FormFlow_onlyOneStep") - * @Template("IntegrationTestBundle::layout_flow.html.twig") */ public function onlyOneStepAction() { - return $this->processFlow((object) array(), $this->get('integrationTestBundle.form.flow.onlyOneStep')); + return $this->processFlow(new \stdClass(), $this->get('integrationTestBundle.form.flow.onlyOneStep')); } /** * @Route("/photoUpload/", name="_FormFlow_photoUpload") - * @Template("IntegrationTestBundle:FormFlow:photoUpload.html.twig") */ public function photoUploadAction() { - return $this->processFlow(new PhotoUpload(), $this->get('integrationTestBundle.form.flow.photoUpload')); + return $this->processFlow(new PhotoUpload(), $this->get('integrationTestBundle.form.flow.photoUpload'), + 'IntegrationTestBundle:FormFlow:photoUpload.html.twig'); } - protected function processFlow($formData, FormFlow $flow) { + protected function processFlow($formData, FormFlow $flow, $template = 'IntegrationTestBundle::layout_flow.html.twig') { $flow->bind($formData); $form = $submittedForm = $flow->createForm(); @@ -152,11 +140,11 @@ protected function processFlow($formData, FormFlow $flow) { return $this->redirect($this->generateUrl($request->attributes->get('_route'), $params)); } - return array( + return $this->render($template, array( 'form' => $form->createView(), 'flow' => $flow, 'formData' => $formData, - ); + )); } protected function getCurrentRequest() {