fix invalid token
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace {
|
||||
if (! function_exists('view')) {
|
||||
function view($name, array $data = [], $options = [])
|
||||
{
|
||||
return $name . ':' . ($data['student']['firstname'] ?? '') . ' ' . ($data['student']['lastname'] ?? '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Tests\App\Services {
|
||||
|
||||
use App\Models\StudentModel;
|
||||
use App\Models\UserModel;
|
||||
use App\Services\EmailService;
|
||||
use App\Services\Parents\ParentRegistrationNotificationService;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
|
||||
final class ParentRegistrationNotificationServiceTest extends CIUnitTestCase
|
||||
{
|
||||
public function testSendsAdminTemplateEmailForRegisteredStudent(): void
|
||||
{
|
||||
$userModel = $this->createMock(UserModel::class);
|
||||
$userModel->expects($this->once())
|
||||
->method('find')
|
||||
->with(12)
|
||||
->willReturn([
|
||||
'firstname' => 'Parent',
|
||||
'lastname' => 'One',
|
||||
'email' => 'parent@example.test',
|
||||
]);
|
||||
|
||||
$studentModel = $this->createMock(StudentModel::class);
|
||||
$studentModel->expects($this->once())
|
||||
->method('find')
|
||||
->with(34)
|
||||
->willReturn([
|
||||
'id' => 34,
|
||||
'firstname' => 'Student',
|
||||
'lastname' => 'One',
|
||||
]);
|
||||
|
||||
$emailService = $this->createMock(EmailService::class);
|
||||
$emailService->expects($this->once())
|
||||
->method('send')
|
||||
->with(
|
||||
'registration@example.test',
|
||||
'New Student Registered: Student One',
|
||||
$this->stringContains('emails/admin_student_registered'),
|
||||
'notifications'
|
||||
)
|
||||
->willReturn(true);
|
||||
|
||||
$service = new ParentRegistrationNotificationService(
|
||||
$userModel,
|
||||
$studentModel,
|
||||
$emailService,
|
||||
'registration@example.test'
|
||||
);
|
||||
|
||||
$service->sendAdminNewStudentEmails([34], 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user