add notifications logic and add support of both JWT and Sanctum
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\School;
|
||||
|
||||
use App\Services\EmailService;
|
||||
use App\Services\Notifications\UserNotificationDispatchService;
|
||||
use App\Services\School\PaymentEventService;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PaymentEventServiceTest extends TestCase
|
||||
{
|
||||
public function test_payment_received_sends_email(): void
|
||||
{
|
||||
$email = Mockery::mock(EmailService::class);
|
||||
$email->shouldReceive('send')->once()->andReturn(true);
|
||||
|
||||
$notifier = Mockery::mock(UserNotificationDispatchService::class);
|
||||
$notifier->shouldReceive('notifyUser')->once();
|
||||
|
||||
$service = new PaymentEventService($email, $notifier);
|
||||
$result = $service->paymentReceived([
|
||||
'user_id' => 1,
|
||||
'email' => 'parent@example.com',
|
||||
'firstname' => 'Parent',
|
||||
'lastname' => 'User',
|
||||
'amount' => 25,
|
||||
'invoice_id' => 10,
|
||||
'payment_date' => now()->toDateTimeString(),
|
||||
'installment_seq' => 1,
|
||||
'pre_balance' => 50,
|
||||
'post_balance' => 25,
|
||||
'invoice_total' => 100,
|
||||
]);
|
||||
|
||||
$this->assertTrue($result['ok']);
|
||||
}
|
||||
|
||||
public function test_extra_charge_requires_email(): void
|
||||
{
|
||||
$email = Mockery::mock(EmailService::class);
|
||||
$notifier = Mockery::mock(UserNotificationDispatchService::class);
|
||||
$notifier->shouldReceive('notifyUser')->once();
|
||||
|
||||
$service = new PaymentEventService($email, $notifier);
|
||||
$result = $service->extraCharge([
|
||||
'user_id' => 1,
|
||||
'firstname' => 'Parent',
|
||||
'lastname' => 'User',
|
||||
'amount_signed' => 10,
|
||||
'amount_abs' => 10,
|
||||
'pre_balance' => 0,
|
||||
'post_balance' => 10,
|
||||
'invoice_total' => 100,
|
||||
'charge_title' => 'Fee',
|
||||
'charge_type' => 'add',
|
||||
]);
|
||||
|
||||
$this->assertFalse($result['ok']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user