Idempotenter Command (nur local/staging): aktiver Legacy-API-User mit Grandfathering, importiertem X-ApiKey, api:immediate-publication, Firma + Pressekontakt; gibt Key + curl-Sammlung des /service-Flows aus. Live gegen die lokale App verifiziert (Firma -> Kontakt -> PM sofort published -> GET 200 im Alt-Format). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
26 lines
960 B
PHP
26 lines
960 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Tests\TestCase;
|
|
|
|
test('the testdata command creates a working legacy api customer', function () {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
|
|
$this->artisan('legacy:seed-api-testdata')
|
|
->assertExitCode(0)
|
|
->expectsOutputToContain('API-Testkunde bereit.');
|
|
|
|
$user = User::query()->where('email', 'api-test@pressekonto.test')->firstOrFail();
|
|
|
|
expect($user->is_active)->toBeTrue()
|
|
->and($user->can('api:immediate-publication'))->toBeTrue()
|
|
->and($user->hasActiveBooking())->toBeTrue()
|
|
->and($user->tokens()->count())->toBe(1);
|
|
|
|
// Idempotent: zweiter Lauf erneuert nur den Key.
|
|
$this->artisan('legacy:seed-api-testdata')->assertExitCode(0);
|
|
expect(User::query()->where('email', 'api-test@pressekonto.test')->count())->toBe(1)
|
|
->and($user->tokens()->count())->toBe(1);
|
|
});
|