当前位置: 首页>>代码示例>>PHP>>正文


PHP CakeTestModel::schema方法代码示例

本文整理汇总了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);
 }
开发者ID:jeffersongoncalves,项目名称:estudos,代码行数:24,代码来源:PostgresTest.php

示例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));
 }
开发者ID:jerzzz777,项目名称:cake-cart,代码行数:19,代码来源:dbo_postgres.test.php


注:本文中的CakeTestModel::schema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。