Added some tests for related models afterFind callback

This commit is contained in:
k-halaburda 2013-08-13 09:29:14 +02:00
parent 3855c0690e
commit 8e40a3a3d3
7 changed files with 14407 additions and 14009 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
<?php <?php
/** /**
* ModelTest file * ModelTest file
* *
@ -17,7 +18,6 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
App::uses('Model', 'Model'); App::uses('Model', 'Model');
App::uses('AppModel', 'Model'); App::uses('AppModel', 'Model');
require_once dirname(__FILE__) . DS . 'models.php'; require_once dirname(__FILE__) . DS . 'models.php';
@ -29,69 +29,71 @@ require_once dirname(__FILE__) . DS . 'models.php';
*/ */
abstract class BaseModelTest extends CakeTestCase { abstract class BaseModelTest extends CakeTestCase {
/** /**
* autoFixtures property * autoFixtures property
* *
* @var bool false * @var bool false
*/ */
public $autoFixtures = false; public $autoFixtures = false;
/** /**
* Whether backup global state for each test method or not * Whether backup global state for each test method or not
* *
* @var bool false * @var bool false
*/ */
public $backupGlobals = false; public $backupGlobals = false;
/** /**
* fixtures property * fixtures property
* *
* @var array * @var array
*/ */
public $fixtures = array( public $fixtures = array(
'core.category', 'core.category_thread', 'core.user', 'core.my_category', 'core.my_product', 'core.category', 'core.category_thread', 'core.user', 'core.my_category', 'core.my_product',
'core.my_user', 'core.my_categories_my_users', 'core.my_categories_my_products', 'core.my_user', 'core.my_categories_my_users', 'core.my_categories_my_products',
'core.article', 'core.featured', 'core.article_featureds_tags', 'core.article_featured', 'core.article', 'core.featured', 'core.article_featureds_tags', 'core.article_featured',
'core.numeric_article', 'core.tag', 'core.articles_tag', 'core.comment', 'core.numeric_article', 'core.tag', 'core.articles_tag', 'core.comment',
'core.attachment', 'core.apple', 'core.sample', 'core.another_article', 'core.item', 'core.attachment', 'core.apple', 'core.sample', 'core.another_article', 'core.item',
'core.advertisement', 'core.home', 'core.post', 'core.author', 'core.bid', 'core.portfolio', 'core.advertisement', 'core.home', 'core.post', 'core.author', 'core.bid', 'core.portfolio',
'core.product', 'core.project', 'core.thread', 'core.message', 'core.items_portfolio', 'core.product', 'core.project', 'core.thread', 'core.message', 'core.items_portfolio',
'core.syfile', 'core.image', 'core.device_type', 'core.device_type_category', 'core.syfile', 'core.image', 'core.device_type', 'core.device_type_category',
'core.feature_set', 'core.exterior_type_category', 'core.document', 'core.device', 'core.feature_set', 'core.exterior_type_category', 'core.document', 'core.device',
'core.document_directory', 'core.primary_model', 'core.secondary_model', 'core.something', 'core.document_directory', 'core.primary_model', 'core.secondary_model', 'core.something',
'core.something_else', 'core.join_thing', 'core.join_a', 'core.join_b', 'core.join_c', 'core.something_else', 'core.join_thing', 'core.join_a', 'core.join_b', 'core.join_c',
'core.join_a_b', 'core.join_a_c', 'core.uuid', 'core.data_test', 'core.posts_tag', 'core.join_a_b', 'core.join_a_c', 'core.uuid', 'core.data_test', 'core.posts_tag',
'core.the_paper_monkies', 'core.person', 'core.underscore_field', 'core.node', 'core.the_paper_monkies', 'core.person', 'core.underscore_field', 'core.node',
'core.dependency', 'core.story', 'core.stories_tag', 'core.cd', 'core.book', 'core.basket', 'core.dependency', 'core.story', 'core.stories_tag', 'core.cd', 'core.book', 'core.basket',
'core.overall_favorite', 'core.account', 'core.content', 'core.content_account', 'core.overall_favorite', 'core.account', 'core.content', 'core.content_account',
'core.film_file', 'core.test_plugin_article', 'core.test_plugin_comment', 'core.uuiditem', 'core.film_file', 'core.test_plugin_article', 'core.test_plugin_comment', 'core.uuiditem',
'core.counter_cache_user', 'core.counter_cache_post', 'core.counter_cache_user', 'core.counter_cache_post',
'core.counter_cache_user_nonstandard_primary_key', 'core.counter_cache_user_nonstandard_primary_key',
'core.counter_cache_post_nonstandard_primary_key', 'core.uuidportfolio', 'core.counter_cache_post_nonstandard_primary_key', 'core.uuidportfolio',
'core.uuiditems_uuidportfolio', 'core.uuiditems_uuidportfolio_numericid', 'core.fruit', 'core.uuiditems_uuidportfolio', 'core.uuiditems_uuidportfolio_numericid', 'core.fruit',
'core.fruits_uuid_tag', 'core.uuid_tag', 'core.product_update_all', 'core.group_update_all', 'core.fruits_uuid_tag', 'core.uuid_tag', 'core.product_update_all', 'core.group_update_all',
'core.player', 'core.guild', 'core.guilds_player', 'core.armor', 'core.armors_player', 'core.player', 'core.guild', 'core.guilds_player', 'core.armor', 'core.armors_player',
'core.bidding', 'core.bidding_message', 'core.site', 'core.domain', 'core.domains_site', 'core.bidding', 'core.bidding_message', 'core.site', 'core.domain', 'core.domains_site',
); 'core.model_with_relations','core.model_related','core.model_habtm_relation',
);
/** /**
* setUp method * setUp method
* *
* @return void * @return void
*/ */
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->debug = Configure::read('debug'); $this->debug = Configure::read('debug');
} }
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
parent::tearDown();
Configure::write('debug', $this->debug);
ClassRegistry::flush();
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
parent::tearDown();
Configure::write('debug', $this->debug);
ClassRegistry::flush();
}
} }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
<?php
/**
* Short description for file.
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Fixture
* @since CakePHP(tm) v 1.2.0.4667
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Class PrimaryRelatedFixture
*
* @package Cake.Test.Fixture
*/
class ModelHabtmRelationFixture extends CakeTestFixture {
/**
* fields property
*
* @var array
*/
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'primary_id' => array('type' => 'integer'),
'related_id' => array('type' => 'integer'),
);
/**
* records property
*
* @var array
*/
public $records = array(
array('id' => 1, 'primary_id' => 1, 'related_id' => 1),
array('id' => 2, 'primary_id' => 1, 'related_id' => 2),
array('id' => 3, 'primary_id' => 2, 'related_id' => 1),
array('id' => 4, 'primary_id' => 2, 'related_id' => 2),
);
}

