pictcode / lib / Cake / TestSuite / Fixture / CakeTestModel.php @ 40928d1c
履歴 | 表示 | アノテート | ダウンロード (2.052 KB)
| 1 | 635eef61 | spyder1211 | <?php
|
|---|---|---|---|
| 2 | /**
|
||
| 3 | * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
||
| 4 | * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
| 5 | *
|
||
| 6 | * Licensed under The MIT License
|
||
| 7 | * For full copyright and license information, please see the LICENSE.txt
|
||
| 8 | * Redistributions of files must retain the above copyright notice
|
||
| 9 | *
|
||
| 10 | * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
| 11 | * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
|
||
| 12 | * @package Cake.TestSuite.Fixture
|
||
| 13 | * @since CakePHP(tm) v 1.2.0.4667
|
||
| 14 | * @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||
| 15 | */
|
||
| 16 | |||
| 17 | App::uses('Model', 'Model'); |
||
| 18 | |||
| 19 | /**
|
||
| 20 | * A model to extend from to help you during testing.
|
||
| 21 | *
|
||
| 22 | * @package Cake.TestSuite.Fixture
|
||
| 23 | */
|
||
| 24 | class CakeTestModel extends Model { |
||
| 25 | |||
| 26 | public $useDbConfig = 'test'; |
||
| 27 | |||
| 28 | public $cacheSources = false; |
||
| 29 | |||
| 30 | /**
|
||
| 31 | * Sets default order for the model to avoid failing tests caused by
|
||
| 32 | * incorrect order when no order has been defined in the finds.
|
||
| 33 | * Postgres can return the results in any order it considers appropriate if none is specified
|
||
| 34 | *
|
||
| 35 | * @param int|string|array $id Set this ID for this model on startup, can also be an array of options, see above.
|
||
| 36 | * @param string $table Name of database table to use.
|
||
| 37 | * @param string $ds DataSource connection name.
|
||
| 38 | */
|
||
| 39 | public function __construct($id = false, $table = null, $ds = null) { |
||
| 40 | parent::__construct($id, $table, $ds); |
||
| 41 | $this->order = array($this->alias . '.' . $this->primaryKey => 'ASC'); |
||
| 42 | } |
||
| 43 | |||
| 44 | /**
|
||
| 45 | * Overriding save() to set CakeTestSuiteDispatcher::date() as formatter for created, modified and updated fields
|
||
| 46 | *
|
||
| 47 | * @param array $data Data to save
|
||
| 48 | * @param bool|array $validate Validate or options.
|
||
| 49 | * @param array $fieldList Whitelist of fields
|
||
| 50 | * @return mixed
|
||
| 51 | */
|
||
| 52 | public function save($data = null, $validate = true, $fieldList = array()) { |
||
| 53 | $db = $this->getDataSource(); |
||
| 54 | $db->columns['datetime']['formatter'] = 'CakeTestSuiteDispatcher::date'; |
||
| 55 | return parent::save($data, $validate, $fieldList); |
||
| 56 | } |
||
| 57 | |||
| 58 | } |