Skip to content

Commit

Permalink
Added __debugInfo to Table
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Mar 8, 2014
1 parent 70d6956 commit 881098f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/ORM/Table.php
Expand Up @@ -1739,4 +1739,23 @@ public function implementedEvents() {
return $events;
}

/**
* Returns an array that can be used to describe the internal state of this
* object.
*
* @return array
*/
public function __debugInfo() {
$conn = $this->connection();
return [
'table' => $this->table(),
'alias' => $this->alias(),
'entityClass' => $this->entityClass(),
'associated' => $this->_associated->keys(),
'behaviors' => $this->_behaviors->loaded(),
'defaultConnection' => $this->defaultConnectionName(),
'connectionName' => $conn ? $conn->configName() : null
];
}

}
21 changes: 21 additions & 0 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -3243,4 +3243,25 @@ public function testPatchEntities() {
$table->patchEntities($entities, $data);
}

/**
* Tests __debugInfo
*
* @return void
*/
public function testDebugInfo() {
$articles = TableRegistry::get('articles');
$articles->addBehavior('Timestamp');
$result = $articles->__debugInfo();
$expected = [
'table' => 'articles',
'alias' => 'articles',
'entityClass' => 'TestApp\Model\Entity\Article',
'associated' => ['authors', 'tags', 'articlestags'],
'behaviors' => ['Timestamp'],
'defaultConnection' => 'default',
'connectionName' => 'test'
];
$this->assertEquals($expected, $result);
}

}

0 comments on commit 881098f

Please sign in to comment.