CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • CakeFixtureManager
  • CakeTestFixture
  • CakeTestModel
 1: <?php
 2: /**
 3:  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
 4:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 5:  *
 6:  * Licensed under The MIT License
 7:  * Redistributions of files must retain the above copyright notice
 8:  *
 9:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
10:  * @link          http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
11:  * @package       Cake.TestSuite.Fixture
12:  * @since         CakePHP(tm) v 1.2.0.4667
13:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
14:  */
15: 
16: App::uses('Model', 'Model');
17: 
18: /**
19:  * A model to extend from to help you during testing.
20:  *
21:  * @package       Cake.TestSuite.Fixture
22:  */
23: class CakeTestModel extends Model {
24: 
25:     public $useDbConfig = 'test';
26: 
27:     public $cacheSources = false;
28: 
29: /**
30:  * Sets default order for the model to avoid failing tests caused by
31:  * incorrect order when no order has been defined in the finds.
32:  * Postgres can return the results in any order it considers appropriate if none is specified
33:  *
34:  * @param array $queryData
35:  * @return array $queryData
36:  */
37:     public function beforeFind($queryData) {
38:         $pk = $this->primaryKey;
39:         $aliasedPk = $this->alias . '.' . $this->primaryKey;
40:         switch (true) {
41:             case !$pk:
42:             case !$this->useTable:
43:             case !$this->schema('id'):
44:             case !empty($queryData['order'][0]):
45:             case !empty($queryData['group']):
46:             case
47:                 (is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) ||
48:                 (is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))):
49:             break;
50:             default:
51:                 $queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC');
52:             break;
53:         }
54:         return $queryData;
55:     }
56: /**
57:  * Overriding save() to set CakeTestSuiteDispatcher::date() as formatter for created, modified and updated fields
58:  *
59:  * @param array $data
60:  * @param boolean|array $validate
61:  * @param array $fieldList
62:  */
63: 
64:     public function save($data = null, $validate = true, $fieldList = array()) {
65:         $db = $this->getDataSource();
66:         $db->columns['datetime']['formatter'] = 'CakeTestSuiteDispatcher::date';
67:         return parent::save($data, $validate, $fieldList);
68:     }
69: 
70: }
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs