title: How to choose the test DB cakePHP testing
body: <p>I am using the cake bake command to create my fixture and Test models. I have done it successfully with one of my models but i am having troubles with another one.</p>
  
  <p>I dont know why, it tries to work with the default DB instead with the test one that i have already defined and that is the one used by the first model i tested.</p>
  
  <p>Both Test models, the one which works well and this 2nd one which doesn't, have been created with cake bake and they look exactly the same.</p>
  
  <p>Both of them have this in their fixture class:</p>
  
  <pre><code>public $import = array('records' =&gt; true, 'connection' =&gt; 'test');
  </code></pre>
  
  <p>Test defines the connection to my test database.
  What can be the problem?</p>
  
  <p>I have experiment something weird. In my test model if i use the singluar instead of the plural, it works with the default DB <strong>BUT</strong> if i change it to plural it works with the test DataBase. (but it can not call any method from the model, just defined methods such as find()).</p>
  
  <p>For example:</p>
  
  <pre><code>public function setUp() {
      parent::setUp();
  
      //uses the default DB (i dont know why)
      $this-&gt;Post = ClassRegistry::init('Post');          
      print_r($this-&gt;User-&gt;find('all'));
  
      $this-&gt;Post-&gt;updatePostsStatus(1); //works well
  
      //uses the default Test Database (i dont know why either)
      $this-&gt;Post = ClassRegistry::init('Posts');         
      print_r($this-&gt;User-&gt;find('all'));   
  
      $this-&gt;Post-&gt;updatePostsStatus(1); //doesn't work. No function found.
      /*SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'updatePostsStatus' at line 1*/
  
  }
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>I HAVE UPDATED IT.</p>
  
  <h1> LAST UPDATE AND SOLUTION</h1>
  
  <p>The problem was the bad initialization of the Post Model constructor. 
  Using the plural was not relevant. It is like using any non existent model. It will always get the test database.
  The answer for the good initialization of the constructor is here:
  <a href="https://stackoverflow.com/questions/10153841/how-to-overriding-a-constructor-correctly-at-cakephp-2-0">How to override model&#39;s constructor correctly in CakePHP</a></p>