<commit_before><?php

namespace DaMess\Test\Http;

use Aura\Session\Session;
use DaMess\Http\SessionMiddleware;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Request;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;

class SessionMiddlewareTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Session
     */
    protected $session;

    public function setUp()
    {
        $this->session = $this->prophesize(Session::class);
    }

    public function testSessionStarts()
    {
        $next = function(ServerRequestInterface $request) {
            $this->assertInstanceOf(Session::class, $request->getAttribute('session'));
        };

        $this->session->start()->shouldBeCalled();
        $middleware = new SessionMiddleware($this->session->reveal());
        $middleware->__invoke(new ServerRequest(), new Response(), $next);
    }
}<commit_msg>Fixing unit test for checking if the session is already started<commit_after><?php

namespace DaMess\Test\Http;

use Aura\Session\Session;
use DaMess\Http\SessionMiddleware;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Request;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;

class SessionMiddlewareTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Session
     */
    protected $session;

    public function setUp()
    {
        $this->session = $this->prophesize(Session::class);
    }

    public function testSessionStarts()
    {
        $next = function(ServerRequestInterface $request) {
            $this->assertInstanceOf(Session::class, $request->getAttribute('session'));
        };

        $this->session->isStarted()->shouldBeCalled();
        $this->session->start()->shouldBeCalled();
        $middleware = new SessionMiddleware($this->session->reveal());
        $middleware->__invoke(new ServerRequest(), new Response(), $next);
    }
}
{'fraction_non_alphanumeric': 0.13242249080399368, 'fraction_numerical': 0.0, 'mean_word_length': 3.632603406326034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4135655', 'n_tokens_mistral': 553, 'n_tokens_neox': 540, 'n_words': 101}