Skip to content

Commit 1b5a46f

Browse files
committed
cleaned up code of some tests
1 parent f5f16be commit 1b5a46f

File tree

4 files changed

+90
-119
lines changed

4 files changed

+90
-119
lines changed

Tests/Form/FormFlowBcMethodsTest.php

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Craue\FormFlowBundle\Tests\Form;
44

5+
use Craue\FormFlowBundle\Form\FormFlow;
6+
57
/**
68
* Ensure that the methods for BC do what they should.
79
*
@@ -14,104 +16,104 @@
1416
class FormFlowBcMethodsTest extends \PHPUnit_Framework_TestCase {
1517

1618
public function testBcMethodDelegation_getCurrentStep() {
17-
$flowStub = $this->getFlowWithMockedDeprecationTriggerMethod('getCurrentStep', 'getCurrentStepNumber');
19+
$flow = $this->getFlowWithMockedDeprecationTriggerMethod('getCurrentStep', 'getCurrentStepNumber');
1820

19-
$flowStub
21+
$flow
2022
->expects($this->once())
2123
->method('getCurrentStepNumber')
2224
->will($this->returnValue(1))
2325
;
2426

25-
$this->assertSame(1, $flowStub->getCurrentStep());
27+
$this->assertSame(1, $flow->getCurrentStep());
2628
}
2729

2830
public function testBcMethodDelegation_getCurrentStepDescription() {
29-
$flowStub = $this->getFlowWithMockedDeprecationTriggerMethod('getCurrentStepDescription', 'getCurrentStepLabel');
31+
$flow = $this->getFlowWithMockedDeprecationTriggerMethod('getCurrentStepDescription', 'getCurrentStepLabel');
3032

31-
$flowStub
33+
$flow
3234
->expects($this->once())
3335
->method('getCurrentStepLabel')
3436
->will($this->returnValue('summary'))
3537
;
3638

37-
$this->assertSame('summary', $flowStub->getCurrentStepDescription());
39+
$this->assertSame('summary', $flow->getCurrentStepDescription());
3840
}
3941

4042
public function testBcMethodDelegation_getMaxSteps() {
41-
$flowStub = $this->getFlowWithMockedDeprecationTriggerMethod('getMaxSteps', 'getStepCount');
43+
$flow = $this->getFlowWithMockedDeprecationTriggerMethod('getMaxSteps', 'getStepCount');
4244

43-
$flowStub
45+
$flow
4446
->expects($this->once())
4547
->method('getStepCount')
4648
->will($this->returnValue(3))
4749
;
4850

49-
$this->assertSame(3, $flowStub->getMaxSteps());
51+
$this->assertSame(3, $flow->getMaxSteps());
5052
}
5153

5254
public function testBcMethodDelegation_getStepDescriptions() {
53-
$flowStub = $this->getFlowWithMockedDeprecationTriggerMethod('getStepDescriptions', 'getStepLabels');
55+
$flow = $this->getFlowWithMockedDeprecationTriggerMethod('getStepDescriptions', 'getStepLabels');
5456

55-
$flowStub
57+
$flow
5658
->expects($this->once())
5759
->method('getStepLabels')
5860
->will($this->returnValue(array('step1', 'step2')))
5961
;
6062

61-
$this->assertSame(array('step1', 'step2'), $flowStub->getStepDescriptions());
63+
$this->assertSame(array('step1', 'step2'), $flow->getStepDescriptions());
6264
}
6365

6466
public function testBcMethodDelegation_getFirstStep() {
65-
$flowStub = $this->getFlowWithMockedDeprecationTriggerMethod('getFirstStep', 'getFirstStepNumber');
67+
$flow = $this->getFlowWithMockedDeprecationTriggerMethod('getFirstStep', 'getFirstStepNumber');
6668

67-
$flowStub
69+
$flow
6870
->expects($this->once())
6971
->method('getFirstStepNumber')
7072
->will($this->returnValue(2))
7173
;
7274

73-
$this->assertSame(2, $flowStub->getFirstStep());
75+
$this->assertSame(2, $flow->getFirstStep());
7476
}
7577

7678
public function testBcMethodDelegation_getLastStep() {
77-
$flowStub = $this->getFlowWithMockedDeprecationTriggerMethod('getLastStep', 'getLastStepNumber');
79+
$flow = $this->getFlowWithMockedDeprecationTriggerMethod('getLastStep', 'getLastStepNumber');
7880

79-
$flowStub
81+
$flow
8082
->expects($this->once())
8183
->method('getLastStepNumber')
8284
->will($this->returnValue(5))
8385
;
8486

85-
$this->assertSame(5, $flowStub->getLastStep());
87+
$this->assertSame(5, $flow->getLastStep());
8688
}
8789

8890
public function testBcMethodDelegation_hasSkipStep() {
89-
$flowStub = $this->getFlowWithMockedDeprecationTriggerMethod('hasSkipStep', 'isStepSkipped');
91+
$flow = $this->getFlowWithMockedDeprecationTriggerMethod('hasSkipStep', 'isStepSkipped');
9092

91-
$flowStub
93+
$flow
9294
->expects($this->once())
9395
->method('isStepSkipped')
9496
->will($this->returnValueMap(array(array(1, true))))
9597
;
9698

97-
$this->assertTrue($flowStub->hasSkipStep(1));
99+
$this->assertTrue($flow->hasSkipStep(1));
98100
}
99101

100102
/**
101103
* @param string $bcMethodName Name of the method for BC.
102104
* @param string $realMethodName Name of the new method actually being called.
103-
* @return PHPUnit_Framework_MockObject_MockObject|\Craue\FormFlowBundle\Form\FormFlow
105+
* @return PHPUnit_Framework_MockObject_MockObject|FormFlow
104106
*/
105107
protected function getFlowWithMockedDeprecationTriggerMethod($bcMethodName, $realMethodName) {
106-
$flowStub = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'triggerDeprecationError', $realMethodName));
108+
$flow = $this->getMock('\Craue\FormFlowBundle\Form\FormFlow', array('getName', 'triggerDeprecationError', $realMethodName));
107109

108-
$class = new \ReflectionClass($flowStub);
110+
$class = new \ReflectionClass($flow);
109111
foreach ($class->getMethods() as $method) {
110112
$methodName = $method->getName();
111113

112114
switch ($methodName) {
113115
case 'triggerDeprecationError':
114-
$flowStub
116+
$flow
115117
->expects($this->once())
116118
->method($methodName)
117119
->with(sprintf('%s() is deprecated since version 2.0. Use %s() instead.', $bcMethodName, $realMethodName))
@@ -121,15 +123,15 @@ protected function getFlowWithMockedDeprecationTriggerMethod($bcMethodName, $rea
121123
break;
122124
default:
123125
// assert that no other methods (of the flow class) are called
124-
$flowStub
126+
$flow
125127
->expects($this->never())
126128
->method($methodName)
127129
;
128130
break;
129131
}
130132
}
131133

132-
return $flowStub;
134+
return $flow;
133135
}
134136

135137
}

0 commit comments

Comments
 (0)