From 288aaf083ceff944402b2877880130a54bd04a95 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 5 Feb 2018 10:45:49 +1300 Subject: [PATCH] BUG Fix issue with DebugView failing on class name of existing class Fixes #7827 --- src/Dev/DebugView.php | 2 +- tests/php/Dev/DebugViewTest.php | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Dev/DebugView.php b/src/Dev/DebugView.php index b08586c8c..24200bf8e 100644 --- a/src/Dev/DebugView.php +++ b/src/Dev/DebugView.php @@ -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(); } diff --git a/tests/php/Dev/DebugViewTest.php b/tests/php/Dev/DebugViewTest.php index e9d296c39..edafe8bff 100644 --- a/tests/php/Dev/DebugViewTest.php +++ b/tests/php/Dev/DebugViewTest.php @@ -31,7 +31,7 @@ class DebugViewTest extends SapphireTest <<
-

Debug (DebugViewTest.php:17 - SilverStripe\Dev\Tests\DebugViewTest::setUp()) +

Debug (DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())

string
@@ -44,7 +44,7 @@ EOS <<
-

Debug (DebugViewTest.php:17 - SilverStripe\Dev\Tests\DebugViewTest::setUp()) +

Debug (DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())

  • key =
    value
    @@ -62,12 +62,26 @@ EOS <<
    -

    Debug (DebugViewTest.php:17 - SilverStripe\Dev\Tests\DebugViewTest::setUp()) +

    Debug (DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp())

    -SilverStripe\Dev\Tests\DebugViewTest\ObjectWithDebug::debug() custom content +SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug::debug() custom content EOS , $view->debugVariable(new ObjectWithDebug(), $this->caller) ); + + $this->assertEquals( + << +
    +

    Debug (DebugViewTest.php:17 - SilverStripe\\Dev\\Tests\\DebugViewTest::setUp()) +

    +
    SilverStripe\\Dev\\Tests\\DebugViewTest\\ObjectWithDebug
    + +EOS + + , + $view->debugVariable(ObjectWithDebug::class, $this->caller) + ); } }