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\Models\Profile;
|
|
|
|
|
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\Carbon;
|
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
|
|
|
|
|
|
|
|
uses(LazilyRefreshDatabase::class);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Eloquent Model Integration Tests
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
| Verify that models, relationships, casts, scopes, and factories
|
|
|
|
|
| work correctly with the current framework version.
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
describe('User model', function () {
|
|
|
|
|
it('creates a user via factory', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
|
|
|
|
|
expect($user)->toBeInstanceOf(User::class)
|
|
|
|
|
->and($user->id)->toBeInt()
|
|
|
|
|
->and($user->email)->toBeString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates a profile automatically via observer', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
$user->refresh();
|
|
|
|
|
|
|
|
|
|
expect($user->profile)->not->toBeNull()
|
|
|
|
|
->and($user->profile)->toBeInstanceOf(Profile::class)
|
|
|
|
|
->and($user->profile->username)->toBe($user->username);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates user settings automatically via observer', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
$user->refresh();
|
|
|
|
|
|
|
|
|
|
expect($user->settings)->not->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('casts email_verified_at to datetime', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
|
|
|
|
|
expect($user->email_verified_at)->toBeInstanceOf(Carbon::class);
|
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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('hides sensitive attributes in serialization', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
$array = $user->toArray();
|
|
|
|
|
|
|
|
|
|
expect($array)->not->toHaveKey('password')
|
|
|
|
|
->not->toHaveKey('remember_token')
|
|
|
|
|
->not->toHaveKey('2fa_secret');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates an admin user via factory state', function () {
|
|
|
|
|
$admin = User::factory()->admin()->create();
|
|
|
|
|
|
|
|
|
|
expect($admin->is_admin)->toBeTrue();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates an unverified user via factory state', function () {
|
|
|
|
|
$user = User::factory()->unverified()->create();
|
|
|
|
|
|
|
|
|
|
expect($user->email_verified_at)->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Profile model', function () {
|
|
|
|
|
it('creates a profile via factory', function () {
|
|
|
|
|
$profile = Profile::factory()->create();
|
|
|
|
|
|
|
|
|
|
expect($profile)->toBeInstanceOf(Profile::class)
|
|
|
|
|
->and($profile->username)->toBeString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('belongs to a user', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
$user->refresh();
|
|
|
|
|
|
|
|
|
|
expect($user->profile->user->id)->toBe($user->id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('soft deletes without removing from database', function () {
|
|
|
|
|
$profile = Profile::factory()->create();
|
|
|
|
|
$id = $profile->id;
|
|
|
|
|
|
|
|
|
|
$profile->delete();
|
|
|
|
|
|
|
|
|
|
expect(Profile::find($id))->toBeNull()
|
|
|
|
|
->and(Profile::withTrashed()->find($id))->not->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates a private profile via factory state', function () {
|
|
|
|
|
$profile = Profile::factory()->private()->create();
|
|
|
|
|
|
|
|
|
|
expect($profile->is_private)->toBeTrue();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('Status model', function () {
|
|
|
|
|
it('creates a status via factory', function () {
|
|
|
|
|
$status = Status::factory()->create();
|
|
|
|
|
|
|
|
|
|
expect($status)->toBeInstanceOf(Status::class)
|
|
|
|
|
->and($status->profile_id)->not->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('belongs to a profile', function () {
|
|
|
|
|
$status = Status::factory()->create();
|
|
|
|
|
|
|
|
|
|
expect($status->profile)->toBeInstanceOf(Profile::class);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('has visibility scopes', function () {
|
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
$user->refresh();
|
|
|
|
|
|
|
|
|
|
Status::factory()->create(['profile_id' => $user->profile_id, 'scope' => 'public']);
|
|
|
|
|
Status::factory()->create(['profile_id' => $user->profile_id, 'scope' => 'private']);
|
|
|
|
|
Status::factory()->create(['profile_id' => $user->profile_id, 'scope' => 'unlisted']);
|
|
|
|
|
|
|
|
|
|
$public = Status::where('profile_id', $user->profile_id)
|
|
|
|
|
->whereIn('scope', ['public', 'unlisted'])
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
expect($public)->toBe(2);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('soft deletes without removing from database', function () {
|
|
|
|
|
$status = Status::factory()->create();
|
|
|
|
|
$id = $status->id;
|
|
|
|
|
|
|
|
|
|
$status->delete();
|
|
|
|
|
|
|
|
|
|
expect(Status::find($id))->toBeNull()
|
|
|
|
|
->and(Status::withTrashed()->find($id))->not->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates typed statuses via factory states', function () {
|
|
|
|
|
$photo = Status::factory()->photo()->create();
|
|
|
|
|
$private = Status::factory()->private()->create();
|
|
|
|
|
$nsfw = Status::factory()->nsfw()->create();
|
|
|
|
|
|
|
|
|
|
expect($photo->type)->toBe('photo')
|
|
|
|
|
->and($private->scope)->toBe('private')
|
|
|
|
|
->and($nsfw->is_nsfw)->toBeTrue();
|
|
|
|
|
});
|
|
|
|
|
});
|