Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
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 |
||
82 | public function testFilterFeatureOutline() |
||
83 | { |
||
84 | $filter = new LineRangeFilter(12, 14); |
||
85 | $feature = $filter->filterFeature($this->getParsedFeature()); |
||
86 | /** @var OutlineNode[] $scenarios */ |
||
87 | $this->assertCount(1, $scenarios = $feature->getScenarios()); |
||
88 | $this->assertSame('Scenario#3', $scenarios[0]->getTitle()); |
||
89 | $this->assertFalse($scenarios[0]->hasExamples()); |
||
90 | |||
91 | $filter = new LineRangeFilter(16, 21); |
||
92 | $feature = $filter->filterFeature($this->getParsedFeature()); |
||
93 | $this->assertCount(1, $scenarios = $feature->getScenarios()); |
||
94 | $this->assertSame('Scenario#3', $scenarios[0]->getTitle()); |
||
95 | $exampleTableNodes = $scenarios[0]->getExampleTables(); |
||
96 | $this->assertEquals(1, count($exampleTableNodes)); |
||
97 | $this->assertCount(3, $exampleTableNodes[0]->getRows()); |
||
98 | $this->assertSame(array( |
||
99 | array('action', 'outcome'), |
||
100 | array('act#1', 'out#1'), |
||
101 | array('act#2', 'out#2'), |
||
102 | ), $exampleTableNodes[0]->getRows()); |
||
103 | $this->assertEquals(array('etag1'), $exampleTableNodes[0]->getTags()); |
||
104 | |||
105 | $filter = new LineRangeFilter(16, 26); |
||
106 | $feature = $filter->filterFeature($this->getParsedFeature()); |
||
107 | $this->assertCount(1, $scenarios = $feature->getScenarios()); |
||
108 | $this->assertSame('Scenario#3', $scenarios[0]->getTitle()); |
||
109 | $exampleTableNodes = $scenarios[0]->getExampleTables(); |
||
110 | $this->assertEquals(2, count($exampleTableNodes)); |
||
111 | |||
112 | $this->assertCount(3, $exampleTableNodes[0]->getRows()); |
||
113 | $this->assertSame(array( |
||
114 | array('action', 'outcome'), |
||
115 | array('act#1', 'out#1'), |
||
116 | array('act#2', 'out#2'), |
||
117 | ), $exampleTableNodes[0]->getRows()); |
||
118 | $this->assertEquals(array('etag1'), $exampleTableNodes[0]->getTags()); |
||
119 | |||
120 | $this->assertCount(2, $exampleTableNodes[1]->getRows()); |
||
121 | $this->assertSame(array( |
||
122 | array('action', 'outcome'), |
||
123 | array('act#3', 'out#3') |
||
124 | ), $exampleTableNodes[1]->getRows()); |
||
125 | |||
126 | $this->assertEquals(array('etag2'), $exampleTableNodes[1]->getTags()); |
||
127 | |||
128 | $filter = new LineRangeFilter(25, 26); |
||
129 | $feature = $filter->filterFeature($this->getParsedFeature()); |
||
130 | $this->assertCount(1, $scenarios = $feature->getScenarios()); |
||
131 | $this->assertSame('Scenario#3', $scenarios[0]->getTitle()); |
||
132 | $exampleTableNodes = $scenarios[0]->getExampleTables(); |
||
133 | $this->assertEquals(1, count($exampleTableNodes)); |
||
134 | $this->assertCount(2, $exampleTableNodes[0]->getRows()); |
||
135 | $this->assertSame(array( |
||
136 | array('action', 'outcome'), |
||
137 | array('act#3', 'out#3'), |
||
138 | ), $exampleTableNodes[0]->getRows()); |
||
139 | $this->assertEquals(array('etag2'), $exampleTableNodes[0]->getTags()); |
||
140 | } |
||
141 | } |
||
142 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: