title: Laravel Unit Test (The response is not a view)
body: <p>I am doing unit testing to my web application. My experience with Laravel and PHP Unit Testing too young. Now, I am just fiddling around with the Laravel Unit test. Now, I am testing if a view returned to the route contains specific text. Very simple. This is what I have done.</p>
  
  <p>I created a view called, unit_test.blade.php with the following content</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      This is unit test
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the route to display that view</p>
  
  <pre><code>Route::get('unit/test', function(){
     return view('unit_test');
  });
  </code></pre>
  
  <p>This is my test class and function</p>
  
  <pre><code>class ApiV2EventController extends TestCase
  {
  
  
      public function testUnitTest()
      {
          $response = $this-&gt;get('unit/test');
  
          $response-&gt;assertViewHas('unit');
      }
  }
  </code></pre>
  
  <p>My test function is simple. It is just checking if the view contains the text, "unit". But when I run the test in the command line, it is giving </p>
  
  <pre><code>There was 1 failure:
  
  1) Tests\Feature\ApiV2EventController::testUnitTest
  The response is not a view.
  </code></pre>
  
  <p>I am returning the view in the route. What is wrong with my code? How can I test it?</p>