1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\Dev\Tests; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Dev\DebugView; |
6
|
|
|
use SilverStripe\Dev\SapphireTest; |
7
|
|
|
use SilverStripe\Dev\Tests\DebugViewTest\ObjectWithDebug; |
8
|
|
|
|
9
|
|
|
class DebugViewTest 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 DebugView(); |
30
|
|
|
$this->assertEquals( |
31
|
|
|
<<<EOS |
32
|
|
|
<div style="background-color: white; text-align: left;"> |
33
|
|
|
<hr> |
34
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
35
|
|
|
</h3> |
36
|
|
|
<pre style="font-family: Courier new, serif">string</pre> |
37
|
|
|
</div> |
38
|
|
|
EOS |
39
|
|
|
, |
40
|
|
|
$view->debugVariable('string', $this->caller) |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
$this->assertEquals( |
44
|
|
|
<<<EOS |
45
|
|
|
<div style="background-color: white; text-align: left;"> |
46
|
|
|
<hr> |
47
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
48
|
|
|
</h3> |
49
|
|
|
<ul> |
50
|
|
|
<li>key = <pre style="font-family: Courier new, serif">value</pre> |
51
|
|
|
</li> |
52
|
|
|
<li>another = <pre style="font-family: Courier new, serif">text</pre> |
53
|
|
|
</li> |
54
|
|
|
</ul> |
55
|
|
|
</div> |
56
|
|
|
EOS |
57
|
|
|
, |
58
|
|
|
$view->debugVariable([ 'key' => 'value', 'another' => 'text' ], $this->caller) |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
$this->assertEquals( |
62
|
|
|
<<<EOS |
63
|
|
|
<div style="background-color: white; text-align: left;"> |
64
|
|
|
<hr> |
65
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
66
|
|
|
</h3> |
67
|
|
|
SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug::debug() custom content</div> |
68
|
|
|
EOS |
69
|
|
|
, |
70
|
|
|
$view->debugVariable(new ObjectWithDebug(), $this->caller) |
71
|
|
|
); |
72
|
|
|
|
73
|
|
|
$this->assertEquals( |
74
|
|
|
<<<EOS |
75
|
|
|
<div style="background-color: white; text-align: left;"> |
76
|
|
|
<hr> |
77
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span> |
78
|
|
|
</h3> |
79
|
|
|
<pre style="font-family: Courier new, serif">SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug</pre> |
80
|
|
|
</div> |
81
|
|
|
EOS |
82
|
|
|
|
83
|
|
|
, |
84
|
|
|
$view->debugVariable(ObjectWithDebug::class, $this->caller) |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|