2025-01-24 21:37:05 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Filament\Admin\Resources\PaymentResource\Pages\CreatePayment;
|
|
|
|
use App\Models\Customer;
|
|
|
|
use App\Models\User;
|
2025-01-30 11:58:21 -08:00
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
|
|
|
|
uses(RefreshDatabase::class);
|
2025-01-24 21:37:05 -05:00
|
|
|
|
|
|
|
it('can create a payment', function () {
|
|
|
|
$user = User::factory(['is_admin' => true])->create();
|
|
|
|
$this->actingAs($user);
|
|
|
|
$customer = Customer::factory()->create();
|
|
|
|
|
|
|
|
$formData = [
|
|
|
|
'customer_id' => $customer->id,
|
|
|
|
'amount' => 500,
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->livewire(CreatePayment::class)
|
|
|
|
->fillForm($formData)
|
|
|
|
->call('create')
|
|
|
|
->assertHasNoErrors();
|
|
|
|
|
|
|
|
$this->assertDatabaseHas('payments', [
|
|
|
|
'customer_id' => $formData['customer_id'],
|
|
|
|
'amount' => $formData['amount'],
|
|
|
|
]);
|
|
|
|
});
|