2008-02-24 02:47:10 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id: model.test.php 6441 2008-02-06 15:48:31Z nate $ */
|
|
|
|
/**
|
|
|
|
* Mock models
|
|
|
|
*
|
|
|
|
* Mock classes for use in Model and related test cases
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
|
|
* Copyright 2005-2008, Cake Software Foundation, Inc.
|
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
|
|
|
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
|
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
* @since CakePHP(tm) v 1.2.0.6464
|
|
|
|
* @version $Revision: 6441 $
|
|
|
|
* @modifiedby $LastChangedBy: nate $
|
|
|
|
* @lastmodified $Date: 2008-02-06 10:48:31 -0500 (Wed, 06 Feb 2008) $
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
|
|
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
|
|
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Test extends Model {
|
|
|
|
var $useTable = false;
|
|
|
|
var $name = 'Test';
|
|
|
|
|
|
|
|
var $_schema = array(
|
|
|
|
'id'=> array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
|
|
|
|
'name'=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
|
|
|
'email'=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
|
|
|
'notes'=> array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
|
|
|
|
'created'=> array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
|
|
|
|
'updated'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-05-13 16:42:39 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class TestAlias extends Model {
|
|
|
|
var $useTable = false;
|
|
|
|
var $name = 'TestAlias';
|
|
|
|
var $alias = 'TestAlias';
|
|
|
|
var $_schema = array(
|
|
|
|
'id'=> array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key'=>'primary'),
|
|
|
|
'name'=> array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
|
|
|
'email'=> array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
|
|
|
|
'notes'=> array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''),
|
|
|
|
'created'=> array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
|
|
|
|
'updated'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-02-24 02:47:10 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class TestValidate extends Model {
|
|
|
|
var $useTable = false;
|
|
|
|
var $name = 'TestValidate';
|
|
|
|
|
|
|
|
var $_schema = array(
|
|
|
|
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
|
|
|
|
'title' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
|
|
|
|
'body' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => ''),
|
|
|
|
'number' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
|
|
|
|
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
|
|
|
|
'modified' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
|
|
|
);
|
|
|
|
|
|
|
|
function validateNumber($value, $options) {
|
2008-03-12 21:19:31 +00:00
|
|
|
$options = array_merge(array('min' => 0, 'max' => 100), $options);
|
2008-02-24 02:47:10 +00:00
|
|
|
$valid = ($value['number'] >= $options['min'] && $value['number'] <= $options['max']);
|
|
|
|
return $valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
function validateTitle($value) {
|
|
|
|
return (!empty($value) && strpos(low($value['title']), 'title-') === 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class User extends CakeTestModel {
|
|
|
|
var $name = 'User';
|
|
|
|
var $validate = array('user' => VALID_NOT_EMPTY, 'password' => VALID_NOT_EMPTY);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Article extends CakeTestModel {
|
|
|
|
var $name = 'Article';
|
|
|
|
var $belongsTo = array('User');
|
2008-03-07 01:29:19 +00:00
|
|
|
var $hasMany = array('Comment' => array('dependent' => true));
|
2008-02-24 02:47:10 +00:00
|
|
|
var $hasAndBelongsToMany = array('Tag');
|
|
|
|
var $validate = array('user_id' => VALID_NUMBER, 'title' => array('allowEmpty' => false, 'rule' => VALID_NOT_EMPTY), 'body' => VALID_NOT_EMPTY);
|
2008-05-13 00:39:29 +00:00
|
|
|
var $beforeSaveReturn = true;
|
|
|
|
|
|
|
|
function beforeSave() {
|
|
|
|
return $this->beforeSaveReturn;
|
|
|
|
}
|
2008-02-24 02:47:10 +00:00
|
|
|
|
|
|
|
function titleDuplicate ($title) {
|
|
|
|
if ($title === 'My Article Title') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Article10 extends CakeTestModel {
|
|
|
|
var $name = 'Article10';
|
|
|
|
var $useTable = 'articles';
|
|
|
|
var $hasMany = array('Comment' => array('dependent' => true, 'exclusive' => true));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class ArticleFeatured extends CakeTestModel {
|
|
|
|
var $name = 'ArticleFeatured';
|
|
|
|
var $belongsTo = array('User', 'Category');
|
|
|
|
var $hasOne = array('Featured');
|
2008-03-11 02:44:33 +00:00
|
|
|
var $hasMany = array('Comment' => array('className' => 'Comment', 'dependent' => true));
|
2008-02-24 02:47:10 +00:00
|
|
|
var $hasAndBelongsToMany = array('Tag');
|
|
|
|
var $validate = array('user_id' => VALID_NUMBER, 'title' => VALID_NOT_EMPTY, 'body' => VALID_NOT_EMPTY);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Featured extends CakeTestModel {
|
|
|
|
var $name = 'Featured';
|
2008-03-11 02:44:33 +00:00
|
|
|
var $belongsTo = array('ArticleFeatured', 'Category');
|
2008-02-24 02:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Tag extends CakeTestModel {
|
|
|
|
var $name = 'Tag';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class ArticlesTag extends CakeTestModel {
|
|
|
|
var $name = 'ArticlesTag';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class ArticleFeaturedsTag extends CakeTestModel {
|
|
|
|
var $name = 'ArticleFeaturedsTag';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Comment extends CakeTestModel {
|
|
|
|
var $name = 'Comment';
|
|
|
|
var $belongsTo = array('Article', 'User');
|
2008-03-07 01:29:19 +00:00
|
|
|
var $hasOne = array('Attachment' => array('dependent' => true));
|
2008-02-24 02:47:10 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Attachment extends CakeTestModel {
|
|
|
|
var $name = 'Attachment';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Category extends CakeTestModel {
|
|
|
|
var $name = 'Category';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class CategoryThread extends CakeTestModel {
|
|
|
|
var $name = 'CategoryThread';
|
|
|
|
var $belongsTo = array('ParentCategory' => array('className' => 'CategoryThread', 'foreignKey' => 'parent_id'));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Apple extends CakeTestModel {
|
|
|
|
var $name = 'Apple';
|
|
|
|
var $validate = array('name' => VALID_NOT_EMPTY);
|
|
|
|
var $hasOne = array('Sample');
|
|
|
|
var $hasMany = array('Child' => array('className' => 'Apple', 'dependent' => true));
|
|
|
|
var $belongsTo = array('Parent' => array('className' => 'Apple', 'foreignKey' => 'apple_id'));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Sample extends CakeTestModel {
|
|
|
|
var $name = 'Sample';
|
|
|
|
var $belongsTo = 'Apple';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class AnotherArticle extends CakeTestModel {
|
|
|
|
var $name = 'AnotherArticle';
|
|
|
|
var $hasMany = 'Home';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Advertisement extends CakeTestModel {
|
|
|
|
var $name = 'Advertisement';
|
|
|
|
var $hasMany = 'Home';
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Home extends CakeTestModel {
|
|
|
|
var $name = 'Home';
|
|
|
|
var $belongsTo = array('AnotherArticle', 'Advertisement');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Post extends CakeTestModel {
|
|
|
|
var $name = 'Post';
|
|
|
|
var $belongsTo = array('Author');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Author extends CakeTestModel {
|
|
|
|
var $name = 'Author';
|
|
|
|
var $hasMany = array('Post');
|
|
|
|
|
|
|
|
function afterFind($results) {
|
|
|
|
$results[0]['Author']['test'] = 'working';
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
}
|
2008-04-17 22:30:25 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class ModifiedAuthor extends Author {
|
|
|
|
var $name = 'Author';
|
|
|
|
|
|
|
|
function afterFind($results) {
|
|
|
|
foreach($results as $index => $result) {
|
|
|
|
$results[$index]['Author']['user'] .= ' (CakePHP)';
|
|
|
|
}
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
}
|
2008-02-24 02:47:10 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Project extends CakeTestModel {
|
|
|
|
var $name = 'Project';
|
|
|
|
var $hasMany = array('Thread');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Thread extends CakeTestModel {
|
|
|
|
var $name = 'Thread';
|
|
|
|
var $hasMany = array('Message');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Message extends CakeTestModel {
|
|
|
|
var $name = 'Message';
|
|
|
|
var $hasOne = array('Bid');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Bid extends CakeTestModel {
|
|
|
|
var $name = 'Bid';
|
|
|
|
var $belongsTo = array('Message');
|
|
|
|
}
|
|
|
|
class NodeAfterFind extends CakeTestModel {
|
|
|
|
var $name = 'NodeAfterFind';
|
|
|
|
var $validate = array('name' => VALID_NOT_EMPTY);
|
|
|
|
var $useTable = 'apples';
|
|
|
|
var $hasOne = array('Sample' => array('className' => 'NodeAfterFindSample'));
|
|
|
|
var $hasMany = array('Child' => array('className' => 'NodeAfterFind', 'dependent' => true));
|
|
|
|
var $belongsTo = array('Parent' => array('className' => 'NodeAfterFind', 'foreignKey' => 'apple_id'));
|
|
|
|
|
|
|
|
function afterFind($results) {
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class NodeAfterFindSample extends CakeTestModel {
|
|
|
|
var $name = 'NodeAfterFindSample';
|
|
|
|
var $useTable = 'samples';
|
|
|
|
var $belongsTo = 'NodeAfterFind';
|
|
|
|
}
|
|
|
|
class NodeNoAfterFind extends CakeTestModel {
|
|
|
|
var $name = 'NodeAfterFind';
|
|
|
|
var $validate = array('name' => VALID_NOT_EMPTY);
|
|
|
|
var $useTable = 'apples';
|
|
|
|
var $hasOne = array('Sample' => array('className' => 'NodeAfterFindSample'));
|
2008-03-11 02:44:33 +00:00
|
|
|
var $hasMany = array('Child' => array('className' => 'NodeAfterFind', 'dependent' => true));
|
2008-02-24 02:47:10 +00:00
|
|
|
var $belongsTo = array('Parent' => array('className' => 'NodeAfterFind', 'foreignKey' => 'apple_id'));
|
|
|
|
}
|
2008-05-15 03:16:36 +00:00
|
|
|
class Node extends CakeTestModel{
|
|
|
|
var $name = 'Node';
|
|
|
|
var $hasAndBelongsToMany = array(
|
|
|
|
'ParentNode' => array(
|
|
|
|
'className' => 'Node',
|
|
|
|
'joinTable' => 'dependency',
|
|
|
|
'foreignKey' => 'child_id',
|
|
|
|
'associationForeignKey' => 'parent_id',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
class Dependency extends CakeTestModel{
|
|
|
|
var $name = 'Dependency';
|
|
|
|
}
|
2008-02-24 02:47:10 +00:00
|
|
|
class ModelA extends CakeTestModel {
|
|
|
|
var $name = 'ModelA';
|
|
|
|
var $useTable = 'apples';
|
|
|
|
var $hasMany = array('ModelB', 'ModelC');
|
|
|
|
}
|
|
|
|
class ModelB extends CakeTestModel {
|
|
|
|
var $name = 'ModelB';
|
|
|
|
var $useTable = 'messages';
|
|
|
|
var $hasMany = array('ModelD');
|
|
|
|
}
|
|
|
|
class ModelC extends CakeTestModel {
|
|
|
|
var $name = 'ModelC';
|
|
|
|
var $useTable = 'bids';
|
|
|
|
var $hasMany = array('ModelD');
|
|
|
|
}
|
|
|
|
class ModelD extends CakeTestModel {
|
|
|
|
var $name = 'ModelD';
|
|
|
|
var $useTable = 'threads';
|
|
|
|
}
|
|
|
|
class Something extends CakeTestModel {
|
|
|
|
var $name = 'Something';
|
|
|
|
var $hasAndBelongsToMany = array('SomethingElse' => array('with' => array('JoinThing' => array('doomed'))));
|
|
|
|
}
|
|
|
|
class SomethingElse extends CakeTestModel {
|
|
|
|
var $name = 'SomethingElse';
|
|
|
|
var $hasAndBelongsToMany = array('Something' => array('with' => 'JoinThing'));
|
|
|
|
}
|
|
|
|
class JoinThing extends CakeTestModel {
|
|
|
|
var $name = 'JoinThing';
|
|
|
|
var $belongsTo = array('Something', 'SomethingElse');
|
|
|
|
}
|
|
|
|
class Portfolio extends CakeTestModel {
|
|
|
|
var $name = 'Portfolio';
|
|
|
|
var $hasAndBelongsToMany = array('Item');
|
|
|
|
}
|
|
|
|
class Item extends CakeTestModel {
|
|
|
|
var $name = 'Item';
|
|
|
|
var $belongsTo = array('Syfile' => array('counterCache' => true));
|
|
|
|
var $hasAndBelongsToMany = array('Portfolio');
|
|
|
|
}
|
|
|
|
class ItemsPortfolio extends CakeTestModel {
|
|
|
|
var $name = 'ItemsPortfolio';
|
|
|
|
}
|
|
|
|
class Syfile extends CakeTestModel {
|
|
|
|
var $name = 'Syfile';
|
|
|
|
var $belongsTo = array('Image');
|
|
|
|
}
|
|
|
|
class Image extends CakeTestModel {
|
|
|
|
var $name = 'Image';
|
|
|
|
}
|
|
|
|
class DeviceType extends CakeTestModel {
|
|
|
|
var $name = 'DeviceType';
|
|
|
|
var $order = array('DeviceType.order' => 'ASC');
|
|
|
|
var $belongsTo = array(
|
|
|
|
'DeviceTypeCategory', 'FeatureSet', 'ExteriorTypeCategory',
|
|
|
|
'Image' => array('className' => 'Document'),
|
|
|
|
'Extra1' => array('className' => 'Document'),
|
|
|
|
'Extra2' => array('className' => 'Document'));
|
|
|
|
var $hasMany = array('Device' => array('order' => array('Device.id' => 'ASC')));
|
|
|
|
}
|
|
|
|
class DeviceTypeCategory extends CakeTestModel {
|
|
|
|
var $name = 'DeviceTypeCategory';
|
|
|
|
}
|
|
|
|
class FeatureSet extends CakeTestModel {
|
|
|
|
var $name = 'FeatureSet';
|
|
|
|
}
|
|
|
|
class ExteriorTypeCategory extends CakeTestModel {
|
|
|
|
var $name = 'ExteriorTypeCategory';
|
|
|
|
var $belongsTo = array('Image' => array('className' => 'Device'));
|
|
|
|
}
|
|
|
|
class Document extends CakeTestModel {
|
|
|
|
var $name = 'Document';
|
|
|
|
var $belongsTo = array('DocumentDirectory');
|
|
|
|
}
|
|
|
|
class Device extends CakeTestModel {
|
|
|
|
var $name = 'Device';
|
|
|
|
}
|
|
|
|
class DocumentDirectory extends CakeTestModel {
|
|
|
|
var $name = 'DocumentDirectory';
|
|
|
|
}
|
|
|
|
class PrimaryModel extends CakeTestModel {
|
|
|
|
var $name = 'PrimaryModel';
|
|
|
|
}
|
|
|
|
class SecondaryModel extends CakeTestModel {
|
|
|
|
var $name = 'SecondaryModel';
|
|
|
|
}
|
|
|
|
class JoinA extends CakeTestModel {
|
|
|
|
var $name = 'JoinA';
|
|
|
|
var $hasAndBelongsToMany = array('JoinB', 'JoinC');
|
|
|
|
}
|
|
|
|
class JoinB extends CakeTestModel {
|
|
|
|
var $name = 'JoinB';
|
|
|
|
var $hasAndBelongsToMany = array('JoinA');
|
|
|
|
}
|
|
|
|
class JoinC extends CakeTestModel {
|
|
|
|
var $name = 'JoinC';
|
|
|
|
var $hasAndBelongsToMany = array('JoinA');
|
|
|
|
}
|
2008-03-11 02:44:33 +00:00
|
|
|
class ThePaper extends CakeTestModel {
|
|
|
|
var $name = 'ThePaper';
|
|
|
|
var $useTable = 'apples';
|
|
|
|
var $hasOne = array('Itself' => array('className' => 'ThePaper', 'foreignKey' => 'apple_id'));
|
2008-03-15 05:08:06 +00:00
|
|
|
var $hasAndBelongsToMany = array('Monkey' => array('joinTable' => 'the_paper_monkies'));
|
|
|
|
}
|
|
|
|
class Monkey extends CakeTestModel {
|
|
|
|
var $name = 'Monkey';
|
|
|
|
var $useTable = 'devices';
|
2008-03-11 02:44:33 +00:00
|
|
|
}
|
2008-02-24 02:47:10 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class AssociationTest1 extends CakeTestModel {
|
|
|
|
var $useTable = 'join_as';
|
|
|
|
var $name = 'AssociationTest1';
|
|
|
|
|
|
|
|
var $hasAndBelongsToMany = array('AssociationTest2' => array(
|
|
|
|
'unique' => false, 'joinTable' => 'join_as_join_bs', 'foreignKey' => false
|
|
|
|
));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class AssociationTest2 extends CakeTestModel {
|
|
|
|
var $useTable = 'join_bs';
|
|
|
|
var $name = 'AssociationTest2';
|
|
|
|
|
|
|
|
var $hasAndBelongsToMany = array('AssociationTest1' => array(
|
|
|
|
'unique' => false, 'joinTable' => 'join_as_join_bs'
|
|
|
|
));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Callback extends CakeTestModel {
|
2008-03-26 11:17:24 +00:00
|
|
|
|
2008-02-26 06:20:16 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class Uuid extends CakeTestModel {
|
|
|
|
var $name = 'Uuid';
|
2008-02-24 02:47:10 +00:00
|
|
|
}
|
2008-03-13 03:11:29 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class DataTest extends CakeTestModel {
|
|
|
|
var $name = 'DataTest';
|
|
|
|
}
|
2008-02-24 02:47:10 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
2008-02-28 04:35:20 +00:00
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class TheVoid extends CakeTestModel {
|
|
|
|
var $name = 'TheVoid';
|
|
|
|
var $useTable = false;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
2008-02-24 02:47:10 +00:00
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class ValidationTest extends CakeTestModel {
|
|
|
|
var $name = 'ValidationTest';
|
|
|
|
var $useTable = false;
|
|
|
|
var $_schema = array();
|
|
|
|
|
|
|
|
var $validate = array(
|
|
|
|
'title' => VALID_NOT_EMPTY,
|
|
|
|
'published' => 'customValidationMethod',
|
|
|
|
'body' => array(
|
|
|
|
VALID_NOT_EMPTY,
|
|
|
|
'/^.{5,}$/s' => 'no matchy',
|
|
|
|
'/^[0-9A-Za-z \\.]{1,}$/s'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
function customValidationMethod($data) {
|
|
|
|
return $data === 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
|
|
|
class ValidationTest2 extends CakeTestModel {
|
|
|
|
var $name = 'ValidationTest2';
|
|
|
|
var $useTable = false;
|
|
|
|
|
|
|
|
var $validate = array(
|
|
|
|
'title' => VALID_NOT_EMPTY,
|
|
|
|
'published' => 'customValidationMethod',
|
|
|
|
'body' => array(
|
|
|
|
VALID_NOT_EMPTY,
|
|
|
|
'/^.{5,}$/s' => 'no matchy',
|
|
|
|
'/^[0-9A-Za-z \\.]{1,}$/s'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
function customValidationMethod($data) {
|
|
|
|
return $data === 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function schema() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
}
|
2008-03-26 11:17:24 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.model
|
|
|
|
*/
|
2008-03-30 03:59:38 +00:00
|
|
|
class Person extends CakeTestModel {
|
2008-03-26 11:17:24 +00:00
|
|
|
var $name = 'Person';
|
|
|
|
var $belongsTo = array(
|
|
|
|
'Mother' => array(
|
|
|
|
'className' => 'Person',
|
|
|
|
'foreignKey' => 'mother_id'),
|
|
|
|
'Father' => array(
|
|
|
|
'className' => 'Person',
|
|
|
|
'foreignKey' => 'father_id'));
|
|
|
|
}
|
2008-05-11 20:07:04 +00:00
|
|
|
|
|
|
|
class UnderscoreField extends CakeTestModel {
|
|
|
|
var $name = 'UnderscoreField';
|
|
|
|
}
|
2008-02-24 02:47:10 +00:00
|
|
|
?>
|