本文整理汇总了PHP中CakeTestModel::schema方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeTestModel::schema方法的具体用法?PHP CakeTestModel::schema怎么用?PHP CakeTestModel::schema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeTestModel
的用法示例。
在下文中一共展示了CakeTestModel::schema方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAlterSchema
/**
* Test the alterSchema capabilities of postgres
*
* @return void
*/
public function testAlterSchema()
{
$Old = new CakeSchema(array('connection' => 'test', 'name' => 'AlterPosts', 'alter_posts' => array('id' => array('type' => 'integer', 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => false), 'title' => array('type' => 'string', 'null' => true), 'body' => array('type' => 'text'), 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'))));
$this->Dbo->query($this->Dbo->createSchema($Old));
$New = new CakeSchema(array('connection' => 'test', 'name' => 'AlterPosts', 'alter_posts' => array('id' => array('type' => 'integer', 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => true), 'title' => array('type' => 'string', 'null' => false, 'default' => 'my title'), 'body' => array('type' => 'string', 'length' => 500), 'status' => array('type' => 'integer', 'length' => 3, 'default' => 1), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'))));
$this->Dbo->query($this->Dbo->alterSchema($New->compare($Old), 'alter_posts'));
$model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test'));
$result = $model->schema();
$this->assertTrue(isset($result['status']));
$this->assertFalse(isset($result['published']));
$this->assertEquals('string', $result['body']['type']);
$this->assertEquals(1, $result['status']['default']);
$this->assertEquals(true, $result['author_id']['null']);
$this->assertEquals(false, $result['title']['null']);
$this->Dbo->query($this->Dbo->dropSchema($New));
$New = new CakeSchema(array('connection' => 'test_suite', 'name' => 'AlterPosts', 'alter_posts' => array('id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => false), 'title' => array('type' => 'string', 'null' => true), 'body' => array('type' => 'text'), 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'))));
$result = $this->Dbo->alterSchema($New->compare($Old), 'alter_posts');
$this->assertNotRegExp('/varchar\\(36\\) NOT NULL/i', $result);
}
示例2: testAlterSchema
/**
* Test the alterSchema capabilities of postgres
*
* @access public
* @return void
*/
function testAlterSchema()
{
$Old =& new CakeSchema(array('connection' => 'test_suite', 'name' => 'AlterPosts', 'alter_posts' => array('id' => array('type' => 'integer', 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => false), 'title' => array('type' => 'string', 'null' => false), 'body' => array('type' => 'text'), 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'))));
$this->db->query($this->db->createSchema($Old));
$New =& new CakeSchema(array('connection' => 'test_suite', 'name' => 'AlterPosts', 'alter_posts' => array('id' => array('type' => 'integer', 'key' => 'primary'), 'author_id' => array('type' => 'integer', 'null' => false), 'title' => array('type' => 'string', 'null' => false), 'body' => array('type' => 'string', 'length' => 500), 'status' => array('type' => 'integer', 'length' => 3), 'created' => array('type' => 'datetime'), 'updated' => array('type' => 'datetime'))));
$this->db->query($this->db->alterSchema($New->compare($Old), 'alter_posts'));
$model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test_suite'));
$result = $model->schema();
$this->assertTrue(isset($result['status']));
$this->assertFalse(isset($result['published']));
$this->assertEqual($result['body']['type'], 'string');
$this->db->query($this->db->dropSchema($New));
}