2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2017-06-10 22:15:34 +00:00
|
|
|
* CakePHP(tm) Tests <https://book.cakephp.org/2.0/en/development/testing.html>
|
2017-06-10 22:10:52 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2010-10-03 16:31:21 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2017-06-10 22:10:52 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 22:15:34 +00:00
|
|
|
* @link https://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.TestSuite.Fixture
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0.4667
|
2017-06-10 22:23:14 +00:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2010-12-08 06:19:36 +00:00
|
|
|
|
|
|
|
App::uses('Model', 'Model');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2011-12-08 15:35:02 +00:00
|
|
|
* A model to extend from to help you during testing.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.TestSuite.Fixture
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class CakeTestModel extends Model {
|
2012-03-05 02:51:44 +00:00
|
|
|
|
2010-09-20 02:41:31 +00:00
|
|
|
public $useDbConfig = 'test';
|
2012-03-05 02:51:44 +00:00
|
|
|
|
2010-04-04 07:14:00 +00:00
|
|
|
public $cacheSources = false;
|
2011-11-22 20:50:17 +00:00
|
|
|
|
|
|
|
/**
|
2011-11-24 21:12:39 +00:00
|
|
|
* Sets default order for the model to avoid failing tests caused by
|
2011-11-22 20:50:17 +00:00
|
|
|
* incorrect order when no order has been defined in the finds.
|
|
|
|
* Postgres can return the results in any order it considers appropriate if none is specified
|
|
|
|
*
|
2014-07-03 13:36:42 +00:00
|
|
|
* @param int|string|array $id Set this ID for this model on startup, can also be an array of options, see above.
|
2013-07-19 20:31:09 +00:00
|
|
|
* @param string $table Name of database table to use.
|
|
|
|
* @param string $ds DataSource connection name.
|
2011-11-22 20:50:17 +00:00
|
|
|
*/
|
2013-07-19 20:31:09 +00:00
|
|
|
public function __construct($id = false, $table = null, $ds = null) {
|
|
|
|
parent::__construct($id, $table, $ds);
|
|
|
|
$this->order = array($this->alias . '.' . $this->primaryKey => 'ASC');
|
2011-11-22 20:50:17 +00:00
|
|
|
}
|
2013-07-19 20:31:09 +00:00
|
|
|
|
2012-03-28 15:49:41 +00:00
|
|
|
/**
|
|
|
|
* Overriding save() to set CakeTestSuiteDispatcher::date() as formatter for created, modified and updated fields
|
|
|
|
*
|
2014-06-05 04:19:27 +00:00
|
|
|
* @param array $data Data to save
|
2014-07-03 13:36:42 +00:00
|
|
|
* @param bool|array $validate Validate or options.
|
2014-06-05 04:19:27 +00:00
|
|
|
* @param array $fieldList Whitelist of fields
|
|
|
|
* @return mixed
|
2012-03-28 15:49:41 +00:00
|
|
|
*/
|
|
|
|
public function save($data = null, $validate = true, $fieldList = array()) {
|
|
|
|
$db = $this->getDataSource();
|
|
|
|
$db->columns['datetime']['formatter'] = 'CakeTestSuiteDispatcher::date';
|
|
|
|
return parent::save($data, $validate, $fieldList);
|
|
|
|
}
|
2011-11-22 20:50:17 +00:00
|
|
|
|
2012-12-05 14:00:24 +00:00
|
|
|
}
|