title: PHP Unit Tests: should tests be under the same namespace as the class?
body: <p>The Symfony 2.0 bundle directory structure, conventionally, has a <code>Tests</code> directory where tests should be placed.</p>
  
  <pre><code>Acme
      -&gt; SomeBundle
          -&gt; Controller
          -&gt; Entity
          -&gt; Service
          -&gt; ...
          -&gt; Tests
              -&gt; Controller
              -&gt; Entity
              -&gt; Service
              -&gt; ...
      -&gt; OtherBundle
      -&gt; ...
  </code></pre>
  
  <p>I am aware the tests work even if they are not under the same namespace as the classes they test.</p>
  
  <pre><code>namespace Acme\SomeBundle\Service;
  
  /**
   * Some service.
   *
   * @author varchar
   * @since  August 1, 2012
   */
  class SomeService
  {
  }
  </code></pre>
  
  <p>For the class above, I (for one) would usually have a test under the following name space (as influenced by the directory structure):</p>
  
  <pre><code>namespace Acme\SomeBundle\Tests\Service;
  </code></pre>
  
  <p>Now, this works okay.</p>
  
  <p>Incidentally however, I use the Netbeans IDE which cannot find a test class unless it is under the same namespace (this is notable when you want to test only a single file). Well, this could be just a Netbeans standard (or something).</p>
  
  <p>Regardless however, is it appropriate to put tests under the same namespace as the class being tested? Are there any merits in doing so?</p>
  
  <h2>Question</h2>
  
  <p><strong>1)</strong> Is it appropriate to put tests under the same namespace as the class being tested?</p>
  
  <p><strong>2)</strong> Are there any merits in doing so?</p>