php-admin/tests/Pest.php
Claude 2e50e4e25e
test: add unit tests for Model methods
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>
2026-03-24 16:55:49 +00:00

39 lines
1.1 KiB
PHP

<?php
/*
* Core PHP Framework
*
* Licensed under the European Union Public Licence (EUPL) v1.2.
* See LICENSE file for details.
*/
declare(strict_types=1);
use Orchestra\Testbench\TestCase;
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| Feature tests use Orchestra Testbench to bootstrap a minimal Laravel
| application with SQLite in-memory database. This provides facades,
| Eloquent, and Schema support without needing the full application.
|
*/
uses(TestCase::class)->in('Feature');
/*
|--------------------------------------------------------------------------
| Package Autoloading
|--------------------------------------------------------------------------
|
| Register PSR-4 namespaces for package modules that sit outside the
| main Core\Admin\ autoload prefix. In CI these are resolved via the
| path repository configuration; locally we register them here.
|
*/
$loader = require __DIR__.'/../vendor/autoload.php';
$loader->addPsr4('Core\\Mod\\Hub\\', __DIR__.'/../src/Mod/Hub/');