Files
fotospiel-app/tests/Feature/PurchaseConfirmationMailTest.php

59 lines
1.7 KiB
PHP

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