Passed
Push — main ( 22ee9f...77fae7 )
by Peter
02:53
created

ExceptionRendererTest::createRunMock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Debug\Exceptions\Handlers\Whoops;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use Whoops\RunInterface;
10
11
class ExceptionRendererTest extends TestCase
12
{
13
    public function testGetRunGetsRun()
14
    {
15
        $runMock = $this->createRunMock();
16
17
        $sut = new ExceptionRenderer($runMock, true);
18
19
        $actualResult = $sut->getRun();
20
21
        $this->assertSame($runMock, $actualResult);
22
    }
23
24
    public function testRenderCallsHandleException()
25
    {
26
        $isDevelopmentEnvironment = true;
27
28
        $exceptionStub = new \Exception();
29
30
        $runMock = $this->createRunMock();
31
32
        $runMock->expects($this->atLeastOnce())->method('handleException')->with($exceptionStub);
33
34
        $sut = new ExceptionRenderer($runMock, $isDevelopmentEnvironment);
35
36
        $sut->render($exceptionStub);
37
    }
38
39
    public function testRenderInProduction()
40
    {
41
        $isDevelopmentEnvironment = false;
42
43
        $exceptionStub = new \Exception();
44
45
        $runMock = $this->createRunMock();
46
47
        $runMock->expects($this->never())->method('handleException');
48
49
        $sut = new ExceptionRenderer($runMock, $isDevelopmentEnvironment);
50
51
        $sut->render($exceptionStub);
52
    }
53
54
    /**
55
     * @return MockObject|RunInterface
56
     */
57
    protected function createRunMock()
58
    {
59
        $mock = $this->createMock(RunInterface::class);
60
61
        return $mock;
62
    }
63
}
64