I've been using Class::DBI to create a web site and it is
going nicely. I now want to create a comprehensive test suite that
tests the site via the web using Test::WWW::Mechanize. The
problem is getting CDBI to grab new data from the database after a
change has been made on the site.
The problem rests with CDBI's cache of objects in memory. This code
demonstrates the problem:
# In test suite.
# Check CDBI object is as expected.
is $cdbi_object->name, 'Foo', "name is correct (Foo)"
# Change the name through web site.
# Check that the name has changed.
is $cdbi_object->name, 'Bar', "name has changed to 'Bar'";
# Test fails.
Arguably the tests should fail as there is no way for one instance
of perl (test) to know that the object has changed in another
(webserver). The tests can be made to work as they should by inserting
something like this before the test that checks for changed values:
# Reload the object from the database.
$cdbi_object = My::Object->retrieve( $cdbi_object->id );
To get to the point is there a simpler and better way to do
this. Can the cache be turned off completely? Is there a way to get a
method like $cdbi_object->freshen that will do the above?
Am I missing the point
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||