BUG Fix issue with DebugView failing on class name of existing class

Fixes #7827
This commit is contained in:
Damian Mooyman 2018-02-05 10:45:49 +13:00
parent b81ac41b5d
commit 288aaf083c
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
2 changed files with 19 additions and 5 deletions

View File

@ -421,7 +421,7 @@ class DebugView
public function debugVariableText($val)
{
// Check debug
if (ClassInfo::hasMethod($val, 'debug')) {
if (is_object($val) && ClassInfo::hasMethod($val, 'debug')) {
return $val->debug();
}

View File

@ -31,7 +31,7 @@ class DebugViewTest extends SapphireTest
<<<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>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span>
</h3>
<pre style="font-family: Courier new, serif">string</pre>
</div>
@ -44,7 +44,7 @@ EOS
<<<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>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span>
</h3>
<ul>
<li>key = <pre style="font-family: Courier new, serif">value</pre>
@ -62,12 +62,26 @@ EOS
<<<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>Debug <span style="font-size: 65%">(DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())</span>
</h3>
SilverStripe\Dev\Tests\DebugViewTest\ObjectWithDebug::debug() custom content</div>
SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug::debug() custom content</div>
EOS
,
$view->debugVariable(new ObjectWithDebug(), $this->caller)
);
$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)
);
}
}