All,
Is there a way to figure out the table prefix that Simpletest
generates at runtime? I am trying to run a test that does a bunch of inserts,
then I need to figure out how many rows were created in the table. However, I
can’t query the table because simpletest changes the name of it every
time. Also, I tried {table_name} instead of table_name in the query but it
didn’t work (line numbers inserted below to help with reading the error
message later):
21 public function test_sync () {
22 require_once(drupal_get_path('module','compoundmanagement').'/compoundmanagement.inc');
23 $result = db_query('select
count(objdid) as count from {cpd_compounds}');
24 $row = $result->db_fetch_object($result);
25 $this->pass('There are '.$row->count.' compounds in
cpd_compounds');
26 $this->drupalGet('sync_cpds',array('absolute' => TRUE));
27 $result = db_query('select
count(objdid) as count from {cpd_compounds}');
28 $row = $result->db_fetch_object($result);
29 $this->pass('There are now
'.$row->count.' compounds in
cpd_compounds');
30 $this->assertEqual($row->count,1313,"CPD_COMPOUNDS
should have 1313 rows.");
31 }
The
test above threw this error:
An error occurred.
/batch?id=18&op=do
<br />
<b>Fatal error</b>: Call to a member function db_fetch_object() on
a non-object in <b>C:\wamp\www\drupal\sites\all\modules\compoundmanagement\compoundmanagement.test</b>
on line <b>24</b><br />
Any ideas what to do here? I have
been developing in Drupal for a while now but am just now discovering the unit
testing available in SimpleTest.
Best,
Dave