Passed
Push — 4.1 ( dd3fbf...7ec5fa )
by Daniel
11:01
created

CLIDebugViewTest::testDebugVariable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 47
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 21
nc 1
nop 0
dl 0
loc 47
rs 9.0303
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Dev\Tests;
4
5
use SilverStripe\Dev\CliDebugView;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Dev\Tests\DebugViewTest\ObjectWithDebug;
8
9
class CLIDebugViewTest extends SapphireTest
10
{
11
    protected $caller = null;
12
13
    protected function setUp()
14
    {
15
        parent::setUp();
16
17
        $this->caller = [
18
            'line' => 17,
19
            'file' => __FILE__,
20
            'args' => [],
21
            'type' => '->',
22
            'class' => __CLASS__,
23
            'function' => __FUNCTION__,
24
        ];
25
    }
26
27
    public function testDebugVariable()
28
    {
29
        $view = new CliDebugView();
30
        $this->assertEquals(
31
            <<<EOS
32
Debug (CLIDebugViewTest.php:17 - SilverStripe\Dev\Tests\CLIDebugViewTest::setUp())
33
string
34
35
36
EOS
37
            ,
38
            $view->debugVariable('string', $this->caller)
39
        );
40
41
        $this->assertEquals(
42
            <<<EOS
43
Debug (CLIDebugViewTest.php:17 - SilverStripe\Dev\Tests\CLIDebugViewTest::setUp())
44
key = value
45
another = text
46
47
48
49
EOS
50
            ,
51
            $view->debugVariable([ 'key' => 'value', 'another' => 'text' ], $this->caller)
52
        );
53
54
        $this->assertEquals(
55
            <<<EOS
56
Debug (CLIDebugViewTest.php:17 - SilverStripe\Dev\Tests\CLIDebugViewTest::setUp())
57
SilverStripe\Dev\Tests\DebugViewTest\ObjectWithDebug::debug() custom content
58
59
60
EOS
61
            ,
62
            $view->debugVariable(new ObjectWithDebug(), $this->caller)
63
        );
64
65
        $this->assertEquals(
66
            <<<EOS
67
Debug (CLIDebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\CLIDebugViewTest::setUp())
68
SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug
69
70
71
EOS
72
            ,
73
            $view->debugVariable(ObjectWithDebug::class, $this->caller)
74
        );
75
    }
76
}
77