title: Laravel unit tests - changing a config value depending on test method
body: <p>I have an application with a system to verify accounts (register -> get email with link to activate -> account verified). That verification flow is optional and can be switched off with a configuration value:</p>
  
  <pre><code>// config/auth.php
  return [
    // ...
    'enable_verification' =&gt; true
  ];
  </code></pre>
  
  <p>I want to test the registration controller: </p>
  
  <ul>
  <li>it should redirect to home page in both cases</li>
  <li>when verification is ON, home page should show message 'email sent'</li>
  <li>when verification is OFF, home page should show message 'account created'</li>
  <li>etc.</li>
  </ul>
  
  <p>My test methods:</p>
  
  <pre><code>public function test_UserProperlyCreated_WithVerificationDisabled()
  {
      $this-&gt;app['config']-&gt;set('auth.verification.enabled', false);
  
      $this
          -&gt;visit(route('frontend.auth.register.form'))
          -&gt;type('Test', 'name')
          -&gt;type('test@example.com', 'email')
          -&gt;type('123123', 'password')
          -&gt;type('123123', 'password_confirmation')
          -&gt;press('Register');
  
      $this
          -&gt;seePageIs('/')
          -&gt;see(trans('auth.registration.complete'));
  }
  
  public function test_UserProperlyCreated_WithVerificationEnabled()
  {
      $this-&gt;app['config']-&gt;set('auth.verification.enabled', true);
  
      $this
          -&gt;visit(route('frontend.auth.register.form'))
          -&gt;type('Test', 'name')
          -&gt;type('test@example.com', 'email')
          -&gt;type('123123', 'password')
          -&gt;type('123123', 'password_confirmation')
          -&gt;press('Register');
  
      $this
          -&gt;seePageIs('/')
          -&gt;see(trans('auth.registration.needs_verification'));
  }
  </code></pre>
  
  <p>When debugging, I noticed that the configuration value when inside the controller method is always set to the value in the config file, no matter what I set with my <code>$this-&gt;app['config']-&gt;set...</code></p>
  
  <p>I have other tests on the user repository itself to check that it works both when validation is ON or OFF. And there the tests behave as expected.</p>
  
  <p><strong>Any idea why it fails for controllers and how to fix that?</strong></p>