View file

@ -0,0 +1,50 @@
<?php
/**
* Short description for file.
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Fixture
* @since CakePHP(tm) v 1.2.0.4667
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Class RelatedFixture
*
* @package Cake.Test.Fixture
*/
class ModelRelatedFixture extends CakeTestFixture {
/**
* fields property
*
* @var array
*/
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'name' => array('type' => 'string'),
'primary_id' => array('type' => 'integer'),
);
/**
* records property
*
* @var array
*/
public $records = array(
array('id' => 1, 'name' => 'This should change on afterFind', 'primary_id' => 1),
array('id' => 2, 'name' => 'This also should change on afterFind', 'primary_id' => 2)
);
}

View file

@ -0,0 +1,50 @@
<?php
/**
* Short description for file.
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Fixture
* @since CakePHP(tm) v 1.2.0.4667
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Class PrimaryFixture
*
* @package Cake.Test.Fixture
*/
class ModelWithRelationsFixture extends CakeTestFixture {
/**
* fields property
*
* @var array
*/
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'name' => array('type' => 'string'),
'related_id' => array('type' => 'integer'),
);
/**
* records property
*
* @var array
*/
public $records = array(
array('id' => 1, 'name' => 'First record', 'related_id' => 1),
array('id' => 2, 'name' => 'Second record', 'related_id' => 2)
);
}