本文整理汇总了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;未经允许,请勿转载。 |
请发表评论