title: Mocking PDO with phpunit
body: <p>I am trying to mock PDO object to use when writing some tests with phpunit, but I find it pretty complicated and can't find too much documentation about it.
  I created this xml structure:</p>
  
  <pre><code>&lt;dataset&gt;
      &lt;table name="providers"&gt;
              &lt;column&gt;id&lt;/column&gt;
              &lt;column&gt;name&lt;/column&gt;
              &lt;column&gt;description&lt;/column&gt;
              &lt;row&gt;
                      &lt;value&gt;1&lt;/value&gt;
                      &lt;value&gt;provdier_1&lt;/value&gt;
                      &lt;value&gt;phpunit first provider&lt;/value&gt;
              &lt;/row&gt;
      &lt;/table&gt;
  &lt;/dataset&gt;
  </code></pre>
  
  <p>and now I want to query <code>providers</code> table and get the data back but I just cant figure out how to do that.</p>
  
  <p>I started with mocking the <code>PDO</code> object but I don't understand how should I work with it and how to use it inside the <code>getConnection()</code> method.
  my first attempt, which I'm guessing its quite far from the correct way because I am very lost here, looks something like this:</p>
  
  <pre><code>class AdProvidersTest extends PHPUnit_Extensions_Database_TestCase
  {
      public function getConnection()
      {
        $dsn = 'mydb';
        $user = '';
        $password = '';
  
        $pdo = $this-&gt;getMockBuilder('PDOMock')
          -&gt;getMock();
  
          return $this-&gt;createDefaultDBConnection($pdo, 'adserverTesting');
      }
  
      public function getDataSet()
      {
          return $this-&gt;createXMLDataSet('adserverTesting.xml');
      }
  
  }
  </code></pre>
  
  <p>how can I make the connection interact with the <code>'adserverTesting.xml'</code> file and how can I query it using this lines:</p>
  
  <pre><code>$ds = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this-&gt;getConnection());
  $ds-&gt;addTable('adserverTesting', 'SELECT * FROM providers');
  </code></pre>