<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>All,<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Is there a way to figure out the table prefix that Simpletest
generates at runtime?&nbsp; 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.&nbsp; However, I
can&#8217;t query the table because simpletest changes the name of it every
time.&nbsp; Also, I tried {table_name} instead of table_name in the query but it
didn&#8217;t work (line numbers inserted below to help with reading the error
message later):<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>21</span><span style='font-size:10.0pt;
font-family:"Courier New";color:blue'> public function </span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>test_sync () {</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>22&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:blue'>require_once</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>(drupal_get_path(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'module'</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'compoundmanagement'</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>).</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'/compoundmanagement.inc'</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>23&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$result </span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>= db_query(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'select
count(objdid) as count from {cpd_compounds}'</span><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>);</span><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>24&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$row </span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>= </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#660000'>$result</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;db_fetch_object(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#660000'>$result</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>25&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$this</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;pass(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'There are '</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>.</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#660000'>$row</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;count.</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>' compounds in
cpd_compounds'</span><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>26&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$this</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;drupalGet(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'sync_cpds'</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>array</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'absolute' </span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>=&gt; </span><span
style='font-size:10.0pt;font-family:"Courier New";color:blue'>TRUE</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>));</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>27&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$result </span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>= db_query(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'select
count(objdid) as count from {cpd_compounds}'</span><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>);</span><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>28&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$row </span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>= </span><span
style='font-size:10.0pt;font-family:"Courier New";color:#660000'>$result</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;db_fetch_object(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#660000'>$result</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span
style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>29&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$this</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;pass(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>'There are now
'</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#660000'>$row</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;count.</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>' compounds in
cpd_compounds'</span><span style='font-size:10.0pt;font-family:"Courier New";
color:black'>);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>30&nbsp;&nbsp;&nbsp; </span><span style='font-size:
10.0pt;font-family:"Courier New";color:#660000'>$this</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;assertEqual(</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#660000'>$row</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>-&gt;count,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:red'>1313</span><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>,</span><span
style='font-size:10.0pt;font-family:"Courier New";color:#008200'>&quot;CPD_COMPOUNDS
should have 1313 rows.&quot;</span><span style='font-size:10.0pt;font-family:
"Courier New";color:black'>);</span><span style='font-size:10.0pt;font-family:
"Courier New"'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'>31 }<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='color:black'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='color:black'>The
test above threw this error:<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:black'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'>An error occurred. <br>
/batch?id=18&amp;op=do<br>
&lt;br /&gt;<br>
&lt;b&gt;Fatal error&lt;/b&gt;: Call to a member function db_fetch_object() on
a non-object in &lt;b&gt;C:\wamp\www\drupal\sites\all\modules\compoundmanagement\compoundmanagement.test&lt;/b&gt;
on line &lt;b&gt;24&lt;/b&gt;&lt;br /&gt;<span style='font-size:10.0pt;
font-family:"Courier New";color:black'><o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'>Any ideas what to do here?&nbsp; I have
been developing in Drupal for a while now but am just now discovering the unit
testing available in SimpleTest.<o:p></o:p></p>

<p class=MsoNormal style='text-autospace:none'><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-autospace:none'>Best,<br>
Dave<o:p></o:p></p>

</div>

</body>

</html>