Skip to content
Permalink
Browse files

Improving Entity::__debugInfo() to better hint what is accessible.

  • Loading branch information...
lorenzo committed May 15, 2015
1 parent a1d97df commit 89778823fbe04b8b346f4b5b4bf299b1b0b4c89d
Showing with 18 additions and 17 deletions.
  1. +8 −9 src/Datasource/EntityTrait.php
  2. +10 −8 tests/TestCase/ORM/EntityTest.php
@@ -885,15 +885,14 @@ public function __toString()
*/
public function __debugInfo()
{
return [
'new' => $this->isNew(),
'accessible' => array_filter($this->_accessible),
'properties' => $this->_properties,
'dirty' => $this->_dirty,
'original' => $this->_original,
'virtual' => $this->_virtual,
'errors' => $this->_errors,
'repository' => $this->_registryAlias
return $this->_properties + [
'[new]' => $this->isNew(),
'[accessible]' => array_filter($this->_accessible),
'[dirty]' => $this->_dirty,
'[original]' => $this->_original,
'[virtual]' => $this->_virtual,
'[errors]' => $this->_errors,
'[repository]' => $this->_registryAlias
];
}
}
@@ -1163,21 +1163,23 @@ public function testToString()
public function testDebugInfo()
{
$entity = new Entity(['foo' => 'bar'], ['markClean' => true]);
$entity->somethingElse = 'value';
$entity->accessible('name', true);
$entity->virtualProperties(['baz']);
$entity->dirty('foo', true);
$entity->errors('foo', ['An error']);
$entity->source('foos');
$result = $entity->__debugInfo();
$expected = [
'new' => true,
'accessible' => ['*' => true, 'name' => true],
'properties' => ['foo' => 'bar'],
'dirty' => ['foo' => true],
'original' => [],
'virtual' => ['baz'],
'errors' => ['foo' => ['An error']],
'repository' => 'foos'
'foo' => 'bar',
'somethingElse' => 'value',
'[new]' => true,
'[accessible]' => ['*' => true, 'name' => true],
'[dirty]' => ['somethingElse' => true, 'foo' => true],
'[original]' => [],
'[virtual]' => ['baz'],
'[errors]' => ['foo' => ['An error']],
'[repository]' => 'foos'
];
$this->assertSame($expected, $result);
}

0 comments on commit 8977882

Please sign in to comment.
You can’t perform that action at this time.