fix tests isssues
API CI/CD / Validate (composer + pint) (push) Successful in 2m6s
API CI/CD / Test (PHPUnit) (push) Failing after 2m24s
API CI/CD / Build frontend assets (push) Successful in 2m25s
API CI/CD / Security audit (push) Successful in 32s
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 2m24s
API CI/CD / Build frontend assets (push) Successful in 2m25s
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:
+1
-1
@@ -539,7 +539,7 @@ Route::prefix('v1')->group(function () {
|
||||
Route::post('/save-notification-note', [AttendanceTrackingController::class, 'saveNotificationNote']);
|
||||
});
|
||||
|
||||
Route::middleware(['auth:api', 'school_year.editable'])->prefix('attendance-comment-templates')->group(function () {
|
||||
Route::middleware(['auth:sanctum', 'school_year.editable'])->prefix('attendance-comment-templates')->group(function () {
|
||||
Route::get('/', [AttendanceCommentTemplateController::class, 'index'])->name('api.v1.attendance-comment-templates.index');
|
||||
Route::get('list-data', [AttendanceCommentTemplateController::class, 'listData'])
|
||||
->name('api.v1.attendance-comment-templates.list-data');
|
||||
|
||||
@@ -77,10 +77,9 @@ class AssignmentApiTest extends TestCase
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'description' => 'Student assigned',
|
||||
'is_active' => 1, // remove if your table doesn’t have this column
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/assignments');
|
||||
$response = $this->getJson('/api/v1/assignments');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonStructure([
|
||||
@@ -137,7 +136,7 @@ class AssignmentApiTest extends TestCase
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/assignments?school_year=2025-2026');
|
||||
$response = $this->getJson('/api/v1/assignments?school_year=2025-2026');
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
@@ -165,7 +164,7 @@ class AssignmentApiTest extends TestCase
|
||||
'description' => 'Moved after placement review',
|
||||
];
|
||||
|
||||
$response = $this->postJson('/api/assignments', $payload);
|
||||
$response = $this->postJson('/api/v1/assignments', $payload);
|
||||
|
||||
$response->assertCreated()
|
||||
->assertJsonPath('message', 'Assignment saved successfully.');
|
||||
@@ -183,7 +182,7 @@ class AssignmentApiTest extends TestCase
|
||||
{
|
||||
Sanctum::actingAs($this->user);
|
||||
|
||||
$response = $this->postJson('/api/assignments', []);
|
||||
$response = $this->postJson('/api/v1/assignments', []);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors([
|
||||
@@ -202,7 +201,7 @@ class AssignmentApiTest extends TestCase
|
||||
$sectionB = ClassSection::factory()->create();
|
||||
|
||||
// First create
|
||||
$this->postJson('/api/assignments', [
|
||||
$this->postJson('/api/v1/assignments', [
|
||||
'student_id' => $student->id,
|
||||
'class_section_id' => $sectionA->class_section_id,
|
||||
'semester' => 'Fall',
|
||||
@@ -210,7 +209,7 @@ class AssignmentApiTest extends TestCase
|
||||
])->assertCreated();
|
||||
|
||||
// Second call same unique key should update (per service updateOrCreate)
|
||||
$this->postJson('/api/assignments', [
|
||||
$this->postJson('/api/v1/assignments', [
|
||||
'student_id' => $student->id,
|
||||
'class_section_id' => $sectionA->class_section_id,
|
||||
'semester' => 'Fall',
|
||||
@@ -238,7 +237,7 @@ class AssignmentApiTest extends TestCase
|
||||
#[Test]
|
||||
public function guest_cannot_access_assignment_api_when_auth_is_required(): void
|
||||
{
|
||||
$response = $this->getJson('/api/assignments');
|
||||
$response = $this->getJson('/api/v1/assignments');
|
||||
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
@@ -2,15 +2,26 @@
|
||||
|
||||
namespace Tests\Feature\Api;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\AttendanceCommentTemplateService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AttendanceCommentTemplateApiTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
use WithFaker;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$user = User::factory()->create();
|
||||
Sanctum::actingAs($user);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Mockery::close();
|
||||
@@ -42,7 +53,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
|
||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||
|
||||
$response = $this->getJson('/api/attendance-comment-templates');
|
||||
$response = $this->getJson('/api/v1/attendance-comment-templates');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -63,7 +74,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
|
||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||
|
||||
$response = $this->getJson('/api/attendance-comment-templates?active_only=1');
|
||||
$response = $this->getJson('/api/v1/attendance-comment-templates?active_only=1');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson([
|
||||
@@ -100,7 +111,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
|
||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||
|
||||
$response = $this->postJson('/api/attendance-comment-templates', $payload);
|
||||
$response = $this->postJson('/api/v1/attendance-comment-templates', $payload);
|
||||
|
||||
$response->assertCreated()
|
||||
->assertJsonPath('status', 'success')
|
||||
@@ -118,7 +129,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
'is_active' => true,
|
||||
];
|
||||
|
||||
$response = $this->postJson('/api/attendance-comment-templates', $payload);
|
||||
$response = $this->postJson('/api/v1/attendance-comment-templates', $payload);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['max_score']);
|
||||
@@ -140,7 +151,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
|
||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||
|
||||
$response = $this->getJson('/api/attendance-comment-templates/5');
|
||||
$response = $this->getJson('/api/v1/attendance-comment-templates/5');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('status', 'success')
|
||||
@@ -171,7 +182,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
|
||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||
|
||||
$response = $this->putJson('/api/attendance-comment-templates/7', $payload);
|
||||
$response = $this->putJson('/api/v1/attendance-comment-templates/7', $payload);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('status', 'success')
|
||||
@@ -186,7 +197,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
'max_score' => 20,
|
||||
];
|
||||
|
||||
$response = $this->putJson('/api/attendance-comment-templates/7', $payload);
|
||||
$response = $this->putJson('/api/v1/attendance-comment-templates/7', $payload);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['max_score']);
|
||||
@@ -201,7 +212,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
|
||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||
|
||||
$response = $this->deleteJson('/api/attendance-comment-templates/12');
|
||||
$response = $this->deleteJson('/api/v1/attendance-comment-templates/12');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('status', 'success')
|
||||
@@ -226,7 +237,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
||||
|
||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||
|
||||
$response = $this->getJson('/api/attendance-comment-templates/list-data');
|
||||
$response = $this->getJson('/api/v1/attendance-comment-templates/list-data');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonCount(1, 'templates')
|
||||
|
||||
Reference in New Issue
Block a user