I\'m currently working with PHPUnit to try and develop tests alongside what I\'m writing, however, I\'m currently working on writing the Session Manager, and am having issue
I think the "right" solution is to create a very simple class (so simple it doesn't need to be tested) that's a wrapper for PHP's session-related functions, and use it instead of calling session_start()
, etc. directly.
In the test pass mock object instead of a real stateful, untestable session class.
private function __construct(SessionWrapper $wrapper)
{
if (!$wrapper->headers_sent())
{
$wrapper->session_start();
$this->session_id = $wrapper->session_id();
}
}