title: Save variable during unit testing Laravel
body: <p>Variable <code>$this-&gt;id</code> not visible in another function <code>testExemple</code></p>
  
  <p>If I pass this variable to a normal function that does not start on a “test” and not to a testing function, everything will work.</p>
  
  <p>Can I fix this somehow? </p>
  
  <pre><code>class LoginTest extends TestCase
  {
      protected $id;
      public function testLogin()
      {
          $response = $this-&gt;json('post', 'auth/login', 
              ['email' =&gt; 'admin@mail.com', 'password' =&gt; '12345678'])
              -&gt;assertJsonStructure(['data' =&gt; ['id', 'name', 'email']]);
  
          $response-&gt;assertStatus(201);
  
          $userData = $response-&gt;getContent();
          $userData = json_decode($userData, true);
          $this-&gt;id = $userData['data']['id'];
      }
      public function testExemple()
      {
          echo($this-&gt;id);
      }
  }
  </code></pre>