From 21274474f33e5e03f942bc93509cb78b37311368 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Wed, 24 Jun 2015 18:00:13 +0200 Subject: [PATCH] removed some useless code in tests --- Tests/Form/FormFlowBcMethodsTest.php | 24 ++++++++----------- .../Controller/FormFlowController.php | 22 ++++++----------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/Tests/Form/FormFlowBcMethodsTest.php b/Tests/Form/FormFlowBcMethodsTest.php index 7b04a01b..38a8a9d7 100644 --- a/Tests/Form/FormFlowBcMethodsTest.php +++ b/Tests/Form/FormFlowBcMethodsTest.php @@ -25,10 +25,9 @@ public function testBcMethodDelegation_getCurrentStep() { $flowStub ->expects($this->once()) ->method('getCurrentStepNumber') - ->will($this->returnValue(1)) ; - $this->assertSame(1, $flowStub->getCurrentStep()); + $flowStub->getCurrentStep(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getCurrentStep', 'getCurrentStepNumber')), $this->getDeprecationNotices()); } @@ -38,10 +37,9 @@ public function testBcMethodDelegation_getCurrentStepDescription() { $flowStub ->expects($this->once()) ->method('getCurrentStepLabel') - ->will($this->returnValue('summary')) ; - $this->assertSame('summary', $flowStub->getCurrentStepDescription()); + $flowStub->getCurrentStepDescription(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getCurrentStepDescription', 'getCurrentStepLabel')), $this->getDeprecationNotices()); } @@ -51,10 +49,9 @@ public function testBcMethodDelegation_getMaxSteps() { $flowStub ->expects($this->once()) ->method('getStepCount') - ->will($this->returnValue(3)) ; - $this->assertSame(3, $flowStub->getMaxSteps()); + $flowStub->getMaxSteps(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getMaxSteps', 'getStepCount')), $this->getDeprecationNotices()); } @@ -64,10 +61,9 @@ public function testBcMethodDelegation_getStepDescriptions() { $flowStub ->expects($this->once()) ->method('getStepLabels') - ->will($this->returnValue(array('step1', 'step2'))) ; - $this->assertSame(array('step1', 'step2'), $flowStub->getStepDescriptions()); + $flowStub->getStepDescriptions(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getStepDescriptions', 'getStepLabels')), $this->getDeprecationNotices()); } @@ -77,10 +73,9 @@ public function testBcMethodDelegation_getFirstStep() { $flowStub ->expects($this->once()) ->method('getFirstStepNumber') - ->will($this->returnValue(2)) ; - $this->assertSame(2, $flowStub->getFirstStep()); + $flowStub->getFirstStep(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getFirstStep', 'getFirstStepNumber')), $this->getDeprecationNotices()); } @@ -90,23 +85,24 @@ public function testBcMethodDelegation_getLastStep() { $flowStub ->expects($this->once()) ->method('getLastStepNumber') - ->will($this->returnValue(5)) ; - $this->assertSame(5, $flowStub->getLastStep()); + $flowStub->getLastStep(); $this->assertEquals(array(sprintf($this->deprecatedMessage, 'getLastStep', 'getLastStepNumber')), $this->getDeprecationNotices()); } public function testBcMethodDelegation_hasSkipStep() { $flowStub = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'isStepSkipped')); + $stepNumber = 1; + $flowStub ->expects($this->once()) ->method('isStepSkipped') - ->will($this->returnValueMap(array(array(1, true)))) + ->with($this->equalTo($stepNumber)) ; - $this->assertTrue($flowStub->hasSkipStep(1)); + $flowStub->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 23e464a3..0c53628e 100644 --- a/Tests/IntegrationTestBundle/Controller/FormFlowController.php +++ b/Tests/IntegrationTestBundle/Controller/FormFlowController.php @@ -7,7 +7,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; @@ -30,7 +29,6 @@ public function createTopicStartAction() { /** * @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')); @@ -38,7 +36,6 @@ public function createTopicAction() { /** * @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')); @@ -46,15 +43,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')); @@ -63,29 +58,26 @@ 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("/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')); } - protected function processFlow($formData, FormFlow $flow) { + protected function processFlow($formData, FormFlow $flow, $template = 'IntegrationTestBundle::layout_flow.html.twig') { $flow->bind($formData); $form = $flow->createForm(); @@ -103,11 +95,11 @@ protected function processFlow($formData, FormFlow $flow) { } } - return array( + return $this->render($template, array( 'form' => $form->createView(), 'flow' => $flow, 'formData' => $formData, - ); + )); } }