/** * Ensure that subsequent reads without the necessary write do not report data */ public function testReadInvalidatesData() { $session = uniqid(); $store = $this->getStore(); // Test new session is blank $result = $store->read($session); $this->assertEmpty($result); // Save data against session $data1 = array('Color' => 'red', 'Animal' => 'elephant'); $store->write($session, serialize($data1)); $result = $store->read($session); $this->assertEquals($data1, unserialize($result)); // Since we have read the data into the result, the application could modify this content // and be unable to write it back due to headers being sent. We should thus assume // that subsequent reads without a successful write do not purport to have valid data $data1['Color'] = 'blue'; $result = $store->read($session); $this->assertEmpty($result); // Check that writing to cookie fails after headers are sent and these results remain // invalidated HybridSessionAbstractTest_TestCookieBackend::$override_headers_sent = true; $store->write($session, serialize($data1)); $result = $store->read($session); $this->assertEmpty($result); }
public function setUp() { parent::setUp(); HybridSessionAbstractTest_TestCookieBackend::$override_headers_sent = false; Injector::nest(); Injector::inst()->registerService(new HybridSessionAbstractTest_TestCookieBackend(), 'HybridSessionStore_Cookie'); SS_Datetime::set_mock_now('2010-03-15 12:00:00'); if (get_class() === get_class($this)) { $this->markTestSkipped("Skipping abstract test"); $this->skipTest = true; } }