fir 61 failed tests
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m33s
API CI/CD / Build frontend assets (push) Successful in 2m20s
API CI/CD / Security audit (push) Successful in 32s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped

This commit is contained in:
root
2026-06-23 00:39:26 -04:00
parent 83c673ba7f
commit f82017cb91
6 changed files with 45 additions and 27 deletions
+18 -13
View File
@@ -20,6 +20,10 @@ class BadgeControllerTest extends TestCase
$user = User::factory()->create();
Sanctum::actingAs($user);
// Ensure well-known user IDs exist for tests that reference them
User::factory()->create(['id' => 10, 'firstname' => 'Known']);
User::factory()->create(['id' => 20, 'firstname' => 'User']);
return $user;
}
@@ -36,7 +40,7 @@ class BadgeControllerTest extends TestCase
$mock = Mockery::mock(BadgeFormDataService::class);
$mock->shouldReceive('build')
->once()
->with('2025-2026', [10, 20], 'teacher')
->with('2025-2026', [10, 20], [], 'teacher')
->andReturn([
'users' => [],
'schoolYears' => ['2025-2026'],
@@ -48,7 +52,7 @@ class BadgeControllerTest extends TestCase
$this->app->instance(BadgeFormDataService::class, $mock);
$response = $this->getJson('/api/badges/form-data?school_year=2025-2026&user_ids=10,20&active_role=teacher');
$response = $this->getJson('/api/v1/badges/form-data?school_year=2025-2026&user_ids=10,20&active_role=teacher');
$response->assertOk()
->assertJson([
@@ -79,7 +83,7 @@ class BadgeControllerTest extends TestCase
$this->app->instance(BadgePrintLogService::class, $mock);
$response = $this->getJson('/api/badges/print-status?user_ids=5,7&school_year=2025-2026');
$response = $this->getJson('/api/v1/badges/print-status?user_ids=5,7&school_year=2025-2026');
$response->assertOk()
->assertJson([
@@ -105,7 +109,7 @@ class BadgeControllerTest extends TestCase
$this->app->instance(BadgePrintLogService::class, $mock);
$response = $this->getJson('/api/badges/print-status?user_ids=5,7');
$response = $this->getJson('/api/v1/badges/print-status?user_ids=5,7');
$response->assertStatus(500)
->assertJson([
@@ -132,7 +136,7 @@ class BadgeControllerTest extends TestCase
$this->app->instance(BadgePrintLogService::class, $mock);
$response = $this->postJson('/api/badges/log-print', [
$response = $this->postJson('/api/v1/badges/log-print', [
'user_ids' => [10, 20],
'school_year' => '2025-2026',
'roles' => ['10' => 'Teacher'],
@@ -157,7 +161,7 @@ class BadgeControllerTest extends TestCase
$this->app->instance(BadgePrintLogService::class, $mock);
$response = $this->postJson('/api/badges/log-print', [
$response = $this->postJson('/api/v1/badges/log-print', [
'user_ids' => [10],
]);
@@ -176,6 +180,7 @@ class BadgeControllerTest extends TestCase
$mock->shouldReceive('generate')
->once()
->with(
[],
[10, 20],
'2025-2026',
['10' => 'Teacher'],
@@ -189,7 +194,7 @@ class BadgeControllerTest extends TestCase
$this->app->instance(BadgePdfService::class, $mock);
$response = $this->post('/api/badges/pdf', [
$response = $this->post('/api/v1/badges/pdf', [
'user_ids' => [10, 20],
'school_year' => '2025-2026',
'roles' => ['10' => 'Teacher'],
@@ -209,7 +214,7 @@ class BadgeControllerTest extends TestCase
{
$this->authenticate();
$response = $this->postJson('/api/badges/pdf', [
$response = $this->postJson('/api/v1/badges/pdf', [
'school_year' => '2025-2026',
]);
@@ -221,7 +226,7 @@ class BadgeControllerTest extends TestCase
{
$this->authenticate();
$response = $this->postJson('/api/badges/log-print', []);
$response = $this->postJson('/api/v1/badges/log-print', []);
$response->assertStatus(422)
->assertJsonValidationErrors(['user_ids']);
@@ -229,9 +234,9 @@ class BadgeControllerTest extends TestCase
public function test_endpoints_require_authentication(): void
{
$this->getJson('/api/badges/form-data')->assertStatus(401);
$this->getJson('/api/badges/print-status')->assertStatus(401);
$this->postJson('/api/badges/log-print', ['user_ids' => [1]])->assertStatus(401);
$this->postJson('/api/badges/pdf', ['user_ids' => [1]])->assertStatus(401);
$this->getJson('/api/v1/badges/form-data')->assertStatus(401);
$this->getJson('/api/v1/badges/print-status')->assertStatus(401);
$this->postJson('/api/v1/badges/log-print', ['user_ids' => [1]])->assertStatus(401);
$this->postJson('/api/v1/badges/pdf', ['user_ids' => [1]])->assertStatus(401);
}
}