Files
alrahma_sunday_school/tests/app/Services/ParentRegistrationNotificationServiceTest.php
root 332b0d1007
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 49s
Tests / PHPUnit (push) Successful in 1m20s
fix invalid token
2026-08-30 21:10:35 -04:00

66 lines
2.1 KiB
PHP

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