@@ -224,6 +224,36 @@ public function testRemoveSegment(){
224224 $ this ->assertArrayNotHasKey ($ this ->name , $ _SESSION );
225225 }
226226
227+ /**
228+ * A flash value set for the *next* request must be readable via getFlash()
229+ * in the following request. resumeSession() has to run *before* the value
230+ * is read so that Session::moveFlash() promotes FLASH_NEXT to FLASH_NOW.
231+ *
232+ * Regression guard for GitHub PR #68, which reordered getFlash() to read
233+ * the value before resuming the session; that always returns the alternate
234+ * (null) here because FLASH_NOW is still empty at read time.
235+ */
236+ public function testGetFlashResumesSessionBeforeReading ()
237+ {
238+ // ---- request 1: set a flash for the next request ----
239+ $ this ->segment ->setFlash ('foo ' , 'bar ' );
240+ $ this ->assertSame ('bar ' , $ _SESSION [Session::FLASH_NEXT ][$ this ->name ]['foo ' ]);
241+ // not visible via getFlash() in the same request (reads FLASH_NOW)
242+ $ this ->assertNull ($ this ->segment ->getFlash ('foo ' ));
243+
244+ $ name = $ this ->session ->getName ();
245+ $ id = $ this ->session ->getId ();
246+ $ this ->session ->commit ();
247+
248+ // ---- request 2: brand new Session object so flash_moved is false ----
249+ $ cookies = array ($ name => $ id );
250+ $ session = $ this ->newSession ($ cookies );
251+ $ segment = $ session ->getSegment ($ this ->name );
252+
253+ // getFlash() resumes, promotes FLASH_NEXT -> FLASH_NOW, and returns it
254+ $ this ->assertSame ('bar ' , $ segment ->getFlash ('foo ' ));
255+ }
256+
227257 public function testRestartSessionFlashNotMove ()
228258 {
229259 $ this ->assertFalse ($ this ->session ->isStarted ());
0 commit comments