Skip to content

Commit 87d1af4

Browse files
committed
forgot the getAll() method
1 parent 3eba808 commit 87d1af4

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/Session.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,16 @@ public function clear(): self
311311
return $this;
312312
}
313313

314+
/**
315+
* Retrieve all session data.
316+
*
317+
* @return array An associative array containing all session data.
318+
*/
319+
public function getAll(): array
320+
{
321+
return $this->data;
322+
}
323+
314324
/**
315325
* Commits the current session data and writes it to the storage.
316326
*

tests/SessionTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,26 @@ public function testWriteWithNoChanges(): void
477477
$result = $writeMethod->invoke($session, $sessionId, 'data');
478478
$this->assertTrue($result);
479479
}
480-
}
480+
481+
public function testGetAll(): void
482+
{
483+
$session = new Session([
484+
'save_path' => $this->tempDir,
485+
'encryption_key' => null,
486+
'auto_commit' => false,
487+
'start_session' => false,
488+
'test_mode' => true
489+
]);
490+
491+
$session->set('key1', 'value1');
492+
$session->set('key2', 'value2');
493+
494+
$expectedData = [
495+
'key1' => 'value1',
496+
'key2' => 'value2'
497+
];
498+
499+
$this->assertEquals($expectedData, $session->getAll());
500+
}
501+
502+
}

0 commit comments

Comments
 (0)