Code Duplication    Length = 55-55 lines in 2 locations

tests/CoverageCheckTest.php 2 locations

@@ 124-178 (lines=55) @@
121
        $this->assertEquals($expected, $lines);
122
    }
123
124
    public function testAddingAllUnknownsCovered()
125
    {
126
        $diffFileState = $this->createMock(DiffFileLoader::class);
127
        $diffFileState->method('getChangedLines')
128
            ->willReturn([
129
                'testFile1.php' => [1,2,3,4],
130
                'testFile2.php' => [3,4],
131
132
            ]);
133
134
        $xmlReport = $this->createMock(XMLReport::class);
135
        $xmlReport->method('getLines')
136
            ->willReturn([
137
                '/full/path/to/testFile1.php' => [1 => 1,2 => 0,3 => 1,4 => 1],
138
139
            ]);
140
141
        $xmlReport->method('handleNotFoundFile')
142
            ->willReturn(true);
143
144
        $xmlReport->method('isValidLine')
145
            ->will(
146
                $this->returnCallback(
147
                    function () {
148
                        $file = func_get_arg(0);
149
                        $line = func_get_arg(1);
150
151
                        if ($file == '/full/path/to/testFile1.php' && $line == 2) {
152
                            return false;
153
                        }
154
155
                        return true;
156
                    }
157
                )
158
            );
159
160
        $matcher = new FileMatchers\EndsWith;
161
        $coverageCheck = new CoverageCheck($diffFileState, $xmlReport, $matcher);
162
        $lines = $coverageCheck->getCoveredLines();
163
164
        $uncoveredLines = [
165
            'testFile1.php' => [2 => 0],
166
        ];
167
        $coveredLines = [
168
            'testFile1.php' => [1,3,4],
169
            'testFile2.php' => [3,4],
170
        ];
171
172
        $expected = [
173
            'coveredLines' => $coveredLines,
174
            'uncoveredLines' => $uncoveredLines,
175
        ];
176
177
        $this->assertEquals($expected, $lines);
178
    }
179
180
    public function testAddingAllUnknownsUnCovered()
181
    {
@@ 180-234 (lines=55) @@
177
        $this->assertEquals($expected, $lines);
178
    }
179
180
    public function testAddingAllUnknownsUnCovered()
181
    {
182
        $diffFileState = $this->createMock(DiffFileLoader::class);
183
        $diffFileState->method('getChangedLines')
184
            ->willReturn([
185
                'testFile1.php' => [1,2,3,4],
186
                'testFile2.php' => [3,4],
187
188
            ]);
189
190
        $xmlReport = $this->createMock(XMLReport::class);
191
        $xmlReport->method('getLines')
192
            ->willReturn([
193
                '/full/path/to/testFile1.php' => [1 => 1,2 => 0,3 => 1,4 => 1],
194
195
            ]);
196
197
        $xmlReport->method('handleNotFoundFile')
198
            ->willReturn(false);
199
200
        $xmlReport->method('isValidLine')
201
            ->will(
202
                $this->returnCallback(
203
                    function () {
204
                        $file = func_get_arg(0);
205
                        $line = func_get_arg(1);
206
207
                        if ($file == '/full/path/to/testFile1.php' && $line == 2) {
208
                            return false;
209
                        }
210
211
                        return true;
212
                    }
213
                )
214
            );
215
216
        $matcher = new FileMatchers\EndsWith;
217
        $coverageCheck = new CoverageCheck($diffFileState, $xmlReport, $matcher);
218
        $lines = $coverageCheck->getCoveredLines();
219
220
        $uncoveredLines = [
221
            'testFile1.php' => [2 => 0],
222
            'testFile2.php' => [3 => 0, 4 => 0],
223
        ];
224
        $coveredLines = [
225
            'testFile1.php' => [1,3,4],
226
        ];
227
228
        $expected = [
229
            'coveredLines' => $coveredLines,
230
            'uncoveredLines' => $uncoveredLines,
231
        ];
232
233
        $this->assertEquals($expected, $lines);
234
    }
235
}
236