title: Symfony2 entity manager in tests
body: <p>I'am writing unit-tests for symfony2 project. For example i want to test some class that requires Doctrine\ORM\EntityManger inctance:</p>
  
  <pre><code>// Class for testing
  // ...
  class CategoryManager
  {
     public function __construct( EntityManager $em )
     {
         // ...
  </code></pre>
  
  <p>So, i need to create Doctrine\ORM\EntityManager instance in my unit-tests and pass it to constructor like this:</p>
  
  <pre><code>// Testing
  // ...
  $category1 = new Category();
  $category2 = new Category();
  $categories = array( $category1, $category2 );
  $query = $this-&gt;getMock( '\Application\BackendBundle\Tests\Mocks\Doctrine\ORM\Query', array(), array(), '', false );
  $query-&gt;expects( $this-&gt;any() )
        -&gt;method( 'getResult' )
        -&gt;will( $this-&gt;returnValue( $categories ) );
  $em = $this-&gt;getMock( 'Doctrine\ORM\EntityManger', array(), array(), '', false );
  $em-&gt;expects( $this-&gt;any() )
     -&gt;method( 'createQuery' )
     -&gt;will( $this-&gt;returnValue( $query ) );
  // ...
  </code></pre>
  
  <p>Please make me advise how to improve and automate entity_manager mock creation. I don't sure that this is the right way to create mocks (creation of this bulky mocks seems inconvenient to me). I will be pleased for any advise.</p>