Merge pull request #7828 from open-sausages/pulls/4.0/fix-debug-string-class

BUG Fix issue with DebugView failing on class name of existing class
This commit is contained in:
Robbie Averill 2018-02-05 12:08:58 +13:00 committed by GitHub
commit 209635b467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View File

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

View File

@ -31,7 +31,7 @@ class DebugViewTest extends SapphireTest
<<<EOS <<<EOS
<div style="background-color: white; text-align: left;"> <div style="background-color: white; text-align: left;">
<hr> <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> </h3>
<pre style="font-family: Courier new, serif">string</pre> <pre style="font-family: Courier new, serif">string</pre>
</div> </div>
@ -44,7 +44,7 @@ EOS
<<<EOS <<<EOS
<div style="background-color: white; text-align: left;"> <div style="background-color: white; text-align: left;">
<hr> <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> </h3>
<ul> <ul>
<li>key = <pre style="font-family: Courier new, serif">value</pre> <li>key = <pre style="font-family: Courier new, serif">value</pre>
@ -62,12 +62,26 @@ EOS
<<<EOS <<<EOS
<div style="background-color: white; text-align: left;"> <div style="background-color: white; text-align: left;">
<hr> <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> </h3>
SilverStripe\Dev\Tests\DebugViewTest\ObjectWithDebug::debug() custom content</div> SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug::debug() custom content</div>
EOS EOS
, ,
$view->debugVariable(new ObjectWithDebug(), $this->caller) $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)
);
} }
} }