atoum/stubs
IDE stubs for atoum providing PHPDoc annotations and full code completion without cluttering atoum’s core source. Install via Composer, use the atoum/mageekguy\atoum aliases in tests, and get richer autocompletion for the userland API.
## Getting Started
### Minimal Setup
1. **Installation**
Update the package to the latest version for PHP 8.4 compatibility and new namespace conventions:
```bash
composer require --dev atoum/stubs:^2.7.0
Ensure atoum/atoum is installed (minimum version supporting PHP 8.4). Verify compatibility with your Laravel version (tested with Laravel 10+).
Locate Stubs
Stubs are now fully reorganized under updated namespaces in vendor/atoum/stubs/src/:
atoum/stubs/ – Core framework stubs (new namespace structure).atoum/stubs/php/ – Generic PHP stubs (unchanged but may reference new namespaces).atoum/stubs/laravel/ – Laravel-specific stubs (if included; now aligned with atoum\stubs\laravel\ namespace).vendor/atoum/stubs/templates/ with PHP 8.4-compatible syntax.First Use Case Generate a Laravel model test with PHP 8.4-compatible syntax and new namespace conventions:
php vendor/bin/atoum --stub="UserTest" --namespace="Tests\Unit" --class="App\Models\User" --laravel
Output includes:
static::assertSame() instead of deprecated assertSame).static::mockery calls.use atoum\stubs\laravel\LaravelTestCase;).Stub Generation
static::assertEquals()).atoum\stubs\laravel\).static::app()->make()).
Example:php vendor/bin/atoum --stub="PostControllerTest" --namespace="Tests\Feature" --methods="store,index" --laravel
--template to override defaults with PHP 8.4-compatible templates:
php vendor/bin/atoum --stub="CustomTest" --template="tests/Stubs/custom.atoum" --namespace="Tests\Unit"
Ensure templates include:
use atoum\stubs\laravel\LaravelTestCase;
static::setLaravelEnvironment('testing');
Laravel-Specific Integrations
static::mockery->mock('overload:Illuminate\Support\Facades\Cache')
->shouldReceive('get')->andReturn(['data' => 'value']);
Use --facades="Cache,Auth" to include multiple facades in stubs.php vendor/bin/atoum --stub="UserRepositoryTest" --eloquent="App\Models\User" --laravel
Output includes:
static::assertDatabaseHas('users', ['email' => 'test@example.com']);
static::assertDatabaseMissing('users', ['deleted_at' => null]);
php vendor/bin/atoum --stub="CommandTest" --artisan="migrate:fresh" --laravel
Generates:
static::artisan()->call('migrate:fresh');
CI/CD Automation
--stub-all with PHP 8.4 flags:
php vendor/bin/atoum --stub-all --namespace="Tests\\Unit" --directory="app/Models" --laravel
# .github/workflows/test.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- run: composer require atoum/stubs:^2.7.0
- run: php vendor/bin/atoum --stub-all --namespace="Tests\\Unit" --laravel
--namespace to match your project (e.g., Tests\Unit or App\Tests\Feature).
Avoid conflicts with the new atoum\stubs\laravel\ namespace in stubs.--append to preserve custom logic when regenerating stubs:
php vendor/bin/atoum --stub="UserTest" --append --laravel
vendor/atoum/stubs/templates/ to tests/Stubs/ and referencing them.
Example template (tests/Stubs/custom.atoum):
<?php
namespace Tests\Unit;
use atoum\stubs\laravel\LaravelTestCase;
static::setLaravelEnvironment('testing');
Namespace Migration Issues
atoum\stubs\laravel\ namespace. Regenerating stubs without --namespace may cause conflicts.--namespace to match your project:
php vendor/bin/atoum --stub="UserTest" --namespace="App\\Tests\\Unit" --laravel
If using custom templates, ensure they reference the correct namespace:
// Old (may break)
use atoum\stubs\LaravelTestCase;
// New (required)
use atoum\stubs\laravel\LaravelTestCase;
PHP 8.4 Deprecations in Stubs
assertSame() instead of static::assertSame()).--laravel flag to enforce PHP 8.4 compliance.
Manually update existing stubs:
- assertSame($expected, $actual);
+ static::assertSame($expected, $actual);
Facade Mocking Quirks
--facades flag to auto-generate correct mockery calls:
php vendor/bin/atoum --stub="AuthTest" --facades="Auth" --laravel
Output:
static::mockery->mock('overload:Illuminate\Auth\Facades\Auth')
->shouldReceive('check')->andReturn(true);
Template Path Changes
tests/Stubs/ (not tests/atoum/Stubs/).mkdir -p tests/Stubs
mv tests/atoum/Stubs/* tests/Stubs/
Reference them with:
php vendor/bin/atoum --stub="CustomTest" --template="tests/Stubs/custom.atoum"
vendor/atoum/stubs/src/atoum/stubs/laravel/ (new path).
Use --verbose to debug:
php vendor/bin/atoum --stub="Test" --verbose --laravel
static::mockery and fully qualified facade names:
// Works
static::mockery->mock('overload:Illuminate\Support\Facades\Cache');
// Fails (deprecated)
$this->mockery->mock('overload:Cache');
use statements in generated stubs. Use --namespace to override defaults.atoum\stubs\laravel\LaravelTestCase by creating a custom stub template:
// tests/Stubs/CustomLaravelTestCase.atoum
<?php
How can I help you explore Laravel packages today?