add controllers, servoices
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Users;
|
||||
|
||||
use App\Services\EmailService;
|
||||
use App\Services\Users\UserEventService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserEventServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_handle_new_account_sends_email(): void
|
||||
{
|
||||
$emailService = Mockery::mock(EmailService::class);
|
||||
$emailService->shouldReceive('send')
|
||||
->once()
|
||||
->with(
|
||||
'user@example.com',
|
||||
'Welcome to Al Rahma Sunday School!',
|
||||
Mockery::type('string'),
|
||||
'registration'
|
||||
)
|
||||
->andReturn(true);
|
||||
|
||||
$service = new UserEventService($emailService);
|
||||
|
||||
$result = $service->handleNewAccountAdded([
|
||||
'firstname' => 'Test',
|
||||
'lastname' => 'User',
|
||||
'email' => 'user@example.com',
|
||||
]);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function test_handle_new_account_requires_email(): void
|
||||
{
|
||||
$emailService = Mockery::mock(EmailService::class);
|
||||
$emailService->shouldNotReceive('send');
|
||||
|
||||
$service = new UserEventService($emailService);
|
||||
$result = $service->handleNewAccountAdded([
|
||||
'firstname' => 'Test',
|
||||
'lastname' => 'User',
|
||||
]);
|
||||
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user