title: PHPUNIT Test - Expected Status 200 But Received 500
body: <p>I keep getting status 500 when 200 is expected. These are the files:</p>
  
  <p><strong>ExampleTest.php</strong></p>
  
  <pre><code>namespace Tests\Feature;
  
  use Tests\TestCase;
  use Illuminate\Foundation\Testing\RefreshDatabase;
  
  class ExampleTest extends TestCase
  {
      /**
       * A basic test example.
       *
       * @return void
       */
      public function testBasicTest()
      {
          $response = $this-&gt;get('/');
  
          $response-&gt;assertStatus(200);
      }
  }
  </code></pre>
  
  <p><strong>phpunit.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;phpunit backupGlobals="false"
           backupStaticAttributes="false"
           bootstrap="vendor/autoload.php"
           colors="true"
           convertErrorsToExceptions="true"
           convertNoticesToExceptions="true"
           convertWarningsToExceptions="true"
           processIsolation="false"
           stopOnFailure="false"&gt;
      &lt;testsuites&gt;
          &lt;testsuite name="Unit"&gt;
              &lt;directory suffix="Test.php"&gt;./tests/Unit&lt;/directory&gt;
          &lt;/testsuite&gt;
  
          &lt;testsuite name="Feature"&gt;
              &lt;directory suffix="Test.php"&gt;./tests/Feature&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="BCRYPT_ROUNDS" value="4"/&gt;
          &lt;env name="CACHE_DRIVER" value="array"/&gt;
          &lt;env name="SESSION_DRIVER" value="array"/&gt;
          &lt;env name="QUEUE_CONNECTION" value="sync"/&gt;
          &lt;env name="MAIL_DRIVER" value="array"/&gt;
      &lt;/php&gt;
  &lt;/phpunit&gt;
  </code></pre>
  
  <p><strong>This is the result returned</strong></p>
  
  <pre><code>PHPUnit 7.4.0 by Sebastian Bergmann and contributors.
  
  .F                                                                  2 / 2 (100%)
  
  Time: 1.86 seconds, Memory: 20.00MB
  
  There was 1 failure:
  
  1) Tests\Feature\ExampleTest::testBasicTest
  Expected status code 200 but received 500.
  Failed asserting that false is true.
  
  /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:133
  /var/www/html/tests/Feature/ExampleTest.php:19
  
  FAILURES!
  Tests: 2, Assertions: 2, Failures: 1.
  </code></pre>
  
  <p><strong>This is the Laravel log file</strong></p>
  
  <pre><code>[2018-10-15 20:56:09] testing.ERROR: Call to a member function load() on null (View: /var/www/html/resources/views/app.blade.php) {"exception":"[object] (ErrorException(code: 0): Call to a member function load() on null (View: /var/www/html/resources/views/app.blade.php) at /var/www/html/app/Ezybyz/Configuration/ProvidesScriptVariables.php:46, Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function load() on null at /var/www/html/app/Ezybyz/Configuration/ProvidesScriptVariables.php:46)
  </code></pre>
  
  <p><strong>app.blade.php</strong></p>
  
  <pre><code>@php
  $config = array_merge(
      Ezybyz::scriptVariables(), [
          // Add key and value here if you want to added to initial state
      ]
  )
  @endphp
  
  @extends('layouts.main')
  
  @push('meta')
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"&gt;
  &lt;meta name="csrf-token" content="{{ csrf_token() }}"&gt;
  {{-- Fix for chunk error in Webpack and Vue-Router --}}
  &lt;base href="/" /&gt;
  @endpush
  
  @push('favicon')
  &lt;link rel="shortcut icon" href="{{ asset('favicon.ico?v=2') }}" type="image/x-icon" /&gt;
  @endpush
  
  @push('css')
  &lt;link rel="stylesheet" href="{{ mix('css/app.css') }}"&gt;
  @endpush
  
  @push('header_js')
  {{--  EzyByz initial state provider --}}
  &lt;script&gt;
    window.App = @json($config)
  &lt;/script&gt;
  {{-- Add whitelisted routes for making API calls --}}
  @routes
  @endpush
  
  @push('title')
  &lt;title&gt;{{ config('app.name') }} &lt;/title&gt;
  @endpush
  
  @section('content')
  &lt;div id="app" v-cloak&gt;
      &lt;app /&gt;
  &lt;/div&gt;
  @endsection
  
  @push('footer_js')
  @if(config('echo.realtime'))
  {{-- Load socket.io --}}
  &lt;script src="//{{ Request::getHost() }}:6001/socket.io/socket.io.js" defer&gt;&lt;/script&gt;
  @endif
  
  &lt;script src="{{ mix('js/manifest.js') }}" defer&gt;&lt;/script&gt;
  &lt;script src="{{ mix('js/vendor.js') }}" defer&gt;&lt;/script&gt;
  &lt;script src="{{ mix('js/app.js') }}" defer&gt;&lt;/script&gt;
  @endpush
  </code></pre>
  
  <p><strong>ProvidesScriptVariables.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Ezybyz\Configuration;
  
  use App\Ezybyz\Ezybyz;
  use Illuminate\Support\Facades\Auth;
  use App\Ezybyz\Contracts\InitialFrontendState;
  
  trait ProvidesScriptVariables
  {
      /**
       * Get the default JavaScript variables for Spark.
       *
       * @return array
       */
      public static function scriptVariables()
      {
          return [
              'csrfToken' =&gt; csrf_token(),
              'env' =&gt; config('app.env'),
              'api_endpoint' =&gt; config('ezybyz.app.api'),
              'sponsor' =&gt; self::getSponsor(),
          ];
      }
  
      protected static function getState()
      {
          return Ezybyz::call(InitialFrontendState::class . '@forUser', [Auth::user()]);
      }
  
      protected static function getSponsor()
      {
          if ($link = request()-&gt;referrallink) {
              $user = Ezybyz::user()-&gt;find($link-&gt;user_id);
  
              return [
                  'user_id' =&gt; $user-&gt;id,
                  'first_name' =&gt; $user-&gt;first_name,
                  'last_name' =&gt; $user-&gt;last_name,
                  'email' =&gt; $user-&gt;email,
                  'profile' =&gt; $user-&gt;profile,
              ];
          }
          // We Will Return a Default Sponsor
          else {
              $user = Ezybyz::user()-&gt;first()-&gt;load('profile');
  
              return [
                  'user_id' =&gt; $user-&gt;id,
                  'first_name' =&gt; $user-&gt;first_name,
                  'last_name' =&gt; $user-&gt;last_name,
                  'email' =&gt; $user-&gt;email,
                  'profile' =&gt; $user-&gt;profile,
              ];
          }
      }
  }
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>