Code Duplication    Length = 24-24 lines in 2 locations

tests/Unit/Coverage/CoverageFetcherTest.php 2 locations

@@ 20-43 (lines=24) @@
17
 */
18
class CoverageFetcherTest extends BaseUnitTestCase
19
{
20
    public function testFetch()
21
    {
22
        $process = new StubbedParaunitProcess('test.php', 'uniqueId');
23
24
        $filename = $this->getTempFilename();
25
        copy($this->getCoverageStubFilePath(), $filename);
26
        $this->assertFileExists($filename, 'Test malformed, stub log file not found');
27
28
        $tempFilenameFactory = $this->prophesize(TempFilenameFactory::class);
29
        $tempFilenameFactory->getFilenameForCoverage('uniqueId')
30
            ->shouldBeCalled()
31
            ->willReturn($filename);
32
        $missingCoverageContainer = $this->prophesize(TestResultHandlerInterface::class);
33
        $missingCoverageContainer->addProcessToFilenames($process)
34
            ->shouldNotBeCalled();
35
36
        $fetcher = new CoverageFetcher($tempFilenameFactory->reveal(), $missingCoverageContainer->reveal());
37
38
        $result = $fetcher->fetch($process);
39
40
        $this->assertInstanceOf(CodeCoverage::class, $result);
41
        $this->assertNotEmpty($result->getData());
42
        $this->assertFileNotExists($filename, 'Coverage file should be deleted to preserve memory');
43
    }
44
45
    public function testFetchIgnoresMissingCoverageFiles()
46
    {
@@ 65-88 (lines=24) @@
62
        $this->assertEmpty($result->getData());
63
    }
64
65
    public function testFetchIgnoresWrongFiles()
66
    {
67
        $process = new StubbedParaunitProcess('test.php', 'uniqueId');
68
69
        $filename = $this->getTempFilename();
70
        copy($this->getWrongCoverageStubFilePath(), $filename);
71
        $this->assertFileExists($filename, 'Test malformed, stub log file not found');
72
73
        $tempFilenameFactory = $this->prophesize(TempFilenameFactory::class);
74
        $tempFilenameFactory->getFilenameForCoverage('uniqueId')
75
            ->shouldBeCalled()
76
            ->willReturn($filename);
77
        $missingCoverageContainer = $this->prophesize(TestResultHandlerInterface::class);
78
        $missingCoverageContainer->addProcessToFilenames($process)
79
            ->shouldBeCalled();
80
81
        $fetcher = new CoverageFetcher($tempFilenameFactory->reveal(), $missingCoverageContainer->reveal());
82
83
        $result = $fetcher->fetch($process);
84
85
        $this->assertInstanceOf(CodeCoverage::class, $result);
86
        $this->assertEmpty($result->getData());
87
        $this->assertFileNotExists($filename, 'Coverage file should be deleted to preserve memory');
88
    }
89
90
    private function getTempFilename(): string
91
    {