[development] Simpletest question

Daniel F. Kudwien news at unleashedmind.com
Tue Jan 26 16:10:45 UTC 2010

	21 public function test_sync () {

Should be testSync().


Should be module_load_include().

	23    $result = db_query('select count(objdid) as count from

"cpd_compounds" does not match your module name.

	24    $row = $result->db_fetch_object($result);

If this is for D7: db_fetch_object() no longer exists.  You can iterate over
$result directly.  Read more on http://drupal.org/node/310069

If this is for D6, then $result simply is no class and db_fetch_object()
simply is no method.

	25    $this->pass('There are '.$row->count.' compounds in

Should use t() as always, with appropriate placeholders (@count in this

	26    $this->drupalGet('sync_cpds',array('absolute' => TRUE));

Unless you have a very good reason to do so, the options array (and absolute
URL) is not required.

	27    $result = db_query('select count(objdid) as count from

SimpleTest always queries the table in the database of the currently running
test, as along as it is escaped (which it is here).

	28    $row = $result->db_fetch_object($result);

Your real error is likely here (again).

	29    $this->pass('There are now '.$row->count.' compounds in

See above.

	30    $this->assertEqual($row->count,1313,"CPD_COMPOUNDS should have
1313 rows.");

Only use double-quotes where technically required.

	The test above threw this error:
	<b>Fatal error</b>: Call to a member function db_fetch_object() on a

In the end, the actual error message is pretty concise. ;)


More information about the development mailing list