1 | <?php |
||
15 | final class ReaderTest extends TestCase |
||
16 | { |
||
17 | private $unreadableFilePath; |
||
18 | |||
19 | public function setUp() |
||
25 | |||
26 | public function tearDown() |
||
30 | |||
31 | /** |
||
32 | * Verify basic usage of Reader. |
||
33 | * |
||
34 | * @test |
||
35 | * @covers ::next |
||
36 | * @covers ::current |
||
37 | * @covers ::key |
||
38 | * @covers ::valid |
||
39 | * @covers ::rewind |
||
40 | * @dataProvider getReaders() |
||
41 | * |
||
42 | * @param Reader $reader The Reader instance to use in the test. |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | public function basicUsage(Reader $reader) |
||
82 | |||
83 | /** |
||
84 | * Data provider for basic usage test |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | public function getReaders() |
||
99 | |||
100 | /** |
||
101 | * Verify parameter checks for $file in __construct(). |
||
102 | * |
||
103 | * @param mixed $file The file parameter to check. |
||
104 | * |
||
105 | * @test |
||
106 | * @covers ::__construct |
||
107 | * @expectedException \InvalidArgumentException |
||
108 | * @expectedExceptionMessage $file must be a string containing a full path to a readable delimited file |
||
109 | * @dataProvider getFiles |
||
110 | * |
||
111 | * @return void |
||
112 | */ |
||
113 | public function constructInvalidFileParam($file) |
||
117 | |||
118 | /** |
||
119 | * Data provider for constructInvalidFileParam() test. |
||
120 | * |
||
121 | * @return array |
||
122 | */ |
||
123 | public function getFiles() |
||
132 | |||
133 | /** |
||
134 | * Verify behavior of __construct with an invalid delimiter. |
||
135 | * |
||
136 | * @test |
||
137 | * @covers ::__construct |
||
138 | * @expectedException \InvalidArgumentException |
||
139 | * @expectedExceptionMessage $delimiter must be a single character string |
||
140 | * |
||
141 | * @return void |
||
142 | */ |
||
143 | public function constructInvalidDelimiter() |
||
147 | |||
148 | /** |
||
149 | * Verify behavior of __construct with an invalid enclosure. |
||
150 | * |
||
151 | * @test |
||
152 | * @covers ::__construct |
||
153 | * @expectedException \InvalidArgumentException |
||
154 | * @expectedExceptionMessage $enclosure must be a single character string |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | public function constructInvalidEnclosure() |
||
162 | |||
163 | /** |
||
164 | * Verify behavior of __construct with an invalid escapeChar. |
||
165 | * |
||
166 | * @test |
||
167 | * @covers ::__construct |
||
168 | * @expectedException \InvalidArgumentException |
||
169 | * @expectedExceptionMessage $escapeChar must be a single character string |
||
170 | * |
||
171 | * @return void |
||
172 | */ |
||
173 | public function constructInvalidEscapeChar() |
||
177 | |||
178 | /** |
||
179 | * Verify behaviour of consecutive rewind(). |
||
180 | * |
||
181 | * @test |
||
182 | * @covers ::rewind |
||
183 | * |
||
184 | * @return void |
||
185 | */ |
||
186 | public function consecutiveRewind() |
||
198 | |||
199 | /** |
||
200 | * Verify basic behaviour of current(). |
||
201 | * |
||
202 | * @test |
||
203 | * @covers ::current |
||
204 | * |
||
205 | * @return void |
||
206 | */ |
||
207 | public function current() |
||
223 | |||
224 | /** |
||
225 | * Verify behavior of Reader with an empty file |
||
226 | * |
||
227 | * @test |
||
228 | * @covers ::next |
||
229 | * @covers ::current |
||
230 | * @covers ::key |
||
231 | * @covers ::valid |
||
232 | * @covers ::rewind |
||
233 | * @dataProvider getEmptyFiles |
||
234 | * |
||
235 | * @param Reader $reader The reader instance to use in the tests. |
||
236 | * |
||
237 | * @return void |
||
238 | */ |
||
239 | public function emptyFiles(Reader $reader) |
||
251 | |||
252 | /** |
||
253 | * Data provider for empty file test. |
||
254 | * |
||
255 | * @return array |
||
256 | */ |
||
257 | public function getEmptyFiles() |
||
266 | } |
||
267 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.