當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。