Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make several tests using MDB2 with PHPUnit DataBase?
    text
    copied!<p>I use PHPUnit DataBase to test some class using MDB2.</p> <p>All is well, since I encounter the second test, which returns an error:</p> <blockquote> <p>Caught exception: Object of class MDB2_Error could not be converted to string</p> </blockquote> <p>When I place the second test in place of the first one, the new first test is OK, but the second one returns the same error! And the next ones also!</p> <p>Maybe the MDB2 connection is closed after the first test?</p> <p>Here is my constructor:</p> <pre><code>public function __construct() { $this-&gt;pdo = new PDO('connectionstring', 'user', 'passwd'); try { $this-&gt;mdb2 = new MyDBA($this-&gt;dsn); } catch (Exception $e) { error_log(' __construct Caught exception: '.$e-&gt;getMessage()); } } </code></pre> <p>MyDBA returns a singleton. No exception is raised inside the constructor...</p> <p>Here are the two first tests:</p> <pre><code>public function testTranslationAdd() { try { $id = $this-&gt;mdb2-&gt;addTranslation("This is the second english translation.","en"); } catch (Exception $e) { error_log(' testTranslationAdd Caught exception: '.$e-&gt;getMessage()); } $xml_dataset = $this-&gt;createFlatXMLDataSet(dirname(__FILE__).'/state/twotranslations.xml'); $this-&gt;assertDataSetsEqual($xml_dataset, $this-&gt;getConnection()-&gt;createDataSet(array("translation"))); } public function testTranslationGet() { try { $text = $this-&gt;mdb2-&gt;getTranslation(1,"en"); } catch (Exception $e) { error_log(' testTranslationGet Caught exception: '.$e-&gt;getMessage()); } $this-&gt;assertEquals("This is the first english translation.",$text); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload