當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CakeTestModel類代碼示例

本文整理匯總了PHP中CakeTestModel的典型用法代碼示例。如果您正苦於以下問題:PHP CakeTestModel類的具體用法?PHP CakeTestModel怎麽用?PHP CakeTestModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CakeTestModel類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testExplainQuery

 /**
  * test that explain query returns arrays of query information.
  *
  * @return void
  */
 public function testExplainQuery()
 {
     $Post = new CakeTestModel(array('table' => 'posts', 'alias' => 'Post'));
     $db = $Post->getDataSource();
     $sql = 'SELECT * FROM ' . $db->fullTableName('posts') . ';';
     $result = $this->Model->explainQuery($Post->useDbConfig, $sql);
     $this->assertTrue(is_array($result));
     $this->assertFalse(empty($result));
 }
開發者ID:hupla78,項目名稱:Nadia,代碼行數:14,代碼來源:ToolbarAccessTest.php

示例2: 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

示例3: testGetQueryLogs

 /**
  * ensure that getQueryLogs works and writes to the cache so the history panel will
  * work.
  *
  * @return void
  */
 public function testGetQueryLogs()
 {
     $model = new CakeTestModel(array('table' => 'posts', 'alias' => 'Post'));
     $model->find('all');
     $model->find('first');
     $result = $this->Toolbar->getQueryLogs($model->useDbConfig, array('cache' => false));
     $this->assertTrue(is_array($result));
     $this->assertTrue(count($result) >= 2, 'Should be more than 2 queries in the log %s');
     $this->assertTrue(isset($result['queries'][0]['actions']));
     $model->find('first');
     Cache::delete('debug_kit_toolbar_test_case', 'default');
     $result = $this->Toolbar->getQueryLogs($model->useDbConfig, array('cache' => true));
     $cached = $this->Toolbar->readCache('sql_log');
     $this->assertTrue(isset($cached[$model->useDbConfig]));
     $this->assertEquals($cached[$model->useDbConfig]['queries'][0], $result['queries'][0]);
 }
開發者ID:pritten,項目名稱:SmartCitizen.me,代碼行數:22,代碼來源:ToolbarHelperTest.php

示例4: 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

示例5: testBlobSaving

 /**
  * test saving and retrieval of blobs
  *
  * @return void
  */
 public function testBlobSaving()
 {
     $this->loadFixtures('BinaryTest');
     $this->Dbo->cacheSources = false;
     $data = file_get_contents(CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif');
     $model = new CakeTestModel(array('name' => 'BinaryTest', 'ds' => 'test'));
     $model->save(compact('data'));
     $result = $model->find('first');
     $this->assertEquals($data, $result['BinaryTest']['data']);
 }
開發者ID:laiello,項目名稱:double-l-bookmanagement,代碼行數:15,代碼來源:MysqlTest.php

示例6: testBlobSaving

 /**
  * test saving and retrieval of blobs
  *
  * @return void
  */
 public function testBlobSaving()
 {
     $this->loadFixtures('BinaryTest');
     $this->Dbo->cacheSources = false;
     $data = "GIF87ab\n\t\tÒ4A¿¿¿ˇˇˇ,b\n\t\t¢îè©ÀÌ#¥⁄ã≥fi:¯Ü‚Héá¶jV∂ÓúÎL≥çÀóËıÎ…>ï≈ vFE%ÒâLFI<†µw˝±≈£7˘ç^H“≤«\f>Éâ*∑ÇnÖA•Ù|flêèj£:=ÿ6óUàµ5'∂®àA¬ñ∆ˆGE(gt’≈àÚyÁó«7\t‚VìöÇ√˙Ç™\n\t\tk”:;kÀAõ{*¡€Î˚˚[;;";
     $model = new CakeTestModel(array('name' => 'BinaryTest', 'ds' => 'test'));
     $model->save(compact('data'));
     $result = $model->find('first');
     $this->assertEqual($result['BinaryTest']['data'], $data);
 }
開發者ID:Nervie,項目名稱:Beta,代碼行數:15,代碼來源:MysqlTest.php

示例7: find

 public function find($conditions = null, $fields = array(), $order = null, $recursive = null)
 {
     if ($this->throwException) {
         throw new Exception('Model tried to query database.');
     }
     return parent::find($conditions, $fields, $order, $recursive);
 }
開發者ID:kouno,項目名稱:EnumerableBehavior,代碼行數:7,代碼來源:enumerable_cache.test.php

示例8: find

 function find($command, $options = array())
 {
     if ($command == 'last') {
         $options = am(array('order' => 'id DESC'), $options);
         return parent::find('first', $options);
     } else {
         return parent::find($command, $options);
     }
 }
開發者ID:vuthaiphat,項目名稱:CakePHP-Assets,代碼行數:9,代碼來源:logable.test.php

示例9: find

 /**
  * find method
  *
  * @param mixed $type
  * @param array $options
  * @return void
  */
 public function find($conditions = null, $fields = array(), $order = null, $recursive = null)
 {
     if ($conditions === 'popular') {
         $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1');
         $options = Hash::merge($fields, compact('conditions'));
         return parent::find('all', $options);
     }
     return parent::find($conditions, $fields);
 }
開發者ID:saihe,項目名稱:reservation,代碼行數:16,代碼來源:PaginatorComponentTest.php

示例10: find

 /**
  * find method
  *
  * @param mixed $type
  * @param array $options
  * @access public
  * @return void
  */
 function find($type, $options = array())
 {
     if ($type == 'popular') {
         $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1');
         $options = Set::merge($options, compact('conditions'));
         return parent::find('all', $options);
     }
     return parent::find($type, $options);
 }
開發者ID:acerato,項目名稱:cntcetp,代碼行數:17,代碼來源:controller.test.php

示例11: beforeValidate

 public function beforeValidate($options = array())
 {
     parent::beforeValidate($options);
     $this->setValidationPatterns();
 }
開發者ID:k1low,項目名稱:yav,代碼行數:5,代碼來源:AdditionalValidationPatternsTest.php


注:本文中的CakeTestModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。