Adding schema introspection tests to Model

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6726 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-04-26 14:39:34 +00:00
parent 3f0b8217ec
commit b0568e7ace

View file

@ -3649,6 +3649,27 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($this->Comment->displayField, 'id'); $this->assertEqual($this->Comment->displayField, 'id');
} }
function testSchema() {
$this->Post = new Post();
$result = $this->Post->schema();
$columns = array('id', 'author_id', 'title', 'body', 'published', 'created', 'updated');
$this->assertEqual(array_keys($result), $columns);
$types = array('integer', 'integer', 'string', 'text', 'string', 'datetime', 'datetime');
$this->assertEqual(Set::extract(array_values($result), '{n}.type'), $types);
$this->expectError('(Model::loadInfo) Deprecated - See Model::schema()');
$result = $this->Post->loadInfo();
$this->assertEqual($result->extract("{n}.name"), $columns);
$this->assertEqual($result->extract('{n}.type'), $types);
$result = $this->Post->schema('body');
$this->assertEqual($result['type'], 'text');
$this->assertNull($this->Post->schema('foo'));
$this->assertEqual($this->Post->getColumnTypes(), array_combine($columns, $types));
}
function testOldQuery() { function testOldQuery() {
$this->loadFixtures('Article'); $this->loadFixtures('Article');