title: Laravel 5 PHPUnit Testing - Wrapping All Tests Within a Controller Into a Single Transaction
body: <p>I have the following test file in my Laravel application:</p>
  
  <p>
  
  <pre><code>use Illuminate\Foundation\Testing\WithoutMiddleware;
  use Illuminate\Foundation\Testing\DatabaseMigrations;
  use Illuminate\Foundation\Testing\DatabaseTransactions;
  
  class ApiAuthControllerTest extends TestCase{
  
      use DatabaseTransactions;
  
      public function testLogin(){
  
          // Test login success
          $response = $this-&gt;json('POST', '/login', array(
              'email' =&gt; 'hello@yahoo.com',
              'password' =&gt; 'sometext'
          ))-&gt;decodeResponseJson();
          return $response['token'];
  
      }
  
     /**
       * @depends testLogin
       */
      public function testLogout($token){
  
          // Test logout success
          $this-&gt;json('DELETE', '/logout', array(
              'token' =&gt; $token
          ))-&gt;assertReponseStatus(200);
  
      }
  
  }
  </code></pre>
  
  <p>I am using the <code>DatabaseTransactions</code> class to wrap my tests as transactions so they don't write to my database.  I noticed that using this class will wrap every individual test within my class as a transaction.  </p>
  
  <p>I would like to wrap the entire class as a transaction.  In my example above, I need for the token that was generated from my login request to be persistent in the database as I test the logout request.</p>
  
  <p>How would I do this with Laravel?</p>