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::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('/', [AttendanceCommentTemplateController::class, 'index'])->name('api.v1.attendance-comment-templates.index');
|
||||||
Route::get('list-data', [AttendanceCommentTemplateController::class, 'listData'])
|
Route::get('list-data', [AttendanceCommentTemplateController::class, 'listData'])
|
||||||
->name('api.v1.attendance-comment-templates.list-data');
|
->name('api.v1.attendance-comment-templates.list-data');
|
||||||
|
|||||||
@@ -77,10 +77,9 @@ class AssignmentApiTest extends TestCase
|
|||||||
'semester' => 'Fall',
|
'semester' => 'Fall',
|
||||||
'school_year' => '2025-2026',
|
'school_year' => '2025-2026',
|
||||||
'description' => 'Student assigned',
|
'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()
|
$response->assertOk()
|
||||||
->assertJsonStructure([
|
->assertJsonStructure([
|
||||||
@@ -137,7 +136,7 @@ class AssignmentApiTest extends TestCase
|
|||||||
'school_year' => '2025-2026',
|
'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();
|
$response->assertOk();
|
||||||
|
|
||||||
@@ -165,7 +164,7 @@ class AssignmentApiTest extends TestCase
|
|||||||
'description' => 'Moved after placement review',
|
'description' => 'Moved after placement review',
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->postJson('/api/assignments', $payload);
|
$response = $this->postJson('/api/v1/assignments', $payload);
|
||||||
|
|
||||||
$response->assertCreated()
|
$response->assertCreated()
|
||||||
->assertJsonPath('message', 'Assignment saved successfully.');
|
->assertJsonPath('message', 'Assignment saved successfully.');
|
||||||
@@ -183,7 +182,7 @@ class AssignmentApiTest extends TestCase
|
|||||||
{
|
{
|
||||||
Sanctum::actingAs($this->user);
|
Sanctum::actingAs($this->user);
|
||||||
|
|
||||||
$response = $this->postJson('/api/assignments', []);
|
$response = $this->postJson('/api/v1/assignments', []);
|
||||||
|
|
||||||
$response->assertStatus(422)
|
$response->assertStatus(422)
|
||||||
->assertJsonValidationErrors([
|
->assertJsonValidationErrors([
|
||||||
@@ -202,7 +201,7 @@ class AssignmentApiTest extends TestCase
|
|||||||
$sectionB = ClassSection::factory()->create();
|
$sectionB = ClassSection::factory()->create();
|
||||||
|
|
||||||
// First create
|
// First create
|
||||||
$this->postJson('/api/assignments', [
|
$this->postJson('/api/v1/assignments', [
|
||||||
'student_id' => $student->id,
|
'student_id' => $student->id,
|
||||||
'class_section_id' => $sectionA->class_section_id,
|
'class_section_id' => $sectionA->class_section_id,
|
||||||
'semester' => 'Fall',
|
'semester' => 'Fall',
|
||||||
@@ -210,7 +209,7 @@ class AssignmentApiTest extends TestCase
|
|||||||
])->assertCreated();
|
])->assertCreated();
|
||||||
|
|
||||||
// Second call same unique key should update (per service updateOrCreate)
|
// Second call same unique key should update (per service updateOrCreate)
|
||||||
$this->postJson('/api/assignments', [
|
$this->postJson('/api/v1/assignments', [
|
||||||
'student_id' => $student->id,
|
'student_id' => $student->id,
|
||||||
'class_section_id' => $sectionA->class_section_id,
|
'class_section_id' => $sectionA->class_section_id,
|
||||||
'semester' => 'Fall',
|
'semester' => 'Fall',
|
||||||
@@ -238,7 +237,7 @@ class AssignmentApiTest extends TestCase
|
|||||||
#[Test]
|
#[Test]
|
||||||
public function guest_cannot_access_assignment_api_when_auth_is_required(): void
|
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);
|
$response->assertStatus(401);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,26 @@
|
|||||||
|
|
||||||
namespace Tests\Feature\Api;
|
namespace Tests\Feature\Api;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
use App\Services\AttendanceCommentTemplateService;
|
use App\Services\AttendanceCommentTemplateService;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Foundation\Testing\WithFaker;
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Laravel\Sanctum\Sanctum;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class AttendanceCommentTemplateApiTest extends TestCase
|
class AttendanceCommentTemplateApiTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
use WithFaker;
|
use WithFaker;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Sanctum::actingAs($user);
|
||||||
|
}
|
||||||
|
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
Mockery::close();
|
Mockery::close();
|
||||||
@@ -42,7 +53,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
|
|
||||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
||||||
|
|
||||||
$response = $this->getJson('/api/attendance-comment-templates');
|
$response = $this->getJson('/api/v1/attendance-comment-templates');
|
||||||
|
|
||||||
$response->assertOk()
|
$response->assertOk()
|
||||||
->assertJson([
|
->assertJson([
|
||||||
@@ -63,7 +74,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
|
|
||||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
$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()
|
$response->assertOk()
|
||||||
->assertJson([
|
->assertJson([
|
||||||
@@ -100,7 +111,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
|
|
||||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
$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()
|
$response->assertCreated()
|
||||||
->assertJsonPath('status', 'success')
|
->assertJsonPath('status', 'success')
|
||||||
@@ -118,7 +129,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->postJson('/api/attendance-comment-templates', $payload);
|
$response = $this->postJson('/api/v1/attendance-comment-templates', $payload);
|
||||||
|
|
||||||
$response->assertStatus(422)
|
$response->assertStatus(422)
|
||||||
->assertJsonValidationErrors(['max_score']);
|
->assertJsonValidationErrors(['max_score']);
|
||||||
@@ -140,7 +151,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
|
|
||||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
$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()
|
$response->assertOk()
|
||||||
->assertJsonPath('status', 'success')
|
->assertJsonPath('status', 'success')
|
||||||
@@ -171,7 +182,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
|
|
||||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
$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()
|
$response->assertOk()
|
||||||
->assertJsonPath('status', 'success')
|
->assertJsonPath('status', 'success')
|
||||||
@@ -186,7 +197,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
'max_score' => 20,
|
'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)
|
$response->assertStatus(422)
|
||||||
->assertJsonValidationErrors(['max_score']);
|
->assertJsonValidationErrors(['max_score']);
|
||||||
@@ -201,7 +212,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
|
|
||||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
$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()
|
$response->assertOk()
|
||||||
->assertJsonPath('status', 'success')
|
->assertJsonPath('status', 'success')
|
||||||
@@ -226,7 +237,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
|
|||||||
|
|
||||||
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
|
$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()
|
$response->assertOk()
|
||||||
->assertJsonCount(1, 'templates')
|
->assertJsonCount(1, 'templates')
|
||||||
|
|||||||
Reference in New Issue
Block a user