R0.4: Seeder produktionssicher (PlanSeeder, keine Fake-Stripe-IDs, Dev-User-Guard)
- PlanSeeder (Starter/Business/Pro/Agency) haengt jetzt im DatabaseSeeder - PaymentOptionSeeder erfindet keine prod_/price_placeholder-IDs mehr (Spalten nullable; echte Verknuepfung via Stripe-Sync/Pflege) - Demo-Zugaenge admin@pressekonto.test/test@example.com (Passwort "password") werden nur noch in local/testing angelegt Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c678e3a21f
commit
b64aa9fbf5
3 changed files with 61 additions and 6 deletions
48
tests/Feature/DatabaseSeederTest.php
Normal file
48
tests/Feature/DatabaseSeederTest.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
use App\Models\PaymentOption;
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\DatabaseSeeder;
|
||||
use Tests\TestCase;
|
||||
|
||||
test('database seeder seeds roles, plans and payment options', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(DatabaseSeeder::class);
|
||||
|
||||
expect(Plan::query()->count())->toBe(4);
|
||||
expect(PaymentOption::query()->count())->toBe(3);
|
||||
});
|
||||
|
||||
test('payment option seeder does not invent stripe ids', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(DatabaseSeeder::class);
|
||||
|
||||
expect(PaymentOption::query()->whereNotNull('stripe_price_id')->exists())->toBeFalse();
|
||||
expect(PaymentOption::query()->whereNotNull('stripe_product_id')->exists())->toBeFalse();
|
||||
});
|
||||
|
||||
test('dev users are seeded outside production', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(DatabaseSeeder::class);
|
||||
|
||||
expect(User::findByEmail('admin@pressekonto.test'))->not->toBeNull();
|
||||
expect(User::findByEmail('test@example.com'))->not->toBeNull();
|
||||
});
|
||||
|
||||
test('dev users are not seeded in production', function () {
|
||||
/** @var TestCase $this */
|
||||
$originalEnv = $this->app['env'];
|
||||
$this->app['env'] = 'production';
|
||||
|
||||
try {
|
||||
// Direkt statt über artisan db:seed – das Command würde in
|
||||
// "production" interaktiv um Bestätigung bitten.
|
||||
(new DatabaseSeeder)->setContainer($this->app)->__invoke();
|
||||
} finally {
|
||||
$this->app['env'] = $originalEnv;
|
||||
}
|
||||
|
||||
expect(User::query()->count())->toBe(0);
|
||||
expect(Plan::query()->count())->toBe(4);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue