Really great insights on the subject. I am going to skip lazy loading for the app in question because I don't want to introduce any new potential issues, but for the next app I am going to use it for sure. I will double check my fixtures array, they are getting inherited, but I must have missed one somewhere.
On Sep 15, 2:50 am, nurvzy <[email protected]> wrote: > I imagine you're missing a fixture in there you didn't think you > were. Make sure you include HABTM joining tables as they tend to > catch me all the time. Fixtures and tests can be finiky at first > until you get the hang of it. I remember not figuring out for the > life of me why it would tell me a table wasn't there when I was > staring right at it in the fixtures array. As soon as I would remove > it it would complain about the next table in my fixture array not > being present. It turned out I was missing a plugin's fixture from > my testing -- added that in and all was well in the world. > > Fixtures are great, I love them, but there is a little learning curve > when you first start testing, just keep at it -- it's well worth the > reward. You'll be a much cleaner and faster programmer down the road. > > I assure you it works as stated. I went back in time (thanks git) to > verify and it works as expected in 1.3 -- as it should, it's basic > inheritance. Think of your BaseCase as an abstract class, you should > never instantiate it on its own your ModelTestCase is simply borrowing > the BaseCase's properties as their own. There is no difference unless > you're specifying your fixtures as private in BaseCase... don't do > that. :) > > But really, you should ditch all that effort and just use > lazy_loading, its 2 lines of code and then you only have to load the > tables your model actually uses through finds (recursion/contain), and > custom functions that take advantage of model association chaining. > This will make your tests run so much faster as the test wont have to > load and unload the entire database of tables it's not using every > test case. > > Hope that helps, and keep testing, > Nick > > On Sep 14, 8:45 am, "j.blotus" <[email protected]> wrote: > > > > > sorry missing post...rather the fixtures inherited...but the missing > > table errors were still prevelant... when i switch backed to > > CakeTestCase it ran fine. I am guessing that there is some additional > > functionality not getting extended by the base class. > > > On Sep 14, 10:38 am, "j.blotus" <[email protected]> wrote: > > > > hmm i had no luck extending CakeTestCase, it seems that the fixtures > > > did not get inherited by the model test file. > > > > On Sep 13, 11:52 pm, nurvzy <[email protected]> wrote: > > > > > If you use lazy_loading you can get past this, only unit test what > > > > each model will actually use, instead of having to load all fixtures > > > > for each because of the default model chaining behavior required for > > > > PHP4 support. > > > > > An alternative I've found useful prior to lazy_loading was creating a > > > > BaseCase that extends CakeTestCase and loads all your fixtures in > > > > there. Then simply extend your BaseCase when doing model testing, > > > > easy as pie. > > > > > class BaseCase extends CakeTestCase{ > > > > var $fixtures = array( > > > > //..fixtures here > > > > ); > > > > > } > > > > > Then with any new test I would just make sure to require BaseCase and > > > > extend it. > > > > require_once(dirname(__FILE__) . 'base_case.php'); > > > > > class ModelTestCase extends BaseCase { > > > > //Tests go here. > > > > > } > > > > > But this was all prior to lazy_loading. If you use lazy_loading > > > > (http://github.com/Phally/lazy_model) you can just use what table your > > > > model test will actually use ignoring the rest, a much more efficient > > > > approach to testing. > > > > > Hope that helps, > > > > Nick > > > > > On Sep 13, 1:32 pm, "j.blotus" <[email protected]> wrote: > > > > > > When I am testing a model, every time I create a new model in my > > > > > application, I have to add it in to my $fixtures array for each test > > > > > case, or I get missing table errors when testing. > > > > > > Is it possible to define $fixtures in just one spot? > > > > > > maybe app_cake_test_case or something like that? > > > > > > This can become a big problem the more tests I write. > > > > > > My current array = > > > > > > var $fixtures = array( > > > > > 'app.booking', > > > > > 'app.listing', > > > > > 'app.instant_payment_notification', > > > > > 'app.transaction', > > > > > 'app.package', > > > > > 'app.promo_code', > > > > > 'app.note', > > > > > 'app.inquiry', > > > > > 'app.event', > > > > > 'app.event_type', > > > > > 'app.publisher', > > > > > 'app.report', > > > > > 'app.country', > > > > > 'app.state', > > > > > 'app.region', > > > > > 'app.city', > > > > > 'app.user', > > > > > 'app.review', > > > > > 'app.image', > > > > > 'app.deal', > > > > > 'app.visit' > > > > > ); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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
