Skip to content
Permalink
Browse files

Update tests for table override.

Make sure Table objects can override the default table value.
  • Loading branch information...
markstory committed Jun 15, 2013
1 parent 4e8f20e commit 470452527c56aa295d74794164e2f5e83806e2b1
Showing with 17 additions and 5 deletions.
  1. +0 −1 lib/Cake/ORM/Table.php
  2. +17 −4 lib/Cake/Test/TestCase/ORM/TableTest.php
@@ -314,7 +314,6 @@ public function association($name) {
if (isset($this->_associations[$name])) {
return $this->_associations[$name];
}
return null;
}
@@ -22,7 +22,6 @@
/**
* Used to test correct class is instantiated when using Table::build();
*
*/
class UsersTable extends Table {
@@ -31,7 +30,21 @@ class UsersTable extends Table {
*
* @var string
*/
public $_table = 'users';
protected $_table = 'users';
}
/**
* Used to test correct class is instantiated when using Table::build();
*/
class MyUsersTable extends Table {
/**
* Overrides default table name
*
* @var string
*/
protected $_table = 'users';
}
@@ -83,8 +96,8 @@ public function testConfigAndBuild() {
$this->assertEmpty(Table::config());
Table::config('users', $options);
$table = Table::build('foo', ['className' => __NAMESPACE__ . '\UsersTable']);
$this->assertInstanceOf(__NAMESPACE__ . '\UsersTable', $table);
$table = Table::build('foo', ['className' => __NAMESPACE__ . '\MyUsersTable']);
$this->assertInstanceOf(__NAMESPACE__ . '\MyUsersTable', $table);
$this->assertEquals('users', $table->table());
$this->assertEquals('foo', $table->alias());
$this->assertSame($this->connection, $table->connection());

0 comments on commit 4704525

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