test: add unit tests for Model methods #37

Open
Charon wants to merge 1 commit from feat/test-model-methods into dev
Member

Summary

  • Add 50 tests for HoneypotHit model (bot detection, severity classification, query scopes, getStats, mass assignment)
  • Add 45 tests for Service model (query scopes, findByCode, getDomainMappings, marketing URL accessor, metadata helpers, mass assignment)
  • Add tests/Pest.php to bootstrap Orchestra Testbench and register Core\Mod\Hub\ PSR-4 namespace
  • 117 total tests, 244 assertions, all passing

Fixes #8

Test plan

  • All 95 new tests pass locally (50 HoneypotHit + 45 Service)
  • All 22 existing MetadataValidationTest tests still pass
  • No changes to source code — tests only
## Summary - Add 50 tests for `HoneypotHit` model (bot detection, severity classification, query scopes, getStats, mass assignment) - Add 45 tests for `Service` model (query scopes, findByCode, getDomainMappings, marketing URL accessor, metadata helpers, mass assignment) - Add `tests/Pest.php` to bootstrap Orchestra Testbench and register `Core\Mod\Hub\` PSR-4 namespace - 117 total tests, 244 assertions, all passing Fixes #8 ## Test plan - [x] All 95 new tests pass locally (50 HoneypotHit + 45 Service) - [x] All 22 existing MetadataValidationTest tests still pass - [x] No changes to source code — tests only
Charon added 1 commit 2026-03-24 16:56:03 +00:00
Add comprehensive Pest tests for HoneypotHit and Service model methods:

HoneypotHitModelTest (50 tests):
- Bot detection (detectBot) for 15+ user agents incl. case-insensitive matching
- Severity classification (severityForPath, constants, configurable paths)
- Query scopes (recent, fromIp, bots, critical, warning) with chaining
- Model configuration (fillable, casts, constants)
- Mass assignment and persistence round-trips
- getStats aggregation (totals, unique IPs, top IPs/bots)

ServiceModelTest (45 tests):
- Query scopes (enabled, public, featured, ordered, withMarketingDomain) with chaining
- findByCode lookup and case sensitivity
- getDomainMappings filtering (disabled, missing domain/class)
- Marketing URL accessor fallback logic
- Metadata helpers (hasMeta, getMeta, setMeta) incl. key validation
- Model configuration (table, fillable, casts, constants)
- Mass assignment and persistence round-trips

Also adds tests/Pest.php to bootstrap Orchestra Testbench and register
the Core\Mod\Hub\ PSR-4 namespace for package module autoloading.

Fixes #8

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/test-model-methods:feat/test-model-methods
git checkout feat/test-model-methods

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout dev
git merge --no-ff feat/test-model-methods
git checkout feat/test-model-methods
git rebase dev
git checkout dev
git merge --ff-only feat/test-model-methods
git checkout feat/test-model-methods
git rebase dev
git checkout dev
git merge --no-ff feat/test-model-methods
git checkout dev
git merge --squash feat/test-model-methods
git checkout dev
git merge --ff-only feat/test-model-methods
git checkout dev
git merge feat/test-model-methods
git push origin dev
Sign in to join this conversation.
No description provided.