title: Testing methods and controllers with Laravel 5 [phpunit]
body: <p>I am tring to make test for my project, could someone show me example how to write tests or give me some good video course to learn testing.</p>
  
  <p>In my example I am tring to test this part:</p>
  
  <pre><code>public function getProjectsForUser(){
          if(Auth::user() -&gt; admin_id == NULL){
              $this-&gt;id = Auth::user() -&gt; id;
          }else{
              $this-&gt;id = Auth::user() -&gt; admin_id;
          }
          $projects = User::findOrFail(Auth::user() -&gt; id)-&gt;projects()-&gt;where('admin_id', '=', $this-&gt;id)-&gt;get();
  
          $role = User::findOrFail(Auth::user() -&gt; id)-&gt;roles;
  
          $users = User::where('admin_id', '=', $this-&gt;id)-&gt;lists('name','id');
  
          return array('projects' =&gt; $projects,'users' =&gt; $users,'roles' =&gt; $role );
  }
  </code></pre>
  
  <p>It was my model Project.php</p>
  
  <p>Here is my PorojectController:</p>
  
  <pre><code>public function project(Project $projects){
              $this -&gt; projects = $projects -&gt;getProjectsForUser();
              return view('projects',$this -&gt; projects);
          }
  </code></pre>
  
  <p>Here is my test to check if user logged...</p>
  
  <pre><code>public function testHome()
          {
              $this-&gt;be(User::find(1));
              $response = $this-&gt;call('GET', '/projects');
              //CHECK IF AUTH USER
              $this-&gt;assertTrue($response-&gt;isOk());
  
      }
  </code></pre>
  
  <p>Now I need to check if I get right values inside array, for $project, $role, $users.</p>