presseportale/tests/Feature/DatabaseSeederTest.php
Kevin Adametz 17eaa80135 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>
2026-07-03 07:58:30 +00:00

48 lines
1.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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);
});