schickere bestellbestätigung und user role detaults auf "user" gesetzt.

This commit is contained in:
Codex Agent
2025-12-23 10:33:06 +01:00
parent ed5c1918fc
commit 886b24b06b
8 changed files with 409 additions and 12 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace Tests\Feature;
use App\Models\Package;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Mail;
use Tests\TestCase;
class CheckoutRegisterRoleTest extends TestCase
{
use RefreshDatabase;
public function test_checkout_register_sets_user_role_until_purchase(): void
{
Mail::fake();
$package = Package::factory()->create();
$payload = [
'email' => 'buyer@example.test',
'username' => 'buyer',
'password' => 'Password!123',
'password_confirmation' => 'Password!123',
'first_name' => 'Soren',
'last_name' => 'Eberhardt',
'address' => 'Example Street 1',
'phone' => '123456789',
'package_id' => $package->id,
'terms' => true,
'privacy_consent' => true,
'locale' => 'de',
];
$response = $this->postJson('/checkout/register', $payload);
$response->assertOk();
$user = User::where('email', 'buyer@example.test')->first();
$this->assertNotNull($user);
$this->assertSame('user', $user->role);
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace Tests\Feature;
use App\Mail\PurchaseConfirmation;
use App\Models\Package;
use App\Models\PackagePurchase;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PurchaseConfirmationMailTest extends TestCase
{
use RefreshDatabase;
public function test_purchase_confirmation_mail_renders_expected_details(): void
{
$user = User::factory()->create([
'first_name' => 'Soren',
'last_name' => 'Eberhardt',
]);
$tenant = Tenant::factory()->create([
'user_id' => $user->id,
]);
$user->forceFill(['tenant_id' => $tenant->id])->save();
$package = Package::factory()->create([
'name' => 'Standard',
'type' => 'endcustomer',
'max_photos' => 500,
'max_guests' => 200,
'gallery_days' => 30,
]);
$purchase = PackagePurchase::factory()->create([
'tenant_id' => $tenant->id,
'package_id' => $package->id,
'provider' => 'paddle',
'provider_id' => 'txn_123',
'price' => 59,
'metadata' => [
'payload' => [
'invoice_url' => 'https://paddle.test/invoice/123',
],
'currency' => 'EUR',
],
]);
$mailable = (new PurchaseConfirmation($purchase))->locale('de');
$html = $mailable->render();
$this->assertStringContainsString('Die Fotospiel.App', $html);
$this->assertStringContainsString('Standard', $html);
$this->assertStringContainsString('txn_123', $html);
$this->assertStringContainsString('https://paddle.test/invoice/123', $html);
}
}