Welcome Guest, Not a member yet? Register   Sign In
Testing with session
#1

Hello,

I'm trying to test an "Auth" library I created. Obviously, that library uses the session.

My first test looks like this:

PHP Code:
public function testConstructor()
{
    $auth = new Auth();
    $this->assertInstanceOf(\App\Libraries\Auth\Auth::class, $auth);
    $this->assertNull(service('session')->get('user'));


See the line where I ask if $_SESSION['user'] does not exist? That line produces an error:

Code:
ErrorException: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

If I understand it correctly, that means "session_start()" hasn't been called before the first "echo".

I see two possibilities:
Which is the correct solution? What are the best practices? and how do I do that?

Thanks in advance!
Reply


Messages In This Thread
Testing with session - by SteeveDroz - 10-27-2019, 12:05 AM
RE: Testing with session - by John_Betong - 10-27-2019, 08:18 PM
RE: Testing with session - by SteeveDroz - 10-27-2019, 10:31 PM
RE: Testing with session - by John_Betong - 10-28-2019, 01:49 AM
RE: Testing with session - by kilishan - 10-28-2019, 06:34 AM
RE: Testing with session - by SteeveDroz - 10-30-2019, 12:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB