title: Symfony2: Testing entity validation constraints
body: <p>Does anyone have a good way to unit test an entity's validation constraints in Symfony2?</p>
  
  <p>Ideally I want to have access to the Dependency Injection Container within the unit test which would then give me access to the validator service. Once I have the validator service I can run it manually:</p>
  
  <pre><code>$errors = $validator-&gt;validate($entity);
  </code></pre>
  
  <p>I could extend <code>WebTestCase</code> and then create a <code>client</code> to get to the container as per the docs however it doesn't feel right. The <code>WebTestCase</code> and <code>client</code> read in the docs as more of a facility to test <strong>actions</strong> as a whole and therefore it feels broken to use it to unit test an entity.</p>
  
  <p>So, does anyone know how to either a) get the container or b) create the validator inside a unit test?</p>