Passed
Branch stable (668427)
by Nuno
04:13 queued 01:26
created

WritesExceptionDetailsTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 52
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\Feature;
4
5
use PHPUnit\Framework\TestCase;
6
7
class WritesExceptionDetailsTest extends TestCase
8
{
9
    use FakeFailTrait;
10
11
    /** @test */
12
    public function it_renders_the_title(): void
13
    {
14
        $result = $this->fakeFail();
15
16
        $this->assertContains('Tests\Feature\FakeProgram\FakeException  : Fail description', $result);
17
    }
18
19
    /** @test */
20
    public function it_renders_the_editor(): void
21
    {
22
        $result = $this->fakeFail();
23
24
        $dir = __DIR__;
25
26
        $expectedResult = <<<EOF
27
  at $dir/FakeProgram/HelloWorldFile3.php: 9
28
  5: class HelloWorldFile3
29
  6: {
30
  7:     public static function say()
31
  8:     {
32
  9:         throw new FakeException('Fail description');
33
  10:     }
34
  11: }
35
EOF;
36
37
        $this->assertContains($expectedResult, $result);
38
    }
39
40
    /** @test */
41
    public function it_writes_the_trace_without_details(): void
42
    {
43
        $result = $this->fakeFail(false);
44
        $dir = __DIR__;
45
46
        $expectedResult = <<<EOF
47
  Exception trace:
48
49
  1   Tests\Feature\FakeProgram\HelloWorldFile3::say()
50
      $dir/FakeProgram/HelloWorldFile2.php : 9
51
52
  2   Tests\Feature\FakeProgram\HelloWorldFile2::say()
53
      $dir/FakeProgram/HelloWorldFile1.php : 9
54
55
  Please use the argument -v to see more details.
56
EOF;
57
58
        $this->assertContains($expectedResult, $result);
59
    }
60
}
61