Error with Node_load() - : Base table or view not found I implemented a function to load nodes which it is loaded from a unitary test..

function labdoo_rest_get_laptop($id) {
    $node = node_load($id);
    return $node;
    }


And i get an error like this:

    Test PDOStatement-&gt;execute() failed: &lt;em class="placeholder"&gt;PDOException&lt;/em&gt;: SQLSTATE[42S02]: Base table or view not found: 1146 TabTest PDOStatement-&gt;execute() failed: &lt;em class="placeholder"&gt;PDOException&lt;/em&gt;: SQLSTATE[42S02]: Base table or view not found: 1146 Table                    [error]
&amp;#039;lbd.simpletest291431node_type&amp;#039; doesn&amp;#039;t exist: SELECT nt.*
FROM 
{node_type} nt
WHERE  (disabled = :db_condition_placeholder_0) 
ORDER BY nt.type ASC; Array
(
    [:db_condition_placeholder_0] =&amp;gt; 0
)
 in &lt;em class="placeholder"&gt;_node_types_build()&lt;/em&gt; (line &lt;em class="placeholder"&gt;738&lt;/em&gt; of &lt;em
class="placeholder"&gt;/var/www/lbd/modules/node/node.module&lt;/em&gt;).
le                    [error]
    &amp;#039;lbd.simpletest291431node_type&amp;#039; doesn&amp;#039;t exist: SELECT nt.*
    FROM 
    {node_type} nt
    WHERE  (disabled = :db_condition_placeholder_0) 
    ORDER BY nt.type ASC; Array
    (
        [:db_condition_placeholder_0] =&amp;gt; 0
    )
     in &lt;em class="placeholder"&gt;_node_types_build()&lt;/em&gt; (line &lt;em class="placeholder"&gt;738&lt;/em&gt; of &lt;em
    class="placeholder"&gt;/var/www/lbd/modules/node/node.module&lt;/em&gt;).


The error is difficult to read... anyway i can understand it is trying to load the node from the database 'lbd.simpletest', but it is not correct!!, I don't know why it is trying to do this.... I tried the 'db_set_active' operation, but i receive the same error, also i could get the node information with sql_query but i prefer this method, it seems better.

My file (with name labdoo_rest.test) to test the SQL function is:

&lt;?php

//TODO Add comments

class LabdooRestUnitaryTest extends DrupalUnitTestCase {

  public static function getInfo() {
    return array(
      'name' =&gt; 'Labdoo REST test functionality',
      'description' =&gt; "Test SQL  operations: Review functions with SQL queries. ",
      'group' =&gt; 'Labdoo'
    );
  }

  function testHelloWorld ()  {
        print "test message\n";
        $this-&gt;assertTrue(TRUE,"My first test works");
 }
 function testGetLaptop ()  {
        $id=2;
        $result = labdoo_rest_get_laptop($id);
        print "$result"."\n";
        $this-&gt;assertTrue(TRUE,"Test get laptop");
}


}


Thanks for your help...

UPDATE: 


$id = 2;  &lt;- it is the node's nid, and the node exists
I proved var_dump($node) but I didn't receive results because my error
message is an exception (PDOException).


UPDATE2:


I tested drush php-eval "print print_r(node_load(2), 1)" and it
returns the correct information. 
I am using druh with drush test-clean &amp;&amp; drush test-run
... to run the function. I suppose the problem is related to the drush test-run call.


UPDATE3:
 - My code in the Github project:
https://github.com/Labdoo/Labdoo-2.0/tree/features/web-services-api/modules/custom/labdoo_rest
Maybe you should define on the test class what profile are you using. Somehow simpletest does not detect it automatically. Without knowing which profile to install, it will not know what is a laptop node, because this content type has not been created. You can try to define on the test class the attribute:

protected $profile = 'labdoo';


See as an example: https://github.com/dashohoxha/oauth2_client/tree/7.x-1.x/tests

In particular, the shell script can be interesting: https://github.com/dashohoxha/oauth2_client/blob/7.x-1.x/tests/run_tests.sh