testo/inline
Inline test plugin for Testo: mark methods as tests via PHP attributes, without separate test classes. Ideal for quick checks near production code and self-documenting examples. Install with composer require --dev testo/inline.
#[Test] in app/Domain/Entities/User.php).app/Helpers/StringHelper.php).phpunit.xml, Tests/TestCase). This could necessitate:
app/Services/).testo.php and phpunit.xml, risking misconfigurations.refreshDatabase(), withoutMiddleware(), or Artisan test runners.Auth or Cache). Testo lacks Laravel’s built-in isolation mechanisms.Auth::logout(), Cache::flush()) before/after inline tests.testo.php + phpunit.xml) and resolve conflicts (e.g., test naming, coverage reporting)?app/Domain/Services/PaymentService.php).app/Helpers/ArrayHelper.php).#[Test] methods in app/Console/Commands/).HttpTests with PHPUnit (Testo lacks actingAs(), route() helpers).refreshDatabase(), migrate:fresh, or Eloquent model factories.BrowserKit.Phase 1: Proof of Concept (1–2 Weeks)
composer require --dev testo/testo testo/inline
Configure testo.php with minimal settings (mirror Laravel’s phpunit.xml where possible):
return [
'paths' => [__DIR__.'/../app'],
'bootstrap' => __DIR__.'/../bootstrap/app.php',
];
StringHelper, ValueObject).// Before (PHPUnit)
class StringHelperTest extends TestCase {
public function test_truncate() { ... }
}
// After (Testo/Inline)
class StringHelper {
#[Test]
public function truncate_returns_expected_string() { ... }
}
Phase 2: Hybrid Integration (2–4 Weeks)
composer.json to support both runners:
"scripts": {
"test": "phpunit",
"test:testo": "vendor/bin/testo",
"test:all": "php vendor/bin/phpunit && php vendor/bin/testo"
}
TestSuite alongside PHPUnit’s @group:
// tests/TestSuite/DomainSuite.php
use Testo\TestSuite;
return new TestSuite([
app(Domain\Entities\User::class),
app(Domain\Services\PaymentService::class),
]);
- name: Run Testo
run: php vendor/bin/testo
TESTING.md guide explaining:
Phase 3: Gradual Replacement (Ongoing)
#[Test] with Testo’s #[Test] for new features in domain logic.@deprecated in favor of inline tests).| Laravel Feature | Testo/Inline Support | Workaround | Risk Level |
|---|---|---|---|
| Database transactions | ❌ No | Manual DB::beginTransaction() + rollback in setUp()/tearDown(). |
High |
| HTTP testing | ❌ No | Use PHPUnit’s HttpTests or Testo’s Client (limited features). |
Critical |
| Authentication | ❌ No | Mock Auth facade or manually set auth()->user(). |
Medium |
| Middleware testing | ❌ No | Disable middleware globally or |
How can I help you explore Laravel packages today?