feat: add framework integration tests for Laravel 12→13 upgrade readiness
Framework tests verify core Laravel integration points:
- ServiceProviderTest: app boot, guard resolution, route loading, config_cache
- RoutingTest: named routes, duplicates, api/oauth prefixes, middleware groups
- EloquentTest: User/Profile/Status factories, relationships, casts, soft deletes
- QueueTest: job dispatch, serialization, middleware, unique IDs
- ConfigTest: config loading, env overrides, auth/cache/queue settings
- MiddlewarePipelineTest: CSRF, auth, throttle, password confirm, 2FA, admin
Also:
- Add HasFactory trait to Status model
- Fix StatusFactory: remove non-existent 'place' column, add 'rendered' field
- Add Api/AccountTest for account endpoint coverage (254 total tests)
4 weeks ago
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Jobs\HomeFeedPipeline\FeedInsertPipeline;
|
|
|
|
|
use App\Jobs\StatusPipeline\StatusDelete;
|
|
|
|
|
use App\Models\Status;
|
|
|
|
|
use App\Models\User;
|
feat: add framework integration tests for Laravel 12→13 upgrade readiness
Framework tests verify core Laravel integration points:
- ServiceProviderTest: app boot, guard resolution, route loading, config_cache
- RoutingTest: named routes, duplicates, api/oauth prefixes, middleware groups
- EloquentTest: User/Profile/Status factories, relationships, casts, soft deletes
- QueueTest: job dispatch, serialization, middleware, unique IDs
- ConfigTest: config loading, env overrides, auth/cache/queue settings
- MiddlewarePipelineTest: CSRF, auth, throttle, password confirm, 2FA, admin
Also:
- Add HasFactory trait to Status model
- Fix StatusFactory: remove non-existent 'place' column, add 'rendered' field
- Add Api/AccountTest for account endpoint coverage (254 total tests)
4 weeks ago
|
|
|
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
|
|
|
|
use Illuminate\Support\Facades\Queue;
|
|
|
|
|
|
|
|
|
|
uses(LazilyRefreshDatabase::class);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Queue & Job Integration Tests
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
| Verify that jobs can be dispatched, serialized, and that the queue
|
|
|
|
|
| system integrates correctly with the application.
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
it('dispatches jobs to the sync queue without errors', function () {
|
|
|
|
|
Queue::fake();
|
|
|
|
|
|
|
|
|
|
FeedInsertPipeline::dispatch(1, 1);
|
|
|
|
|
|
|
|
|
|
Queue::assertPushed(FeedInsertPipeline::class);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('dispatches jobs with correct constructor arguments', function () {
|
|
|
|
|
Queue::fake();
|
|
|
|
|
|
|
|
|
|
FeedInsertPipeline::dispatch(123, 456);
|
|
|
|
|
|
|
|
|
|
Queue::assertPushed(FeedInsertPipeline::class, function ($job) {
|
|
|
|
|
// The job stores sid and pid as protected properties
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can serialize and unserialize a StatusDelete job', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
$user->refresh();
|
|
|
|
|
$status = Status::factory()->create(['profile_id' => $user->profile_id]);
|
|
|
|
|
|
|
|
|
|
$job = new StatusDelete($status);
|
|
|
|
|
$serialized = serialize($job);
|
|
|
|
|
$unserialized = unserialize($serialized);
|
|
|
|
|
|
|
|
|
|
expect($unserialized)->toBeInstanceOf(StatusDelete::class);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('supports job middleware configuration', function () {
|
|
|
|
|
$job = new FeedInsertPipeline(1, 1);
|
|
|
|
|
|
|
|
|
|
// FeedInsertPipeline uses WithoutOverlapping middleware
|
|
|
|
|
$middleware = $job->middleware();
|
|
|
|
|
|
|
|
|
|
expect($middleware)->toBeArray()
|
|
|
|
|
->and($middleware)->not->toBeEmpty();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('supports unique job identification', function () {
|
|
|
|
|
$job = new FeedInsertPipeline(42, 1);
|
|
|
|
|
|
|
|
|
|
expect($job->uniqueId())->toContain('42');
|
|
|
|
|
});
|