@@ -344,6 +344,20 @@ public function testCanFlashData(): void
344344 $ this ->assertFalse ($ session ->has ('foo ' ));
345345 }
346346
347+ /**
348+ * @see https://github.com/codeigniter4/CodeIgniter4/pull/9535#discussion_r2052022296
349+ */
350+ public function testMarkAsFlashdataFailsWhenAtLeastOneKeyIsNotInSession (): void
351+ {
352+ $ session = $ this ->getInstance ();
353+ $ session ->start ();
354+
355+ $ session ->set (['foo1 ' => 'bar1 ' , 'foo2 ' => 'bar2 ' ]);
356+
357+ $ this ->assertFalse ($ session ->markAsFlashdata (['foo1 ' , 'foo2 ' , 'foo3 ' ]));
358+ $ this ->assertArrayNotHasKey ('__ci_vars ' , $ _SESSION );
359+ }
360+
347361 public function testCanFlashArray (): void
348362 {
349363 $ session = $ this ->getInstance ();
@@ -462,6 +476,20 @@ public function testSetTempDataArraySingleTTL(): void
462476 $ this ->assertLessThanOrEqual ($ _SESSION ['__ci_vars ' ]['baz ' ], $ time + 200 );
463477 }
464478
479+ /**
480+ * @see https://github.com/codeigniter4/CodeIgniter4/pull/9536#discussion_r2051798869
481+ */
482+ public function testMarkAsTempdataFailsWhenAtLeastOneKeyIsNotInSession (): void
483+ {
484+ $ session = $ this ->getInstance ();
485+ $ session ->start ();
486+
487+ $ session ->set (['foo1 ' => 'bar1 ' , 'foo2 ' => 'bar2 ' ]);
488+
489+ $ this ->assertFalse ($ session ->markAsTempdata (['foo1 ' , 'foo2 ' , 'foo3 ' ], 200 ));
490+ $ this ->assertArrayNotHasKey ('__ci_vars ' , $ _SESSION );
491+ }
492+
465493 public function testGetTestDataReturnsAll (): void
466494 {
467495 $ session = $ this ->getInstance ();
0 commit comments