fix: update badge unit tests to match service constructor changes
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m29s
API CI/CD / Build frontend assets (push) Successful in 2m24s
API CI/CD / Security audit (push) Successful in 33s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m29s
API CI/CD / Build frontend assets (push) Successful in 2m24s
API CI/CD / Security audit (push) Successful in 33s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
- BadgeFormDataServiceTest: add missing BadgeStudentLookupService mock, update build() signature with param, fix default role assertion (teacher → all) - BadgePdfServiceTest: add missing BadgeStudentLookupService mock as first constructor arg, update generate() calls with studentIds:, fix filename assertion (Staff_Badges.pdf → Badges.pdf) These constructors were refactored to accept a new BadgeStudentLookupService dependency and reordered parameters, but the unit tests were never updated, causing TypeError failures.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Unit\Services\Badges;
|
||||
|
||||
use App\Services\Badges\BadgeFormDataService;
|
||||
use App\Services\Badges\BadgeStudentLookupService;
|
||||
use App\Services\Badges\BadgeTextFormatter;
|
||||
use App\Services\Badges\BadgeUserLookupService;
|
||||
use Mockery;
|
||||
@@ -19,6 +20,7 @@ class BadgeFormDataServiceTest extends TestCase
|
||||
public function test_build_formats_users_and_assigns_latest_class_for_teacherish_roles(): void
|
||||
{
|
||||
$lookup = Mockery::mock(BadgeUserLookupService::class);
|
||||
$studentLookup = Mockery::mock(BadgeStudentLookupService::class);
|
||||
$formatter = new BadgeTextFormatter;
|
||||
|
||||
$lookup->shouldReceive('fetchStaffList')
|
||||
@@ -51,9 +53,14 @@ class BadgeFormDataServiceTest extends TestCase
|
||||
->once()
|
||||
->andReturn(['2025-2026', '2024-2025']);
|
||||
|
||||
$service = new BadgeFormDataService($lookup, $formatter);
|
||||
$studentLookup->shouldReceive('fetchStudentList')
|
||||
->once()
|
||||
->with('2025-2026', [])
|
||||
->andReturn([]);
|
||||
|
||||
$result = $service->build('2025-2026', [10, 20], 'teacher');
|
||||
$service = new BadgeFormDataService($lookup, $studentLookup, $formatter);
|
||||
|
||||
$result = $service->build('2025-2026', [10, 20], [], 'teacher');
|
||||
|
||||
$this->assertSame('2025-2026', $result['selectedYear']);
|
||||
$this->assertSame([10, 20], $result['selectedUserIds']);
|
||||
@@ -75,6 +82,7 @@ class BadgeFormDataServiceTest extends TestCase
|
||||
public function test_build_defaults_invalid_active_role_to_teacher(): void
|
||||
{
|
||||
$lookup = Mockery::mock(BadgeUserLookupService::class);
|
||||
$studentLookup = Mockery::mock(BadgeStudentLookupService::class);
|
||||
$formatter = new BadgeTextFormatter;
|
||||
|
||||
$lookup->shouldReceive('fetchStaffList')
|
||||
@@ -85,10 +93,14 @@ class BadgeFormDataServiceTest extends TestCase
|
||||
->once()
|
||||
->andReturn([]);
|
||||
|
||||
$service = new BadgeFormDataService($lookup, $formatter);
|
||||
$studentLookup->shouldReceive('fetchStudentList')
|
||||
->once()
|
||||
->andReturn([]);
|
||||
|
||||
$result = $service->build('2025-2026', [], 'invalid-role');
|
||||
$service = new BadgeFormDataService($lookup, $studentLookup, $formatter);
|
||||
|
||||
$this->assertSame('teacher', $result['active_role']);
|
||||
$result = $service->build('2025-2026', [], [], 'invalid-role');
|
||||
|
||||
$this->assertSame('all', $result['active_role']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user