seed(PaymentOptionSeeder::class); $monthly = PaymentOption::query() ->where('article_number', 'PR-MONTHLY-001') ->firstOrFail(); expect($monthly->translations()->count())->toBe(2); }); test('user payment option supports company pivot and payments relation', function () { /** @var TestCase $this */ $userPaymentOption = UserPaymentOption::factory()->create(); $company = Company::query()->create([ 'name' => 'Test Company '.Str::random(6), 'slug' => 'test-company-'.Str::lower(Str::random(8)), ]); $userPaymentOption->companies()->attach($company->id, ['is_active' => true]); $payment = $userPaymentOption->payments()->create([ 'amount_cents' => 9900, 'currency' => 'EUR', 'status' => 'succeeded', 'stripe_charge_id' => 'ch_test_123456', ]); $this->assertModelExists($payment); expect($userPaymentOption->companies()->whereKey($company->id)->exists())->toBeTrue(); expect($userPaymentOption->payments()->count())->toBe(1); }); test('invoice factory creates valid relation graph', function () { /** @var TestCase $this */ $invoice = Invoice::factory()->create(); $this->assertModelExists($invoice); expect($invoice->user)->not->toBeNull(); expect($invoice->invoiceBillingAddress)->not->toBeNull(); expect($invoice->userPayment)->not->toBeNull(); });