mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Correcting default value handling in model fixtures; updating test cases
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6737 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
471b6b0e2d
commit
f8f1380bcd
8 changed files with 17 additions and 11 deletions
|
@ -274,7 +274,7 @@ class ModelTest extends CakeTestCase {
|
||||||
array('id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31',
|
array('id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31',
|
||||||
'JoinThing' => array('doomed' => '1', 'something_id' => '1', 'something_else_id' => '2')),
|
'JoinThing' => array('doomed' => '1', 'something_id' => '1', 'something_else_id' => '2')),
|
||||||
array('id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31',
|
array('id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31',
|
||||||
'JoinThing' => array('doomed' => null, 'something_id' => '1', 'something_else_id' => '3'))));
|
'JoinThing' => array('doomed' => '0', 'something_id' => '1', 'something_else_id' => '3'))));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3538,6 +3538,7 @@ class ModelTest extends CakeTestCase {
|
||||||
|
|
||||||
if (!isset($config->test) || !isset($config->test2)) {
|
if (!isset($config->test) || !isset($config->test2)) {
|
||||||
echo "<br />Primary and secondary test databases not configured, skipping cross-database join tests<br />";
|
echo "<br />Primary and secondary test databases not configured, skipping cross-database join tests<br />";
|
||||||
|
echo "To run these tests, you must define \$test and \$test2 in your database configuration.<br />";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->loadFixtures('Article', 'Tag', 'ArticlesTag', 'User', 'Comment');
|
$this->loadFixtures('Article', 'Tag', 'ArticlesTag', 'User', 'Comment');
|
||||||
|
|
4
cake/tests/fixtures/join_a_b_fixture.php
vendored
4
cake/tests/fixtures/join_a_b_fixture.php
vendored
|
@ -33,11 +33,13 @@
|
||||||
* @subpackage cake.tests.fixtures
|
* @subpackage cake.tests.fixtures
|
||||||
*/
|
*/
|
||||||
class JoinABFixture extends CakeTestFixture {
|
class JoinABFixture extends CakeTestFixture {
|
||||||
|
|
||||||
var $name = 'JoinAsJoinB';
|
var $name = 'JoinAsJoinB';
|
||||||
|
|
||||||
var $fields = array(
|
var $fields = array(
|
||||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
'join_a_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
'join_a_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||||
'join_b_id' => array('type' => 'integer', 'default' => ''),
|
'join_b_id' => array('type' => 'integer', 'default' => null),
|
||||||
'other' => array('type' => 'string', 'default' => ''),
|
'other' => array('type' => 'string', 'default' => ''),
|
||||||
'created' => array('type' => 'datetime', 'null' => true),
|
'created' => array('type' => 'datetime', 'null' => true),
|
||||||
'updated' => array('type' => 'datetime', 'null' => true)
|
'updated' => array('type' => 'datetime', 'null' => true)
|
||||||
|
|
4
cake/tests/fixtures/join_a_c_fixture.php
vendored
4
cake/tests/fixtures/join_a_c_fixture.php
vendored
|
@ -33,11 +33,13 @@
|
||||||
* @subpackage cake.tests.fixtures
|
* @subpackage cake.tests.fixtures
|
||||||
*/
|
*/
|
||||||
class JoinACFixture extends CakeTestFixture {
|
class JoinACFixture extends CakeTestFixture {
|
||||||
|
|
||||||
var $name = 'JoinAsJoinC';
|
var $name = 'JoinAsJoinC';
|
||||||
|
|
||||||
var $fields = array(
|
var $fields = array(
|
||||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
'join_a_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
'join_a_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||||
'join_c_id' => array('type' => 'integer', 'default' => ''),
|
'join_c_id' => array('type' => 'integer', 'default' => null),
|
||||||
'other' => array('type' => 'string', 'default' => ''),
|
'other' => array('type' => 'string', 'default' => ''),
|
||||||
'created' => array('type' => 'datetime', 'null' => true),
|
'created' => array('type' => 'datetime', 'null' => true),
|
||||||
'updated' => array('type' => 'datetime', 'null' => true)
|
'updated' => array('type' => 'datetime', 'null' => true)
|
||||||
|
|
2
cake/tests/fixtures/join_a_fixture.php
vendored
2
cake/tests/fixtures/join_a_fixture.php
vendored
|
@ -33,7 +33,9 @@
|
||||||
* @subpackage cake.tests.fixtures
|
* @subpackage cake.tests.fixtures
|
||||||
*/
|
*/
|
||||||
class JoinAFixture extends CakeTestFixture {
|
class JoinAFixture extends CakeTestFixture {
|
||||||
|
|
||||||
var $name = 'JoinA';
|
var $name = 'JoinA';
|
||||||
|
|
||||||
var $fields = array(
|
var $fields = array(
|
||||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
'name' => array('type' => 'string', 'default' => ''),
|
'name' => array('type' => 'string', 'default' => ''),
|
||||||
|
|
2
cake/tests/fixtures/join_b_fixture.php
vendored
2
cake/tests/fixtures/join_b_fixture.php
vendored
|
@ -33,7 +33,9 @@
|
||||||
* @subpackage cake.tests.fixtures
|
* @subpackage cake.tests.fixtures
|
||||||
*/
|
*/
|
||||||
class JoinBFixture extends CakeTestFixture {
|
class JoinBFixture extends CakeTestFixture {
|
||||||
|
|
||||||
var $name = 'JoinB';
|
var $name = 'JoinB';
|
||||||
|
|
||||||
var $fields = array(
|
var $fields = array(
|
||||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
'name' => array('type' => 'string', 'default' => ''),
|
'name' => array('type' => 'string', 'default' => ''),
|
||||||
|
|
2
cake/tests/fixtures/join_c_fixture.php
vendored
2
cake/tests/fixtures/join_c_fixture.php
vendored
|
@ -33,7 +33,9 @@
|
||||||
* @subpackage cake.tests.fixtures
|
* @subpackage cake.tests.fixtures
|
||||||
*/
|
*/
|
||||||
class JoinCFixture extends CakeTestFixture {
|
class JoinCFixture extends CakeTestFixture {
|
||||||
|
|
||||||
var $name = 'JoinC';
|
var $name = 'JoinC';
|
||||||
|
|
||||||
var $fields = array(
|
var $fields = array(
|
||||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
'name' => array('type' => 'string', 'default' => ''),
|
'name' => array('type' => 'string', 'default' => ''),
|
||||||
|
|
4
cake/tests/fixtures/join_thing_fixture.php
vendored
4
cake/tests/fixtures/join_thing_fixture.php
vendored
|
@ -33,11 +33,13 @@
|
||||||
* @subpackage cake.tests.fixtures
|
* @subpackage cake.tests.fixtures
|
||||||
*/
|
*/
|
||||||
class JoinThingFixture extends CakeTestFixture {
|
class JoinThingFixture extends CakeTestFixture {
|
||||||
|
|
||||||
var $name = 'JoinThing';
|
var $name = 'JoinThing';
|
||||||
|
|
||||||
var $fields = array(
|
var $fields = array(
|
||||||
'id' => array('type' => 'integer', 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'key' => 'primary'),
|
||||||
'something_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
'something_id' => array('type' => 'integer', 'length' => 10, 'null' => true),
|
||||||
'something_else_id' => array('type' => 'integer', 'default' => ''),
|
'something_else_id' => array('type' => 'integer', 'default' => null),
|
||||||
'doomed' => array('type' => 'boolean', 'default' => '0'),
|
'doomed' => array('type' => 'boolean', 'default' => '0'),
|
||||||
'created' => array('type' => 'datetime', 'null' => true),
|
'created' => array('type' => 'datetime', 'null' => true),
|
||||||
'updated' => array('type' => 'datetime', 'null' => true)
|
'updated' => array('type' => 'datetime', 'null' => true)
|
||||||
|
|
|
@ -108,13 +108,6 @@ class CakeTestFixture extends Object {
|
||||||
if (!isset($this->primaryKey) && isset($this->fields['id'])) {
|
if (!isset($this->primaryKey) && isset($this->fields['id'])) {
|
||||||
$this->primaryKey = 'id';
|
$this->primaryKey = 'id';
|
||||||
}
|
}
|
||||||
if (isset($this->fields)) {
|
|
||||||
foreach ($this->fields as $index => $field) {
|
|
||||||
if (isset($field['default']) && empty($field['default']) && $field['default'] !== 0) {
|
|
||||||
unset($this->fields[$index]['default']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Run before all tests execute, should return SQL statement to create table for this fixture.
|
* Run before all tests execute, should return SQL statement to create table for this fixture.
|
||||||
|
|
Loading…
Add table
Reference in a new issue