This directory contains tests for the Vantage queue monitoring package.
# Run all tests
composer test
# Run with Pest directly
./vendor/bin/pest
# Run with coverage
./vendor/bin/pest --coverage
# Run specific test file
./vendor/bin/pest tests/Unit/VantageJobTest.php
# Run in parallel (faster)
./vendor/bin/pest -p- VantageJobTest.php: Tests for the VantageJob model
- Model creation and attributes
- Relationship tests (retries, retriedFrom)
- Scope methods (withTag, failed, successful, etc.)
- Helper methods (hasTag, formatted_duration)
-
JobListenersTest.php: Integration tests for queue event listeners
- Recording job start
- Recording job success with duration calculation
- Recording job failures with exception details
- Retry chain tracking
- Tag extraction and storage
-
QueueMonitorControllerTest.php: Tests for web interface
- Dashboard statistics
- Job listing and filtering
- Individual job details
- Retry chain display
- Tag filtering
- Failed jobs page
-
RoutePrefixTest.php: Verifies custom route prefix configuration serves the dashboard correctly
Use the artisan command to generate test jobs for load testing:
# Generate 100 test jobs (default)
php artisan vantage:generate-test-jobs
# Generate 1000 jobs with 90% success rate
php artisan vantage:generate-test-jobs --count=1000 --success-rate=90
# Generate jobs with custom tags
php artisan vantage:generate-test-jobs --count=500 --tags=load-test,production,email
# Generate jobs with variable duration (10ms to 10 seconds)
php artisan vantage:generate-test-jobs --count=200 --duration-min=10 --duration-max=10000
# Dispatch in smaller batches
php artisan vantage:generate-test-jobs --count=1000 --batch-size=25-
Generate test jobs:
php artisan vantage:generate-test-jobs --count=1000 --success-rate=85
-
Start queue worker (in separate terminal):
php artisan queue:work
-
Monitor progress:
- Visit
/vantageto see dashboard - Visit
/vantage/jobsto see job list - Watch statistics update in real-time
- Visit
-
Verify results:
- Check that all jobs are recorded
- Verify success/failure rates match expectations
- Check duration calculations are accurate
- Verify tags are extracted correctly
- Test retry functionality if failures occur
# Terminal 1: Generate jobs
php artisan vantage:generate-test-jobs \
--count=5000 \
--success-rate=80 \
--tags=load-test,production,stress-test \
--duration-min=50 \
--duration-max=2000 \
--batch-size=100
# Terminal 2: Run queue worker
php artisan queue:work --tries=3 --timeout=300
# Terminal 3: Monitor database
php artisan tinker
>>> \Storvia\Vantage\Models\VantageJob::count()
>>> \Storvia\Vantage\Models\VantageJob::where('status', 'processed')->count()
>>> \Storvia\Vantage\Models\VantageJob::where('status', 'failed')->count()it('does something', function () {
$job = VantageJob::create([
'uuid' => Str::uuid(),
'job_class' => 'App\\Jobs\\TestJob',
'status' => 'processing',
]);
expect($job->status)->toBe('processing');
});it('handles a feature', function () {
$response = $this->get('/vantage/jobs');
$response->assertStatus(200);
});Tests use an in-memory SQLite database by default. This is configured in TestCase.php. The database is automatically migrated and refreshed before each test thanks to RefreshDatabase trait.
Tests are designed to run in CI/CD pipelines. The composer.json includes a test script that runs Pest with parallel execution:
"scripts": {
"test": "pest -p"
}Add this to your CI configuration:
# Example GitHub Actions
- name: Run tests
run: composer test