nette/tester
Nette Tester is a lightweight PHP unit testing framework with simple assertions, clear output, and easy CLI running. It supports writing isolated tests, reporting failures nicely, and integrates well into CI pipelines for fast, reliable test suites.
Strengths:
--parallel).phpunit or pest coverage tools.Assert::hasKey(), DomQuery for HTML testing) complement Laravel’s testing needs (e.g., Blade templates, API responses).Gaps:
actingAs(), followRedirects()). Would require custom wrappers or integration with Laravel’s Http/Database testing utilities.--debug or Pest’s --verbose for Laravel’s service container inspection.Pros:
phpunit.xml with minimal config changes (e.g., autoload-dev adjustments).artisan test command via custom aliases or wrapper scripts.@dataProvider (similar to Pest’s with()), useful for Laravel’s Eloquent model factories.FileMock, PhpInterpreter, and DomQuery can mock files, HTTP responses, and HTML—useful for Laravel’s file-based caching or Blade testing.Cons:
php.ini shift may require Laravel’s phpunit.xml to explicitly set tester.ini or use --ini flags.assertDatabaseHas()). Would need custom assertions or composition with Laravel’s DatabaseMigrations trait.stream_select(); older Laravel stacks (PHP 8.1–8.3) may need adjustments.High:
test() vs. it(), Assert::equal() vs. assertEquals()) could introduce bugs.laravel/testbench or spatie/laravel-test-factory may not work out-of-the-box.Medium:
Low:
assertRouteIs(), assertSessionHasErrors())?Laravel Core:
phpunit/phpunit or pestphp/pest in composer.json. Requires updating phpunit.xml to use Tester’s bootstrap.artisan command or alias to run Tester (e.g., php artisan tester).Assert facade.Tooling:
tester instead of phpunit. Example:
# GitHub Actions
- run: composer require --dev nette/tester
- run: ./vendor/bin/tester tests/
phpdoc annotations.Database:
FileMock can mock database files, but Laravel’s DatabaseMigrations trait would need a wrapper.setUp()/tearDown() to wrap Laravel’s DatabaseTransactions trait.Phase 1: Pilot Project
assertJson() with Tester’s Assert::json() or HttpAssert.Phase 2: Hybrid Setup
# Run Tester for unit tests
./vendor/bin/tester tests/Unit/
# Run PHPUnit for feature tests
./vendor/bin/phpunit tests/Feature/
Phase 3: Full Migration
console-lines mode for incremental adoption.Laravel Versions:
Dependencies:
dom, fileinfo, etc. Laravel’s default stack should cover these.Configuration:
<php>
<ini name="tester.ini" value="path/to/tester.ini"/>
<env name="APP_ENV" value="testing"/>
</php>
Assert class for Laravel-specific checks:
// app/Tests/TesterExtensions/Assert.php
namespace App\Tests\TesterExtensions;
use Tester\Assert;
class LaravelAssert extends Assert {
public static function routeIs(string $routeName) {
// Custom logic using Laravel's Router
}
}
Pre-Migration:
RefreshDatabase, CreateApplication).Parallel Testing:
--parallel flag../vendor/bin/tester --parallel tests/Unit/ --coverage-src=app/
Post-Migration:
Pros:
test() syntax is more concise than PHPUnit’s public function test_* methods.Cons:
How can I help you explore Laravel packages today?