Browse Source

Merge pull request #11734 from cakephp/feature/v-fields

Add virtual fields into __debugInfo() output.
Mark Story 8 years ago
parent
commit
f2d42a5aeb
2 changed files with 7 additions and 1 deletions
  1. 6 1
      src/Datasource/EntityTrait.php
  2. 1 0
      tests/TestCase/ORM/EntityTest.php

+ 6 - 1
src/Datasource/EntityTrait.php

@@ -1303,7 +1303,12 @@ trait EntityTrait
      */
     public function __debugInfo()
     {
-        return $this->_properties + [
+        $properties = $this->_properties;
+        foreach ($this->_virtual as $field) {
+            $properties[$field] = $this->$field;
+        }
+
+        return $properties + [
             '[new]' => $this->isNew(),
             '[accessible]' => $this->_accessible,
             '[dirty]' => $this->_dirty,

+ 1 - 0
tests/TestCase/ORM/EntityTest.php

@@ -1506,6 +1506,7 @@ class EntityTest extends TestCase
         $expected = [
             'foo' => 'bar',
             'somethingElse' => 'value',
+            'baz' => null,
             '[new]' => true,
             '[accessible]' => ['*' => true, 'id' => false, 'name' => true],
             '[dirty]' => ['somethingElse' => true, 'foo' => true],