Code Duplication    Length = 19-28 lines in 3 locations

tests/Unit/Parser/JSON/LogParserTest.php 1 location

@@ 48-66 (lines=19) @@
45
        $parser->onProcessTerminated(new ProcessEvent($process));
46
    }
47
48
    public function testParseHandlesMissingLogs()
49
    {
50
        $process = new StubbedParaunitProcess();
51
        $process->setOutput('Test output (core dumped)');
52
        $process->setExitCode(139);
53
        $parser1 = $this->prophesize(ParserChainElementInterface::class);
54
        $parser1->handleLogItem($process, Argument::cetera())
55
            ->shouldBeCalledTimes(1)
56
            ->willReturn($this->mockTestResult());
57
        $parser2 = $this->prophesize(ParserChainElementInterface::class);
58
        $parser2->handleLogItem($process, Argument::cetera())
59
            ->shouldNotBeCalled();
60
61
        $parser = $this->createParser(false);
62
        $parser->addParser($parser1->reveal());
63
        $parser->addParser($parser2->reveal());
64
65
        $parser->onProcessTerminated(new ProcessEvent($process));
66
    }
67
68
    public function testParseHandlesNoTestExecuted()
69
    {

tests/Unit/Runner/RunnerTest.php 2 locations

@@ 74-101 (lines=28) @@
71
        $this->assertSame(0, $runner->run());
72
    }
73
74
    public function testOnProcessParsingCompletedWithFailedProcess()
75
    {
76
        $process = new StubbedParaunitProcess();
77
        $process->setIsToBeRetried(false);
78
        $process->setExitCode(1);
79
80
        $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
81
        $eventDispatcher->dispatch(Argument::cetera())
82
            ->shouldNotBeCalled();
83
84
        $filter = $this->prophesize(Filter::class);
85
        $filter->filterTestFiles()
86
            ->willReturn([]);
87
        $pipelineCollection = $this->prophesize(PipelineCollection::class);
88
        $pipelineCollection->push($process)
89
            ->shouldNotBeCalled();
90
91
        $runner = new Runner(
92
            $eventDispatcher->reveal(),
93
            $this->mockProcessFactory(),
94
            $filter->reveal(),
95
            $pipelineCollection->reveal()
96
        );
97
98
        $runner->onProcessParsingCompleted(new ProcessEvent($process));
99
100
        $this->assertAttributeNotSame(0, 'exitCode', $runner);
101
    }
102
103
    public function testOnProcessToBeRetried()
104
    {
@@ 103-130 (lines=28) @@
100
        $this->assertAttributeNotSame(0, 'exitCode', $runner);
101
    }
102
103
    public function testOnProcessToBeRetried()
104
    {
105
        $process = new StubbedParaunitProcess();
106
        $process->setIsToBeRetried(true);
107
        $process->setExitCode(1);
108
109
        $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
110
        $eventDispatcher->dispatch(Argument::cetera())
111
            ->shouldNotBeCalled();
112
113
        $filter = $this->prophesize(Filter::class);
114
        $filter->filterTestFiles()
115
            ->willReturn([]);
116
        $pipelineCollection = $this->prophesize(PipelineCollection::class);
117
        $pipelineCollection->push($process)
118
            ->shouldNotBeCalled();
119
120
        $runner = new Runner(
121
            $eventDispatcher->reveal(),
122
            $this->mockProcessFactory(),
123
            $filter->reveal(),
124
            $pipelineCollection->reveal()
125
        );
126
127
        $runner->onProcessToBeRetried(new ProcessEvent($process));
128
129
        $this->assertAttributeSame(0, 'exitCode', $runner);
130
    }
131
132
    private function mockEventDispatcher(): EventDispatcherInterface
133
    {