We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Session in Unit testing

Hi,

I'm writing unit tests for my application. Is any way to use session during the unit tests?

My $di:

$di->set('session', function() {
    $session = new Phalcon\Session\Adapter\Files();
    if (session_status() == PHP_SESSION_NONE) {
        $session->start();
    }
    return $session;
});


98.9k

You probably need something like that because PHPUnit produces output and the session cannot be started by PHP/Phalcon.