mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding test for #3455 replicating issue, Secondary model array in model data causes corruption
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5892 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
34a7d667db
commit
6591c8f79b
3 changed files with 123 additions and 1 deletions
|
@ -434,6 +434,12 @@ class Device extends CakeTestModel {
|
||||||
class DocumentDirectory extends CakeTestModel {
|
class DocumentDirectory extends CakeTestModel {
|
||||||
var $name = 'DocumentDirectory';
|
var $name = 'DocumentDirectory';
|
||||||
}
|
}
|
||||||
|
class PrimaryModel extends CakeTestModel {
|
||||||
|
var $name = 'PrimaryModel';
|
||||||
|
}
|
||||||
|
class SecondaryModel extends CakeTestModel {
|
||||||
|
var $name = 'SecondaryModel';
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -447,7 +453,8 @@ class ModelTest extends CakeTestCase {
|
||||||
'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',
|
'core.project', 'core.thread', 'core.message', 'core.bid',
|
||||||
'core.portfolio', 'core.item', 'core.items_portfolio', 'core.syfile', 'core.image',
|
'core.portfolio', 'core.item', 'core.items_portfolio', 'core.syfile', 'core.image',
|
||||||
'core.device_type', 'core.device_type_category', 'core.feature_set', 'core.exterior_type_category', 'core.document', 'core.device', 'core.document_directory'
|
'core.device_type', 'core.device_type_category', 'core.feature_set', 'core.exterior_type_category', 'core.document', 'core.device', 'core.document_directory',
|
||||||
|
'core.primary_model', 'core.secondary_model'
|
||||||
);
|
);
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
|
@ -668,6 +675,29 @@ class ModelTest extends CakeTestCase {
|
||||||
array('Article' => array('id' => 4, 'title' => 'Brand New Article'))));
|
array('Article' => array('id' => 4, 'title' => 'Brand New Article'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testCreationWithMultipleDataSameModelManualInstances() {
|
||||||
|
$Primary =& new PrimaryModel();
|
||||||
|
$Secondary =& new PrimaryModel();
|
||||||
|
|
||||||
|
$result = $Primary->field('primary_name', array('id' => 1));
|
||||||
|
$this->assertEqual($result, 'Primary Name Existing');
|
||||||
|
|
||||||
|
$data = array('PrimaryModel' => array('primary_name' => 'Primary Name New'),
|
||||||
|
'SecondaryModel' => array('id' => 1));
|
||||||
|
$Primary->create();
|
||||||
|
$result = $Primary->save($data);
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
$result = $Primary->field('primary_name', array('id' => 1));
|
||||||
|
$this->assertEqual($result, 'Primary Name Existing');
|
||||||
|
|
||||||
|
$result = $Primary->getInsertID();
|
||||||
|
$this->assertTrue(!empty($result));
|
||||||
|
|
||||||
|
$result = $Primary->findCount();
|
||||||
|
$this->assertEqual($result, 2);
|
||||||
|
}
|
||||||
|
|
||||||
function testReadFakeThread() {
|
function testReadFakeThread() {
|
||||||
$this->model =& new CategoryThread();
|
$this->model =& new CategoryThread();
|
||||||
|
|
||||||
|
|
46
cake/tests/fixtures/primary_model_fixture.php
vendored
Normal file
46
cake/tests/fixtures/primary_model_fixture.php
vendored
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<?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 PrimaryModelFixture extends CakeTestFixture {
|
||||||
|
var $name = 'PrimaryModel';
|
||||||
|
var $fields = array(
|
||||||
|
'id' => array('type' => 'integer', 'key' => 'primary', 'extra'=> 'auto_increment'),
|
||||||
|
'primary_name' => array('type' => 'string', 'null' => false)
|
||||||
|
);
|
||||||
|
var $records = array(
|
||||||
|
array ('id' => 1, 'title' => 'Primary Name Existing')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
46
cake/tests/fixtures/secondary_model_fixture.php
vendored
Normal file
46
cake/tests/fixtures/secondary_model_fixture.php
vendored
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<?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 SecondaryModelFixture extends CakeTestFixture {
|
||||||
|
var $name = 'SecondaryModel';
|
||||||
|
var $fields = array(
|
||||||
|
'id' => array('type' => 'integer', 'key' => 'primary', 'extra'=> 'auto_increment'),
|
||||||
|
'secondary_name' => array('type' => 'string', 'null' => false)
|
||||||
|
);
|
||||||
|
var $records = array(
|
||||||
|
array ('id' => 1, 'title' => 'Secondary Name Existing')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Add table
Reference in a new issue