Here is a test for the dblog module.
I found the following issues:
1) The drupalCreateUser
function does not trigger an Add User event logging. Should it?
2) Likewise, the drupalCreateNode
function does not trigger an Add Content-Type event logging. Should it?
3) When a user is deleted, any content they created remains but the uid = 0. One side effect is their blog entry shows as "'s blog" on the home page. Is this intended or should the content be deleted or 'reassigned' in some fashion?
4) The following query leaves an extra row in the watchdog table. In other words, if dblog_row_limit = 100, the watchdog table will have 101 rows after this function runs. A where clause of 'wid <= %d' (replace '<' with '<=') would leave 100 rows.
function dblog_cron() {
// Cleanup the watchdog table
$max = db_result(db_query('SELECT MAX(wid) FROM {watchdog}'));
db_query('DELETE FROM {watchdog} WHERE wid < %d', $max - variable_get('dblog_row_limit', 1000));
}
5) In checking the cron functionality, there appears to be something funny with the global $conf
array. I noticed this when setting the dblog_row_limit variable by a post from the related administrative form. Based on my tests, there would appear to be multiple copies of the array in memory.
I base this on dumping values from the variable_set
and variable_get
routines before and after setting the dblog_row_limit variable by a post from the administrative form. The $conf[$name]
variable has the new value in the set routine, but has the 'system' value in the get routine (called immediately after). By 'system' value, I mean the value when the SimpleTest is not running.
Later, I manually called the variable_set
routine and this value took.
Comment | File | Size | Author |
---|---|---|---|
#8 | dblog_cron_fix.patch | 3.12 KB | solotandem |
#6 | dblog_cleanup.patch | 2.06 KB | solotandem |
#4 | dblog_cleanup.patch | 1.83 KB | solotandem |
#1 | dblog.test | 14.19 KB | solotandem |
dblog.test | 14.24 KB | solotandem |
Comments
Comment #1
solotandem CreditAttribution: solotandem commentedDue to the recent core changes to the user api, my test did not pass as expected. This version fixes the tests with the exception of the three failures outlined above.
I created a patch for the dblog_cron query at http://drupal.org/node/241629.
Comment #3
boombatower CreditAttribution: boombatower commentedCommitted.
Only two intended fails since core patch was committed!
Comment #4
solotandem CreditAttribution: solotandem commentedSimplified some code for consistency with other tests.
Comment #5
boombatower CreditAttribution: boombatower commentedCommitted.
Thanks again.
Comment #6
solotandem CreditAttribution: solotandem commentedChanged some code missed with last patch; removed code no longer needed due to core fix of dblog_cron; and corrected a comment.
Comment #7
boombatower CreditAttribution: boombatower commentedCommitted.
Comment #8
solotandem CreditAttribution: solotandem commentedThis patch resolves item #5 in the original post about the
global $conf
array. I removed some now unneeded assertions and utilized the internal browser to invoke the cron job instead of calling the api functiondblog_cron
.Comment #9
boombatower CreditAttribution: boombatower commentedCommitted.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.