test: Add unit tests for Session FileHandler - #10435
Open
gr8man wants to merge 2 commits into
Open
Conversation
gr8man
force-pushed
the
feature/session-file-handler-tests
branch
from
July 31, 2026 20:19
c95820f to
5a6106e
Compare
gr8man
force-pushed
the
feature/session-file-handler-tests
branch
from
July 31, 2026 20:33
ff3a113 to
e4a9039
Compare
gr8man
force-pushed
the
feature/session-file-handler-tests
branch
from
July 31, 2026 20:43
a6c9a5e to
7aad5ac
Compare
There was a problem hiding this comment.
Pull request overview
Adds unit tests and failure-injection helpers for the Session FileHandler.
Changes:
- Covers constructor, file operations, cleanup, and failure paths.
- Adds configurable stream and close-failure test doubles.
- Assumed
developbase; focused tests were not run.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
tests/system/Session/Handlers/FileHandlerTest.php |
Adds comprehensive handler tests. |
tests/_support/Session/FileHandlerCloseFail.php |
Simulates failed session closing. |
tests/_support/Session/FaultyStream.php |
Simulates stream operation failures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+27
to
+31
| public $context; | ||
| private static bool $failLock = false; | ||
| private static bool $failRead = false; | ||
| private static bool $failWrite = false; | ||
| private $stream; |
| ini_set('session.sid_bits_per_character', $this->originalSidBits); | ||
| ini_set('session.sid_length', $this->originalSidLength); | ||
|
|
||
| FaultyStream::reset(); |
Comment on lines
+111
to
+129
| * @return array<string, int> | ||
| */ | ||
| public function url_stat(): array | ||
| { | ||
| return [ | ||
| 'dev' => 0, | ||
| 'ino' => 0, | ||
| 'mode' => 0o100600, | ||
| 'nlink' => 1, | ||
| 'uid' => 0, | ||
| 'gid' => 0, | ||
| 'rdev' => 0, | ||
| 'size' => 5, | ||
| 'atime' => time(), | ||
| 'mtime' => time(), | ||
| 'ctime' => time(), | ||
| 'blksize' => -1, | ||
| 'blocks' => -1, | ||
| ]; |
| { | ||
| $dir = $this->tempPath . '/readonly'; | ||
| mkdir($dir, 0700); | ||
| chmod($dir, 0555); |
| { | ||
| $dir = $this->tempPath . '/unreadable'; | ||
| mkdir($dir, 0700); | ||
| chmod($dir, 0000); |
Comment on lines
+67
to
+69
| public function stream_write(string $data): false|int | ||
| { | ||
| return self::$failWrite ? false : fwrite($this->stream, $data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds unit tests for
system/Session/Handlers/FileHandler.php, reaching 100%statement and method coverage. No production code changed.
Checklist: