Skip to content
Permalink
Browse files

Adding __debugInfo to EntityTrait

  • Loading branch information...
lorenzo committed Mar 8, 2014
1 parent f7b0912 commit a081d33f32d378db91d7e8795258e358a4eae0c1
Showing with 38 additions and 0 deletions.
  1. +17 −0 src/Datasource/EntityTrait.php
  2. +21 −0 tests/TestCase/ORM/EntityTest.php
@@ -671,4 +671,21 @@ public function __toString() {
return json_encode($this, JSON_PRETTY_PRINT);
}
/**
* Returns an array that can be used to describe the internal estate of this
* object.
*
* @return array
*/
public function __debugInfo() {
return [
'new' => $this->isNew(),
'accessible' => array_filter($this->_accessible),
'properties' => $this->_properties,
'dirty' => $this->_dirty,
'virtual' => $this->_virtual,
'errors' => $this->_errors
];
}
}
@@ -996,4 +996,25 @@ public function testToString() {
$this->assertEquals(json_encode($entity, JSON_PRETTY_PRINT), (string)$entity);
}
/**
* Tests __debugInfo
*
* @return void
*/
public function testDebugInfo() {
$entity = new Entity(['foo' => 'bar'], ['markClean' => true]);
$entity->accessible('name', true);
$entity->virtualProperties(['baz']);
$entity->errors('foo', ['An error']);
$result = $entity->__debugInfo();
$expected = [
'new' => true,
'accessible' => ['name'],
'properties' => ['foo' => 'bar'],
'dirty' => ['foo' => true],
'virtual' => ['baz'],
'errors' => ['foo' => ['An error']]
];
}
}

0 comments on commit a081d33

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