Skip to content

Commit

Permalink
Improving Entity::__debugInfo() to better hint what is accessible.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 15, 2015
1 parent a1d97df commit 8977882
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
17 changes: 8 additions & 9 deletions src/Datasource/EntityTrait.php
Expand Up @@ -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
];
}
}
18 changes: 10 additions & 8 deletions tests/TestCase/ORM/EntityTest.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8977882

Please sign in to comment.