mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding new test case to show failing inner associations
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5542 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
44e978c194
commit
f2d4894f73
5 changed files with 306 additions and 1 deletions
|
@ -31,6 +31,11 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
}
|
}
|
||||||
uses('model'.DS.'model', 'model'.DS.'datasources'.DS.'datasource', 'model'.DS.'datasources'.DS.'dbo_source',
|
uses('model'.DS.'model', 'model'.DS.'datasources'.DS.'datasource', 'model'.DS.'datasources'.DS.'dbo_source',
|
||||||
'model'.DS.'datasources'.DS.'dbo'.DS.'dbo_mysql');
|
'model'.DS.'datasources'.DS.'dbo'.DS.'dbo_mysql');
|
||||||
|
|
||||||
|
if (!class_exists('AppModel')) {
|
||||||
|
loadModel();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -299,6 +304,46 @@ class Author extends CakeTestModel {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 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');
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -310,7 +355,8 @@ class ModelTest extends CakeTestCase {
|
||||||
var $fixtures = array(
|
var $fixtures = array(
|
||||||
'core.category', 'core.category_thread', 'core.user', 'core.article', 'core.featured', 'core.article_featureds_tags',
|
'core.category', 'core.category_thread', 'core.user', 'core.article', 'core.featured', 'core.article_featureds_tags',
|
||||||
'core.article_featured', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment',
|
'core.article_featured', 'core.tag', 'core.articles_tag', 'core.comment', 'core.attachment',
|
||||||
'core.apple', 'core.sample', 'core.another_article', 'core.advertisement', 'core.home', 'core.post', 'core.author'
|
'core.apple', 'core.sample', 'core.another_article', 'core.advertisement', 'core.home', 'core.post', 'core.author',
|
||||||
|
'core.project', 'core.thread', 'core.message', 'core.bid'
|
||||||
);
|
);
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
|
@ -324,6 +370,72 @@ class ModelTest extends CakeTestCase {
|
||||||
Configure::write('debug', $this->debug);
|
Configure::write('debug', $this->debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testHasManyOptimization() {
|
||||||
|
$this->Project =& new Project();
|
||||||
|
|
||||||
|
$this->Project->recursive = 3;
|
||||||
|
$result = $this->Project->findAll();
|
||||||
|
$expected = array(
|
||||||
|
array(
|
||||||
|
'Project' => array(
|
||||||
|
'id' => 1, 'name' => 'Project 1'
|
||||||
|
),
|
||||||
|
'Thread' => array(
|
||||||
|
array(
|
||||||
|
'id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1',
|
||||||
|
'Message' => array(
|
||||||
|
array(
|
||||||
|
'id' => 1, 'thread' => 1, 'name' => 'Thread 1, Message 1',
|
||||||
|
'Bid' => array(
|
||||||
|
'id' => 1, 'message_id' => 1, 'name' => 'Bid 1.1'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 2, 'project_id' => 1, 'name' => 'Project 1, Thread 2',
|
||||||
|
'Message' => array(
|
||||||
|
array(
|
||||||
|
'id' => 2, 'thread' => 2, 'name' => 'Thread 2, Message 1',
|
||||||
|
'Bid' => array(
|
||||||
|
'id' => 4, 'message_id' => 2, 'name' => 'Bid 2.1'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'Project' => array(
|
||||||
|
'id' => 2, 'name' => 'Project 2'
|
||||||
|
),
|
||||||
|
'Thread' => array(
|
||||||
|
array(
|
||||||
|
'id' => 3, 'project_id' => 2, 'name' => 'Project 2, Thread 1',
|
||||||
|
'Message' => array(
|
||||||
|
array(
|
||||||
|
'id' => 3, 'thread' => 3, 'name' => 'Thread 3, Message 1',
|
||||||
|
'Bid' => array(
|
||||||
|
'id' => 3, 'message_id' => 3, 'name' => 'Bid 3.1'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'Project' => array(
|
||||||
|
'id' => 3, 'name' => 'Project 3'
|
||||||
|
),
|
||||||
|
'Thread' => array()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
unset($this->Project);
|
||||||
|
}
|
||||||
|
|
||||||
function testFindAllRecursiveSelfJoin() {
|
function testFindAllRecursiveSelfJoin() {
|
||||||
$this->model =& new Home();
|
$this->model =& new Home();
|
||||||
|
|
||||||
|
|
50
cake/tests/fixtures/bid_fixture.php
vendored
Normal file
50
cake/tests/fixtures/bid_fixture.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Short description for file.
|
||||||
|
*
|
||||||
|
* Long description for file
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
* Copyright 2005-2007, 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-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
* @since CakePHP(tm) v 1.2.0.4667
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Short description for class.
|
||||||
|
*
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
*/
|
||||||
|
class BidFixture extends CakeTestFixture {
|
||||||
|
var $name = 'Bid';
|
||||||
|
var $fields = array(
|
||||||
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
|
'message_id' => array('type' => 'integer', 'null' => false),
|
||||||
|
'name' => array('type' => 'string', 'null' => false)
|
||||||
|
);
|
||||||
|
var $records = array(
|
||||||
|
array ('id' => 1, 'message_id' => 1, 'name' => 'Bid 1.1'),
|
||||||
|
array ('id' => 2, 'message_id' => 1, 'name' => 'Bid 1.2'),
|
||||||
|
array ('id' => 3, 'message_id' => 3, 'name' => 'Bid 3.1'),
|
||||||
|
array ('id' => 4, 'message_id' => 2, 'name' => 'Bid 2.1'),
|
||||||
|
array ('id' => 5, 'message_id' => 2, 'name' => 'Bid 2.2')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
48
cake/tests/fixtures/message_fixture.php
vendored
Normal file
48
cake/tests/fixtures/message_fixture.php
vendored
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Short description for file.
|
||||||
|
*
|
||||||
|
* Long description for file
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
* Copyright 2005-2007, 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-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
* @since CakePHP(tm) v 1.2.0.4667
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Short description for class.
|
||||||
|
*
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
*/
|
||||||
|
class MessageFixture extends CakeTestFixture {
|
||||||
|
var $name = 'Message';
|
||||||
|
var $fields = array(
|
||||||
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
|
'thread_id' => array('type' => 'integer', 'null' => false),
|
||||||
|
'name' => array('type' => 'string', 'null' => false)
|
||||||
|
);
|
||||||
|
var $records = array(
|
||||||
|
array ('id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1'),
|
||||||
|
array ('id' => 2, 'thread_id' => 2, 'name' => 'Thread 2, Message 1'),
|
||||||
|
array ('id' => 3, 'thread_id' => 3, 'name' => 'Thread 3, Message 1')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
47
cake/tests/fixtures/project_fixture.php
vendored
Normal file
47
cake/tests/fixtures/project_fixture.php
vendored
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Short description for file.
|
||||||
|
*
|
||||||
|
* Long description for file
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
* Copyright 2005-2007, 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-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
* @since CakePHP(tm) v 1.2.0.4667
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Short description for class.
|
||||||
|
*
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
*/
|
||||||
|
class ProjectFixture extends CakeTestFixture {
|
||||||
|
var $name = 'Project';
|
||||||
|
var $fields = array(
|
||||||
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
|
'name' => array('type' => 'string', 'null' => false)
|
||||||
|
);
|
||||||
|
var $records = array(
|
||||||
|
array ('id' => 1, 'name' => 'Project 1'),
|
||||||
|
array ('id' => 2, 'name' => 'Project 2'),
|
||||||
|
array ('id' => 3, 'name' => 'Project 3')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
48
cake/tests/fixtures/thread_fixture.php
vendored
Normal file
48
cake/tests/fixtures/thread_fixture.php
vendored
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Short description for file.
|
||||||
|
*
|
||||||
|
* Long description for file
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
* Copyright 2005-2007, 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-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
* @since CakePHP(tm) v 1.2.0.4667
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Short description for class.
|
||||||
|
*
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.fixtures
|
||||||
|
*/
|
||||||
|
class ThreadFixture extends CakeTestFixture {
|
||||||
|
var $name = 'Thread';
|
||||||
|
var $fields = array(
|
||||||
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
|
'project_id' => array('type' => 'integer', 'null' => false),
|
||||||
|
'name' => array('type' => 'string', 'null' => false)
|
||||||
|
);
|
||||||
|
var $records = array(
|
||||||
|
array ('id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1'),
|
||||||
|
array ('id' => 2, 'project_id' => 1, 'name' => 'Project 1, Thread 2'),
|
||||||
|
array ('id' => 3, 'project_id' => 2, 'name' => 'Project 2, Thread 1')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Add table
Reference in a new issue