test: add comprehensive unit test coverage across all major components - #153
test: add comprehensive unit test coverage across all major components#153MaximillianGroup with Copilot wants to merge 10 commits into
Conversation
Agent-Logs-Url: https://github.com/Starisian-Technologies/sparxstar-user-environment-check/sessions/d987c0ef-b328-4c25-af26-708f3dc8cf3e Co-authored-by: MaximillianGroup <34328348+MaximillianGroup@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Starisian-Technologies/sparxstar-user-environment-check/sessions/d987c0ef-b328-4c25-af26-708f3dc8cf3e Co-authored-by: MaximillianGroup <34328348+MaximillianGroup@users.noreply.github.com>
|
@copilot - still having this error - Run pnpm install --frozen-lockfile Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile" Error: Process completed with exit code 1. |
Agent-Logs-Url: https://github.com/Starisian-Technologies/sparxstar-user-environment-check/sessions/5ab0a2c9-87e2-4148-a2d0-ce60c7bec707 Co-authored-by: MaximillianGroup <34328348+MaximillianGroup@users.noreply.github.com>
Fixed in aa12459. The |
There was a problem hiding this comment.
Pull request overview
This PR expands isolated PHPUnit coverage for major SPARXSTAR UEC components and extends the shared WordPress test bootstrap with additional stubs needed by those tests.
Changes:
- Adds new unit tests for database, REST, logging, scheduler, session, repository, GeoIP, installer deactivation, and StarUserEnv getters.
- Expands
tests/bootstrap-unit.phpwith WordPress constants, class stubs, transient helpers, and updatedwpdb::get_row()compatibility. - Updates PHPUnit result cache metadata.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/bootstrap-unit.php |
Adds WP test shims and transient storage support. |
tests/unit/SparxstarUECDatabaseTest.php |
Covers schema, table naming, snapshot storage, and cleanup paths. |
tests/unit/SparxstarUECGeoIPServiceTest.php |
Covers provider selection, invalid IPs, and transient cache behavior. |
tests/unit/SparxstarUECInstallerDeactivateTest.php |
Covers single-site and multisite deactivation cleanup. |
tests/unit/SparxstarUECRESTControllerTest.php |
Covers permission checks and REST request handling. |
tests/unit/SparxstarUECSchedulerTest.php |
Covers cron interval mapping, scheduling, deduplication, and clearing. |
tests/unit/SparxstarUECSessionManagerTest.php |
Covers dot-path lookup and session manager stubs. |
tests/unit/SparxstarUECSnapshotRepositoryTest.php |
Covers null guards and cache flushing. |
tests/unit/StarLoggerTest.php |
Covers logging levels, sanitization, wrappers, correlation IDs, and timers. |
tests/unit/StarUserEnvGettersTest.php |
Covers public snapshot getters and server-side helper methods. |
.phpunit.result.cache |
Updates generated PHPUnit cache metadata. |
Files not reviewed (1)
- .phpunit.result.cache: Language not supported
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
…rror code in REST controller test Agent-Logs-Url: https://github.com/Starisian-Technologies/sparxstar-user-environment-check/sessions/ff12c0e0-a034-4363-aff1-c87916605e9d Co-authored-by: MaximillianGroup <34328348+MaximillianGroup@users.noreply.github.com>
Applied in 9076a35:
All 153 tests still pass (212 assertions). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 13 changed files in this pull request and generated 3 comments.
Files not reviewed (2)
- .phpunit.result.cache: Language not supported
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
tests/unit/StarUserEnvGettersTest.php:535
- This test locks in the current misclassification of iPhone user agents as Mac instead of covering the intended iOS branch in getUserOS. Update it to assert iOS detection (or isolate the production bug as an expected-failure/TODO) so the new suite does not prevent correcting mobile OS detection later.
public function test_get_user_os_returns_mac_for_ios_ua(): void
{
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)';
// 'mac os x' matches before 'iphone' in the ordered pattern map.
$this->assertSame('Mac', StarUserEnv::getUserOS());
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
… add 200-success REST controller test Agent-Logs-Url: https://github.com/Starisian-Technologies/sparxstar-user-environment-check/sessions/18c0bbd3-d338-4608-94df-c4b9df3d8c17 Co-authored-by: MaximillianGroup <34328348+MaximillianGroup@users.noreply.github.com>
Applied in 99c8502:
All 154 tests pass (217 assertions). |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Max Barrett <34328348+MaximillianGroup@users.noreply.github.com>
| * An Android User-Agent string with a Linux token is currently classified as 'Linux'. | ||
| */ | ||
| public function test_get_user_os_detects_android(): void | ||
| { | ||
| $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36'; | ||
|
|
||
| $this->assertSame('Linux', StarUserEnv::getUserOS()); |
There was a problem hiding this comment.
Updated in 25b9212: this test now expects Android, matching the updated getUserOS() ordering.
| * An iPhone User-Agent string currently matches the Mac pattern first and is classified as 'Mac'. | ||
| */ | ||
| public function test_get_user_os_detects_ios(): void | ||
| { | ||
| $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)'; | ||
|
|
||
| $this->assertSame('Mac', StarUserEnv::getUserOS()); |
There was a problem hiding this comment.
Updated in 25b9212: this test now expects iOS, matching the updated getUserOS() ordering.
…dering Agent-Logs-Url: https://github.com/Starisian-Technologies/sparxstar-user-environment-check/sessions/02d60a49-2c5c-4b05-bc8b-1ba1bdb5e14f Co-authored-by: MaximillianGroup <34328348+MaximillianGroup@users.noreply.github.com>
The
The remaining open items from that review thread were addressed in
Fixed in |
tests/bootstrap-unit.phppnpm-lock.yamlout-of-sync withpackage.json(rollup^4.60.1→^4.60.2).phpunit.result.cacheto.gitignoreand remove from git trackingSparxstarUECRESTControllerTest: split into error-path (db_table_missing) and success-path (seeded wpdb stub returns a200 WP_REST_Responsewithstatus=ok,action=inserted)getUserOS()map ordering insrc/StarUserEnv.php: more-specific UA patterns (Windows Phone, iOS, Android) now precede generic ones (Windows, Mac, Linux)StarUserEnvGettersTest.php: update Android/iOS test assertions and docblocks to match correctedgetUserOS()behavior (Android UA →'Android', iOS UA →'iOS')