Files
daily-meal-api/tests/Feature/BillingProductsTest.php
T
leonm 68560655f3
CI / 🧪 Tests Laravel (push) Successful in 2m0s
CI / 🐳 Build & Push Image (push) Successful in 35s
feat: clean credits users
2026-08-07 15:32:40 +02:00

40 lines
1.3 KiB
PHP

<?php
use App\Enums\BillingProductPurpose;
use App\Models\BillingProduct;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Sanctum\Sanctum;
uses(RefreshDatabase::class);
it('lists the subscription and certification offers for the mobile app', function () {
Sanctum::actingAs(User::factory()->create());
BillingProduct::create([
'name' => 'Certification',
'purpose' => BillingProductPurpose::CERTIFICATION,
'amount' => 1999,
'currency' => 'eur',
'stripe_price_id' => 'price_certification',
'sort_order' => 20,
]);
BillingProduct::create([
'name' => 'Bowli Plus',
'purpose' => BillingProductPurpose::SUBSCRIPTION,
'amount' => 999,
'currency' => 'eur',
'stripe_price_id' => 'price_subscription',
'sort_order' => 10,
]);
$this
->getJson('/api/billing/products')
->assertOk()
->assertJsonCount(2, 'data')
->assertJsonPath('data.0.name', 'Bowli Plus')
->assertJsonPath('data.0.purpose', BillingProductPurpose::SUBSCRIPTION->value)
->assertJsonPath('data.0.formattedAmount', '9,99 EUR')
->assertJsonPath('data.1.name', 'Certification')
->assertJsonPath('data.1.purpose', BillingProductPurpose::CERTIFICATION->value);
});