Re: Getting simpletest to work with test DB
You seem to be rught Mark, But why does this dependency exist in the first place? Ed On Sat, Dec 13, 2008 at 10:36 AM, mark_story wrote: > > Ed, looks like those fails are on the schema and containable classes, > not the model. And as you found out bake doesn't search through every > related model to add fixtures from. It only goes one level deep, you > need to manually add all the missing fixtures. > > -Mark > > On Dec 12, 5:53 pm, "Ed Howland" wrote: >> I forgot to mention that I am still getting the previous errors on the >> Core/model tests. >> -- >> Ed Howlandhttp://greenprogrammer.blogspot.comhttp://twitter.com/ed_howland > > > -- Ed Howland http://greenprogrammer.blogspot.com http://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
Ed, looks like those fails are on the schema and containable classes, not the model. And as you found out bake doesn't search through every related model to add fixtures from. It only goes one level deep, you need to manually add all the missing fixtures. -Mark On Dec 12, 5:53 pm, "Ed Howland" wrote: > I forgot to mention that I am still getting the previous errors on the > Core/model tests. > -- > Ed Howlandhttp://greenprogrammer.blogspot.comhttp://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
I forgot to mention that I am still getting the previous errors on the Core/model tests. -- Ed Howland http://greenprogrammer.blogspot.com http://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
Ok, final update. All my tests are now passing! The trick was to make sure that ALL the down-chain fixtures get loaded. This applies to both belongs_to and has_many. The bake scripts did not fully populate the var $fixtures. I am not sure this is a bug because of the order of my baking the models and creating the db tables. So I'd suggest creating all the DB tables before baking models. Then double check the fullest extent of fixtures get loaded in the tests. Overall, this seems to me to not be a necessary dependency. In RSpec/Rails you can be very fine grained about what fixtures you want to load. So you can load a single fixture for that model's table and ignore any belongs_to or has_many associations. Ed On Fri, Dec 12, 2008 at 2:48 PM, Ed Howland wrote: > Ok, currently (nightly build 12/12/2008) I am seeing the following. > > First, I re-baked all models to get new fixtures and test cases. > > 1. Any leaf model w.o any associations works fine. > 2. Any leaf model that has a has_many association, doesn't seem to > create that table. > 3. Any model with a single depth belongs_to association works fine > 4. Any model that belongs_to a model that belongs_to another model > doesn't create the furthest model in the chain. > > I am not sure that final one is a consistent symptom. But I had a 4 > way indirect chain and it bombed on the final model that the > penultimate model belonged to. But it seemed to create all other > tables up to that point. > > Do your tests test models with deep associations? > > Also, I have 6 failures in the Core tests for model. > > All model tests > >* Failed > Equal expectation fails with member [comments] with member > [article_id] as key list [type, null, default] does not match key list > [type, null] at > [/var/www/xeon/cake/tests/cases/libs/model/schema.test.php line 391] > ModelGroupTest -> > /var/www/xeon/cake/tests/cases/libs/model/schema.test.php -> > CakeSchemaTest -> testSchemaRead >* Failed > Identical expectation [Array: 4 items] fails with [Array: 3 > items] as key list [type, null, default, length] does not match key > list [type, null, length] at > [/var/www/xeon/cake/tests/cases/libs/model/schema.test.php line 395] > ModelGroupTest -> > /var/www/xeon/cake/tests/cases/libs/model/schema.test.php -> > CakeSchemaTest -> testSchemaRead >* Failed > at > [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > line 110] > ModelGroupTest -> > /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > -> ContainableTest -> testContainments >* Failed > at > [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > line 111] > ModelGroupTest -> > /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > -> ContainableTest -> testContainments >* Failed > Equal expectation fails as key list [] does not match key list > [0, 1] at > [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > line 112] > ModelGroupTest -> > /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > -> ContainableTest -> testContainments >* Failed > Equal expectation fails as key list [] does not match key list > [0] at > [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > line 113] > ModelGroupTest -> > /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php > -> ContainableTest -> testContainments > > > Ed > > > -- > Ed Howland > http://greenprogrammer.blogspot.com > http://twitter.com/ed_howland > -- Ed Howland http://greenprogrammer.blogspot.com http://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
Ok, currently (nightly build 12/12/2008) I am seeing the following. First, I re-baked all models to get new fixtures and test cases. 1. Any leaf model w.o any associations works fine. 2. Any leaf model that has a has_many association, doesn't seem to create that table. 3. Any model with a single depth belongs_to association works fine 4. Any model that belongs_to a model that belongs_to another model doesn't create the furthest model in the chain. I am not sure that final one is a consistent symptom. But I had a 4 way indirect chain and it bombed on the final model that the penultimate model belonged to. But it seemed to create all other tables up to that point. Do your tests test models with deep associations? Also, I have 6 failures in the Core tests for model. All model tests * Failed Equal expectation fails with member [comments] with member [article_id] as key list [type, null, default] does not match key list [type, null] at [/var/www/xeon/cake/tests/cases/libs/model/schema.test.php line 391] ModelGroupTest -> /var/www/xeon/cake/tests/cases/libs/model/schema.test.php -> CakeSchemaTest -> testSchemaRead * Failed Identical expectation [Array: 4 items] fails with [Array: 3 items] as key list [type, null, default, length] does not match key list [type, null, length] at [/var/www/xeon/cake/tests/cases/libs/model/schema.test.php line 395] ModelGroupTest -> /var/www/xeon/cake/tests/cases/libs/model/schema.test.php -> CakeSchemaTest -> testSchemaRead * Failed at [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php line 110] ModelGroupTest -> /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php -> ContainableTest -> testContainments * Failed at [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php line 111] ModelGroupTest -> /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php -> ContainableTest -> testContainments * Failed Equal expectation fails as key list [] does not match key list [0, 1] at [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php line 112] ModelGroupTest -> /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php -> ContainableTest -> testContainments * Failed Equal expectation fails as key list [] does not match key list [0] at [/var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php line 113] ModelGroupTest -> /var/www/xeon/cake/tests/cases/libs/model/behaviors/containable.test.php -> ContainableTest -> testContainments Ed -- Ed Howland http://greenprogrammer.blogspot.com http://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
On Fri, Dec 12, 2008 at 8:13 AM, Marcus wrote: > > On Dec 11, 10:55 pm, mark_story wrote: >> Should be fixed now! :) > > Indeed, it works again :) > > Thank you, Mark. > > Marcus > > > I think my bake scripts created the old style test, with model = new Model(). I'm going to try the ClassRegistry.init route. Ed -- Ed Howland http://greenprogrammer.blogspot.com http://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
On Dec 11, 10:55 pm, mark_story wrote: > Should be fixed now! :) Indeed, it works again :) Thank you, Mark. Marcus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
On Thu, Dec 11, 2008 at 3:55 PM, mark_story wrote: > > Should be fixed now! :) > On r7916: Ok, I am getting a lot farther now. Before, no model tests were passing. Now only two don't pass. Those two models belong_to other models. E.g. User => Group. The error reports that the group table is missing, in that case. Thanks for fixing the rest of them though. Ed -- Ed Howland http://greenprogrammer.blogspot.com http://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
Should be fixed now! :) On Dec 11, 11:10 am, Marcus wrote: > On Dec 11, 5:01 pm, "Ed Howland" wrote: > > > > Same problem here. The error message "Database table not found" > > > appeared with changeset 7870 of CakePHP. > > > So an earlier changeset might work for me? > > Maybe. Here it works when I downgrade CakePHP to revision 7869. > > Marcus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
Thanks marcus, I'll try to get this setup locally and see if I can get it fixed. Perhaps you could file a ticket as well so I don't forget. But your test looks like it should be working, so that's a problem. -Mark On Dec 11, 11:09 am, Marcus <[EMAIL PROTECTED]> wrote: > On Dec 11, 3:22 pm, mark_story <[EMAIL PROTECTED]> wrote: > > > How are your fixtures setup? > > Are you using imports? > > Are you initializing your models in setup() or startTest()? > > Are you using ClassRegistry::init() or are you use new Model()? > > Hey Mark, > > (i) Fixtures Setup (comments and wihitespaces stripped out) > > user_group_fixture.php: > > class UserGroupFixture extends CakeTestFixture > { > public $name = 'UserGroup'; > public $import = array('model' => 'UserGroup', 'records' => true); > > } > > user_fixture.php: > > class UserFixture extends CakeTestFixture > { > public $name = 'User'; > public $import = array('model' => 'User', 'records' => false); > public $records = array( > array( > 'id' => 1, > 'user_group_id' => 2, > 'name' => 'foo', > 'password' => > '288f5ed10f9b731149ad3e3bcdd6add568bb61a3', > 'salt' => '34da1b0c', > (...) > ) > ); > > } > > (ii) Using imports > > Yes, schema is imported in all cases, records just in some cases. > > (iii) Initializing of models > > The model is initialized with ClassRegistry::init(): > > user.test.php > > class UserTestCase extends CakeTestCase > { > public $User = null; > public $fixtures = array('app.user', 'app.user_group'); > public function start() > { > parent::start(); > Configure::write('debug', 2); > } > > public function end() > { > parent::end(); > } > > public function startTest($method) > { > $this->User = ClassRegistry::init('User'); > $this->User->query("-- >> STARTING TEST: " . > $method . " "); > } > > public function endTest($method) > { > } > > public function testHashPassword() > { > $this->assertEqual($this->User->hashPassword('foo'), 'bar'); > } > > } > > In this example, the user model is associated with the user_group > model (user belongsTo user_group, user_group hasMany user). Tests are > failing with "Error: Database table user_groups for model UserGroup > was not found." in this case. > > This setup was fine until revision 7869. As of revision 7870 tests are > failing. > > Marcus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
On Dec 11, 5:01 pm, "Ed Howland" <[EMAIL PROTECTED]> wrote: > > Same problem here. The error message "Database table not found" > > appeared with changeset 7870 of CakePHP. > > So an earlier changeset might work for me? Maybe. Here it works when I downgrade CakePHP to revision 7869. Marcus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
On Dec 11, 3:22 pm, mark_story <[EMAIL PROTECTED]> wrote: > How are your fixtures setup? > Are you using imports? > Are you initializing your models in setup() or startTest()? > Are you using ClassRegistry::init() or are you use new Model()? Hey Mark, (i) Fixtures Setup (comments and wihitespaces stripped out) user_group_fixture.php: class UserGroupFixture extends CakeTestFixture { public $name = 'UserGroup'; public $import = array('model' => 'UserGroup', 'records' => true); } user_fixture.php: class UserFixture extends CakeTestFixture { public $name = 'User'; public $import = array('model' => 'User', 'records' => false); public $records = array( array( 'id'=> 1, 'user_group_id' => 2, 'name' => 'foo', 'password' => '288f5ed10f9b731149ad3e3bcdd6add568bb61a3', 'salt' => '34da1b0c', (...) ) ); } (ii) Using imports Yes, schema is imported in all cases, records just in some cases. (iii) Initializing of models The model is initialized with ClassRegistry::init(): user.test.php class UserTestCase extends CakeTestCase { public $User = null; public $fixtures = array('app.user', 'app.user_group'); public function start() { parent::start(); Configure::write('debug', 2); } public function end() { parent::end(); } public function startTest($method) { $this->User = ClassRegistry::init('User'); $this->User->query("-- >> STARTING TEST: " . $method . " "); } public function endTest($method) { } public function testHashPassword() { $this->assertEqual($this->User->hashPassword('foo'), 'bar'); } } In this example, the user model is associated with the user_group model (user belongsTo user_group, user_group hasMany user). Tests are failing with "Error: Database table user_groups for model UserGroup was not found." in this case. This setup was fine until revision 7869. As of revision 7870 tests are failing. Marcus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
On Thu, Dec 11, 2008 at 2:19 AM, Marcus <[EMAIL PROTECTED]> wrote: > > Same problem here. The error message "Database table not found" > appeared with changeset 7870 of CakePHP. > So an earlier changeset might work for me? > When calling ClassRegistry::init('Foo') in the startTest method of a > test case, Cake tries to set up 'Foo' with all the associated models > and fails when initializing the first related model: CakePHP reads the > schema definition from database with wrong connection. > > When calling ClassRegistry::init('Foo'), Cake uses the 'default' > connection for getting the schema for 'Foo' and everything works fine. > Then the first related Model is initialized, CakePHP tries to read the > schema, but now with the 'test_suite' connection, which raises the > error because the table doesn't exist in the test database. > I poked around some more and I think I am seeing the same thing. > Is this an error that should be filed to trac? > Nothing open in trac at the moment. perhaps a closed > Marcus On Thu, Dec 11, 2008 at 8:22 AM, mark_story <[EMAIL PROTECTED]> wrote: > > How are your fixtures setup? var $fixtures = array('app.form', 'app.program'); > Are you using imports? App::import('Model', 'Form'); > Are you initializing your models in setup() or startTest()? function start() { parent::start(); $this->Form = new TestForm(); } > Are you using ClassRegistry::init() or are you use new Model()? Tried both. But it came with new Model(); It seems like a DB connection issue, as Marcus said. I wonder if it work with models with no associations. Ed > > > -- Ed Howland http://greenprogrammer.blogspot.com http://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
How are your fixtures setup? Are you using imports? Are you initializing your models in setup() or startTest()? Are you using ClassRegistry::init() or are you use new Model()? -Mark On Dec 10, 2:33 pm, "Ed Howland" <[EMAIL PROTECTED]> wrote: > Hi, > > I've got simpletest installed but now I am having problems with the test DB. > > I had to change the name of the variable to $test_suite from $test. > After that I could see the create table statements. > > Here is my setup: > > var $test_suite = array( > 'driver' => 'mysql', > 'persistent' => false, > 'host' => 'localhost', > 'login' => 'eddie', > 'password' => 'eddie', > 'database' => 'bph_test', > 'prefix' => '', > ); > > But now every test reports > Error: Database table forms for model Form was not found. The rest of > the test aborts. > > Any idea what I am doing wrong? > > Thanks, > Ed > > -- > Ed Howlandhttp://greenprogrammer.blogspot.comhttp://twitter.com/ed_howland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting simpletest to work with test DB
On Dec 10, 8:33 pm, "Ed Howland" <[EMAIL PROTECTED]> wrote: > Hi, > > I've got simpletest installed but now I am having problems with the test DB. > > I had to change the name of the variable to $test_suite from $test. > After that I could see the create table statements. > > Here is my setup: > > var $test_suite = array( > 'driver' => 'mysql', > 'persistent' => false, > 'host' => 'localhost', > 'login' => 'eddie', > 'password' => 'eddie', > 'database' => 'bph_test', > 'prefix' => '', > ); > > But now every test reports > Error: Database table forms for model Form was not found. The rest of > the test aborts. Same problem here. The error message "Database table not found" appeared with changeset 7870 of CakePHP. When calling ClassRegistry::init('Foo') in the startTest method of a test case, Cake tries to set up 'Foo' with all the associated models and fails when initializing the first related model: CakePHP reads the schema definition from database with wrong connection. When calling ClassRegistry::init('Foo'), Cake uses the 'default' connection for getting the schema for 'Foo' and everything works fine. Then the first related Model is initialized, CakePHP tries to read the schema, but now with the 'test_suite' connection, which raises the error because the table doesn't exist in the test database. Is this an error that should be filed to trac? Marcus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---