function test_logout() { $_SESSION['active_user'] = array('name' => 'fred', 'id' => 1); $usr = new ctrl_users(); try { $usr->logout(); $this->fail(); } catch(exception $e) { $this->assertEquals(preg_match("/messages/", $e->getMessage()), 1); } $this->assertEquals($_SESSION, array()); }