Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
12 | public function testLoader() |
||
13 | { |
||
14 | $customFilter1 = $this->getCustomFilterMock(); |
||
15 | $customFilter2 = $this->getCustomFilterMock(); |
||
16 | |||
17 | $gherkin = new Gherkin(); |
||
18 | $gherkin->addLoader($loader = $this->getLoaderMock()); |
||
19 | $gherkin->addFilter($nameFilter = $this->getNameFilterMock()); |
||
20 | $gherkin->addFilter($tagFilter = $this->getTagFilterMock()); |
||
21 | |||
22 | $scenario = new ScenarioNode(null, array(), array(), null, null); |
||
23 | $feature = new FeatureNode(null, null, array(), null, array($scenario), null, null, null, null); |
||
24 | |||
25 | $loader |
||
26 | ->expects($this->once()) |
||
27 | ->method('supports') |
||
28 | ->with($resource = 'some/feature/resource') |
||
29 | ->will($this->returnValue(true)); |
||
30 | $loader |
||
31 | ->expects($this->once()) |
||
32 | ->method('load') |
||
33 | ->with($resource) |
||
34 | ->will($this->returnValue(array($feature))); |
||
35 | |||
36 | $nameFilter |
||
37 | ->expects($this->once()) |
||
38 | ->method('filterFeature') |
||
39 | ->with($this->identicalTo($feature)) |
||
40 | ->will($this->returnValue($feature)); |
||
41 | $tagFilter |
||
42 | ->expects($this->once()) |
||
43 | ->method('filterFeature') |
||
44 | ->with($this->identicalTo($feature)) |
||
45 | ->will($this->returnValue($feature)); |
||
46 | $customFilter1 |
||
47 | ->expects($this->once()) |
||
48 | ->method('filterFeature') |
||
49 | ->with($this->identicalTo($feature)) |
||
50 | ->will($this->returnValue($feature)); |
||
51 | $customFilter2 |
||
52 | ->expects($this->once()) |
||
53 | ->method('filterFeature') |
||
54 | ->with($this->identicalTo($feature)) |
||
55 | ->will($this->returnValue($feature)); |
||
56 | |||
57 | $features = $gherkin->load($resource, array($customFilter1, $customFilter2)); |
||
58 | $this->assertEquals(1, count($features)); |
||
59 | |||
60 | $scenarios = $features[0]->getScenarios(); |
||
61 | $this->assertEquals(1, count($scenarios)); |
||
62 | $this->assertSame($scenario, $scenarios[0]); |
||
63 | } |
||
64 | |||
186 |