public function testFlashes() { // Test data $test_session_key = '__flashes'; $test_flashes = array(array('message' => 'Test info message', 'type' => 'info'), array('message' => 'Test error message', 'type' => 'error'), array('message' => 'Test second error message', 'type' => 'error'), array('message' => 'Test whatever message', 'type' => 'whatever')); $test_error_flashes = array($test_flashes[1]['message'], $test_flashes[2]['message']); $service = new ServiceProvider(); $this->assertEmpty($_SESSION); $this->assertEmpty($service->flashes()); $service->flash($test_flashes[0]['message'], $test_flashes[0]['type']); $service->flash($test_flashes[1]['message'], $test_flashes[1]['type']); $service->flash($test_flashes[2]['message'], $test_flashes[2]['type']); $service->flash($test_flashes[3]['message'], $test_flashes[3]['type']); // Test error flashes only $error_flashes = $service->flashes('error'); $this->assertCount(2, $error_flashes); $this->assertSame($test_error_flashes, $error_flashes); // Test the rest $all_flashes = $service->flashes(); $this->assertCount(count($test_flashes) - count($error_flashes), $all_flashes); // Clean up session_destroy(); $_SESSION = array(); }