Laravel 5.0 Unit Testing problems with Session variables
<p>I am trying to do some unit testing on some existing code. My controller looks something like</p>

<pre><code>class DefaultController extends Controller
{
    public function index() {
        if (!Session::get('answers', [])) {
            App::abort(403, 'Error.');
        }

        // Do rest of the stuff here
    }
}
</code></pre>

<p>and my test class looks something like</p>

<pre><code>class DefaultController extends extends TestCase {
    public function testIndex_withoutSession() {
        // Arrange
        /* Nothing to arrange now */

        // Act
        $this-&gt;action('GET', 'DefaultController@index');

        // Assert
        $this-&gt;assertResponseStatus(403);
    }

    public function testIndex_withSession() {
        // Arrange
        $this-&gt;session(['answers' =&gt; array()]);

        // Act
        $this-&gt;action('GET', 'ParticipantController@create');

        $this-&gt;assertSessionHas('answers');
        // this function is giving true

        // Assert
        $this-&gt;assertResponseStatus(200);

        $this-&gt;flushSession();
    }
}
</code></pre>

<p>My test cases without the session is working fine but when I want to check it by mocking the session variable 'answers' it is still giving me the error. Can anyone please help me out by figuring what am I doing wrong or how can I do it properly? Without this I cannot proceed any further in checking the code.
Thanks in advance.</p>