title: Why phpunit is not getting the correct APP_ENV as specified in phpunit.xml?
body: <p>I'm using Laravel and this is my ./phpunit.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;phpunit backupGlobals="false"
           backupStaticAttributes="false"
           bootstrap="bootstrap/autoload.php"
           colors="true"
           convertErrorsToExceptions="true"
           convertNoticesToExceptions="true"
           convertWarningsToExceptions="true"
           processIsolation="false"
           stopOnFailure="false"&gt;
      &lt;testsuites&gt;
          &lt;testsuite name="FeatureTests"&gt;
              &lt;directory suffix="Test.php"&gt;./tests/Feature&lt;/directory&gt;
          &lt;/testsuite&gt;
  
          &lt;testsuite name="UnitTests"&gt;
              &lt;directory suffix="Test.php"&gt;./tests/Unit&lt;/directory&gt;
          &lt;/testsuite&gt;
      &lt;/testsuites&gt;
      &lt;filter&gt;
          &lt;whitelist processUncoveredFilesFromWhitelist="true"&gt;
              &lt;directory suffix=".php"&gt;./app&lt;/directory&gt;
          &lt;/whitelist&gt;
      &lt;/filter&gt;
      &lt;php&gt;
          &lt;env name="APP_ENV" value="testing"/&gt;
          &lt;env name="CACHE_DRIVER" value="array"/&gt;
          &lt;env name="SESSION_DRIVER" value="array"/&gt;
          &lt;env name="QUEUE_DRIVER" value="sync"/&gt;
          &lt;env name="DB_CONNECTION" value="sqlite_testing" /&gt;
      &lt;/php&gt;
  &lt;/phpunit&gt;
  </code></pre>
  
  <p>I'm firing one of my test suites with the following command: </p>
  
  <pre><code>./vendor/phpunit/phpunit/phpunit --testsuite UnitTests
  </code></pre>
  
  <p>Inside my test method I have:</p>
  
  <pre><code>public function testAllMandatoryData()
  {
     dump(env('APP_ENV'));
     ....
  }
  </code></pre>
  
  <p>It's displaying "local" I was expecting "testing" as specified in phpunit.xml</p>
  
  <pre><code>         &lt;env name="APP_ENV" value="testing"/&gt;
  </code></pre>
  
  <p><strong>Edit: additional details</strong>
  I have this laravel application running in a Docker container</p>
  
  <p>On the docker-compose.yml I set some environment variables like:</p>
  
  <pre><code>environment:
    - APP_ENV=local
    - DB_HOST=192.168.0.22
    - DB_PORT=33306
    - DB_DATABASE=mydatabase
    - DB_USERNAME=homestead
    - DB_PASSWORD=homestead
  </code></pre>
  
  <p>What I've noticed is that directives in phpunit.xml like:</p>
  
  <pre><code>    &lt;env name="APP_ENV" value="testing"/&gt;
  </code></pre>
  
  <p>have no effect when the name is there in the docker-compose already.</p>
  
  <p>Instead if I add some not defined in docker-compose.yml will be correctly set at phpunit runtime, like:</p>
  
  <pre><code>    &lt;env name="DB_CONNECTION" value="sqlite_test"/&gt;
  </code></pre>
  
  <p><strong>end Edit</strong></p>
  
  <p>What I'm missing?</p>
  
  <p>Thanks</p>