mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
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:
parent
3f0b8217ec
commit
b0568e7ace
1 changed files with 21 additions and 0 deletions
|
@ -3649,6 +3649,27 @@ class ModelTest extends CakeTestCase {
|
|||
$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() {
|
||||
$this->loadFixtures('Article');
|
||||
|
|
Loading…
Add table
Reference in a new issue