title: Getting a mock Doctrine\ORM\QueryBuilder
body: <p>I've been trying all day to write some tests for a class that parses a custom DSL and creates DQL queries.</p>
  
  <p>My class requires that I pass in a <code>queryBuilder</code> which it then uses to build the query and return it.</p>
  
  <p>The problem I have is that</p>
  
  <ul>
  <li>to get a <code>queryBuilder</code> I need an <code>entityManager</code></li>
  <li>to get an <code>entityManager</code> I need a connection</li>
  <li>to get a connection I need a database</li>
  </ul>
  
  <p>I'd rather that my unit tests didn't rely on a database so I've been trying to create a mock <code>queryBuilder</code> using <code>PHPUnit</code> but <code>queryBuilder</code> seems to rely on the <code>entityManager</code> which in turn relies on a connection.</p>
  
  <p>So 2 questions:<br>
  Is there a better way to dynamically construct queries in Doctrine 2?<br>
  Is there a way to get a working <code>queryBuilder</code> without an <code>entityManager</code> (or at least without a real database)?</p>