From f8f1380bcd5ae2a3fe6451892d90ccd3b97f84a5 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 30 Apr 2008 19:19:16 +0000 Subject: [PATCH] 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 --- cake/tests/cases/libs/model/model.test.php | 3 ++- cake/tests/fixtures/join_a_b_fixture.php | 4 +++- cake/tests/fixtures/join_a_c_fixture.php | 4 +++- cake/tests/fixtures/join_a_fixture.php | 2 ++ cake/tests/fixtures/join_b_fixture.php | 2 ++ cake/tests/fixtures/join_c_fixture.php | 2 ++ cake/tests/fixtures/join_thing_fixture.php | 4 +++- cake/tests/lib/cake_test_fixture.php | 7 ------- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 7914a0706..6470c903d 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -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', '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', - '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); } @@ -3538,6 +3538,7 @@ class ModelTest extends CakeTestCase { if (!isset($config->test) || !isset($config->test2)) { echo "
Primary and secondary test databases not configured, skipping cross-database join tests
"; + echo "To run these tests, you must define \$test and \$test2 in your database configuration.
"; return; } $this->loadFixtures('Article', 'Tag', 'ArticlesTag', 'User', 'Comment'); diff --git a/cake/tests/fixtures/join_a_b_fixture.php b/cake/tests/fixtures/join_a_b_fixture.php index 0f99eabc5..1aadaa37d 100644 --- a/cake/tests/fixtures/join_a_b_fixture.php +++ b/cake/tests/fixtures/join_a_b_fixture.php @@ -33,11 +33,13 @@ * @subpackage cake.tests.fixtures */ class JoinABFixture extends CakeTestFixture { + var $name = 'JoinAsJoinB'; + var $fields = array( 'id' => array('type' => 'integer', 'key' => 'primary'), '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' => ''), 'created' => array('type' => 'datetime', 'null' => true), 'updated' => array('type' => 'datetime', 'null' => true) diff --git a/cake/tests/fixtures/join_a_c_fixture.php b/cake/tests/fixtures/join_a_c_fixture.php index 3614bbcf3..c3191c930 100644 --- a/cake/tests/fixtures/join_a_c_fixture.php +++ b/cake/tests/fixtures/join_a_c_fixture.php @@ -33,11 +33,13 @@ * @subpackage cake.tests.fixtures */ class JoinACFixture extends CakeTestFixture { + var $name = 'JoinAsJoinC'; + var $fields = array( 'id' => array('type' => 'integer', 'key' => 'primary'), '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' => ''), 'created' => array('type' => 'datetime', 'null' => true), 'updated' => array('type' => 'datetime', 'null' => true) diff --git a/cake/tests/fixtures/join_a_fixture.php b/cake/tests/fixtures/join_a_fixture.php index 70616d483..c0facf142 100644 --- a/cake/tests/fixtures/join_a_fixture.php +++ b/cake/tests/fixtures/join_a_fixture.php @@ -33,7 +33,9 @@ * @subpackage cake.tests.fixtures */ class JoinAFixture extends CakeTestFixture { + var $name = 'JoinA'; + var $fields = array( 'id' => array('type' => 'integer', 'key' => 'primary'), 'name' => array('type' => 'string', 'default' => ''), diff --git a/cake/tests/fixtures/join_b_fixture.php b/cake/tests/fixtures/join_b_fixture.php index 78d3b5bb9..bbc4006c4 100644 --- a/cake/tests/fixtures/join_b_fixture.php +++ b/cake/tests/fixtures/join_b_fixture.php @@ -33,7 +33,9 @@ * @subpackage cake.tests.fixtures */ class JoinBFixture extends CakeTestFixture { + var $name = 'JoinB'; + var $fields = array( 'id' => array('type' => 'integer', 'key' => 'primary'), 'name' => array('type' => 'string', 'default' => ''), diff --git a/cake/tests/fixtures/join_c_fixture.php b/cake/tests/fixtures/join_c_fixture.php index f0985eafc..7f00aa552 100644 --- a/cake/tests/fixtures/join_c_fixture.php +++ b/cake/tests/fixtures/join_c_fixture.php @@ -33,7 +33,9 @@ * @subpackage cake.tests.fixtures */ class JoinCFixture extends CakeTestFixture { + var $name = 'JoinC'; + var $fields = array( 'id' => array('type' => 'integer', 'key' => 'primary'), 'name' => array('type' => 'string', 'default' => ''), diff --git a/cake/tests/fixtures/join_thing_fixture.php b/cake/tests/fixtures/join_thing_fixture.php index 779e6a3eb..23dce9c7e 100644 --- a/cake/tests/fixtures/join_thing_fixture.php +++ b/cake/tests/fixtures/join_thing_fixture.php @@ -33,11 +33,13 @@ * @subpackage cake.tests.fixtures */ class JoinThingFixture extends CakeTestFixture { + var $name = 'JoinThing'; + var $fields = array( 'id' => array('type' => 'integer', 'key' => 'primary'), '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'), 'created' => array('type' => 'datetime', 'null' => true), 'updated' => array('type' => 'datetime', 'null' => true) diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 2543de59e..ba6ce2b4c 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -108,13 +108,6 @@ class CakeTestFixture extends Object { if (!isset($this->primaryKey) && isset($this->fields['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.