2016-12-23 03:41:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Dev\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\DebugView;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\Dev\Tests\DebugViewTest\ObjectWithDebug;
|
|
|
|
|
|
|
|
class DebugViewTest extends SapphireTest
|
|
|
|
{
|
|
|
|
protected $caller = null;
|
|
|
|
|
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->caller = [
|
|
|
|
'line' => 17,
|
|
|
|
'file' => __FILE__,
|
|
|
|
'args' => [],
|
|
|
|
'type' => '->',
|
|
|
|
'class' => __CLASS__,
|
|
|
|
'function' => __FUNCTION__,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDebugVariable()
|
|
|
|
{
|
|
|
|
$view = new DebugView();
|
|
|
|
$this->assertEquals(
|
|
|
|
<<<EOS
|
|
|
|
<div style="background-color: white; text-align: left;">
|
|
|
|
<hr>
|
2018-02-04 22:45:49 +01:00
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span>
|
2016-12-23 03:41:41 +01:00
|
|
|
</h3>
|
|
|
|
<pre style="font-family: Courier new, serif">string</pre>
|
|
|
|
</div>
|
|
|
|
EOS
|
|
|
|
,
|
|
|
|
$view->debugVariable('string', $this->caller)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
<<<EOS
|
|
|
|
<div style="background-color: white; text-align: left;">
|
|
|
|
<hr>
|
2018-02-04 22:45:49 +01:00
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span>
|
2016-12-23 03:41:41 +01:00
|
|
|
</h3>
|
|
|
|
<ul>
|
|
|
|
<li>key = <pre style="font-family: Courier new, serif">value</pre>
|
|
|
|
</li>
|
|
|
|
<li>another = <pre style="font-family: Courier new, serif">text</pre>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
EOS
|
|
|
|
,
|
|
|
|
$view->debugVariable([ 'key' => 'value', 'another' => 'text' ], $this->caller)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
<<<EOS
|
|
|
|
<div style="background-color: white; text-align: left;">
|
|
|
|
<hr>
|
2018-02-04 22:45:49 +01:00
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span>
|
2016-12-23 03:41:41 +01:00
|
|
|
</h3>
|
2018-02-04 22:45:49 +01:00
|
|
|
SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug::debug() custom content</div>
|
2016-12-23 03:41:41 +01:00
|
|
|
EOS
|
|
|
|
,
|
|
|
|
$view->debugVariable(new ObjectWithDebug(), $this->caller)
|
|
|
|
);
|
2018-02-04 22:45:49 +01:00
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
<<<EOS
|
|
|
|
<div style="background-color: white; text-align: left;">
|
|
|
|
<hr>
|
|
|
|
<h3>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span>
|
|
|
|
</h3>
|
|
|
|
<pre style="font-family: Courier new, serif">SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug</pre>
|
|
|
|
</div>
|
|
|
|
EOS
|
|
|
|
|
|
|
|
,
|
|
|
|
$view->debugVariable(ObjectWithDebug::class, $this->caller)
|
|
|
|
);
|
2016-12-23 03:41:41 +01:00
|
|
|
}
|
|
|
|
}
|