title: Data got imported (using PDO) twice when running test with Codeception
body: <p>I'm writing a small script to <em>parse CSV information</em> and store it in a database.
  I'm not using any framework since this is a small project, but I use Codeception to test my code.</p>
  
  <p>Basically what my class Parser does is parsing data from a CSV file, process the data (put it more neatly into arrays) and insert that data.</p>
  
  <p>Below is the method for inserting data:</p>
  
  <pre><code>public function insertCategories() {
      // prepare statement
      codecept_debug("entering insertCategories");
      $stmt = $this-&gt;dbo-&gt;prepare("INSERT INTO `cs_menucategory` (`catid`, `menugroupid`, `categoryname`) VALUES (:catid, :menugroupid, :categoryname)");
  
      // prepare parameters
      $cats = $this-&gt;result['Category'];
      for ($i = 0; $i &lt; count($cats); $i++) {
          $params = array();
          $params['menugroupid'] = $i+1;
          $params['catid'] = $i+1;
          $params['categoryname'] = $cats[$i];
  
          // execute statement
          $stmt-&gt;execute($params);
      }
  }
  </code></pre>
  
  <p>I also wrote a simple unit test for this method using Codeception:</p>
  
  <pre><code>class Test extends \PHPUnit_Framework_TestCase {
  
      protected function setUp() {}
  
      protected function tearDown() {}
  
      // tests
      public function test() {
          $parser = new Parser();
          $parser-&gt;run(); 
      }
  }
  </code></pre>
  
  <p>in which method run is </p>
  
  <pre><code>public function run() {
      $this-&gt;createResultArrays();
      $this-&gt;getCSVData();
  
      $this-&gt;connectDtb();
  
      $this-&gt;processData();
      $this-&gt;insertCategories();
  }
  </code></pre>
  
  <p>When I ran this test and checked back in my database, all data got <strong>imported twice</strong>. 
  Then I tried to see if the method got called more than once, or if the loop was causing the problem by simply printing out status 'flags', but both weren't the case.</p>
  
  <p>Once I tried PHP interactive mode, however, the code worked just fine, all data got imported once and correctly. </p>
  
  <p>So I ran the test again in debug mode, and here was what was returned:</p>
  
  <pre><code>    Vy-Huynhs:MenuDrive VyHuynh$ ./vendor/bin/codecept run unit Test --debug
      Codeception PHP Testing Framework v2.1.5
      Powered by PHPUnit 4.8.22 by Sebastian Bergmann and contributors.
  
        Group 'failed' is empty, no tests are loaded
        entering insertCategories
  
      Unit Tests (1) ------------------------------
      Modules: Asserts, \Helper\Unit
      ---------------------------------------------
      Running Test::test... 
        entering insertCategories
      Test::test                             Ok
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      ---------------------------------------------
  
  
      Time: 225 ms, Memory: 9.50Mb
  
      OK (1 test, 0 assertions)
      Vy-Huynhs:MenuDrive VyHuynh$ 
  </code></pre>
  
  <p>I suspect this is what causing the error:</p>
  
  <blockquote>
    <p>Group 'failed' is empty, no tests are loaded</p>
  </blockquote>
  
  <p>Maybe there are some configurations to Codeception that I didn't do correctly.</p>
  
  <p>Below is the content of the CSV file: </p>
  
  <pre><code>Group,Category,Item 
  Main Menu,Appetizers,Buffalo Wings 
  ,,Chicken Fingers 
  ,,French Fries 
  ,Salad,Caesar Salad 
  ,,House Salad 
  Breakfast Menu,Sandwiches,BLT 
  ,Drinks,Coffee 
  ,,Tea 
  </code></pre>
  
  <p>and this script tried importing data from the Category column.</p>
  
  <p>Thank you all.</p>