fix teacher page
This commit is contained in:
@@ -19,7 +19,7 @@ class TeacherClassAssignmentControllerTest extends TestCase
|
||||
$this->seedTeacherUser();
|
||||
$this->seedClassSection();
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
Sanctum::actingAs($admin, [], 'api');
|
||||
$response = $this->getJson('/api/v1/administrator/teacher-class/assignments?school_year=2025-2026');
|
||||
|
||||
$response->assertOk();
|
||||
@@ -35,7 +35,7 @@ class TeacherClassAssignmentControllerTest extends TestCase
|
||||
$teacher = $this->seedTeacherUser();
|
||||
$classSectionId = $this->seedClassSection();
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
Sanctum::actingAs($admin, [], 'api');
|
||||
$storeResponse = $this->postJson('/api/v1/administrator/teacher-class/assign', [
|
||||
'teacher_id' => $teacher->id,
|
||||
'class_section_id' => $classSectionId,
|
||||
@@ -48,6 +48,8 @@ class TeacherClassAssignmentControllerTest extends TestCase
|
||||
'teacher_id' => $teacher->id,
|
||||
'class_section_id' => $classSectionId,
|
||||
'position' => 'main',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
$deleteResponse = $this->postJson('/api/v1/administrator/teacher-class/delete', [
|
||||
@@ -62,6 +64,8 @@ class TeacherClassAssignmentControllerTest extends TestCase
|
||||
'teacher_id' => $teacher->id,
|
||||
'class_section_id' => $classSectionId,
|
||||
'position' => 'main',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -75,6 +79,12 @@ class TeacherClassAssignmentControllerTest extends TestCase
|
||||
|
||||
private function seedAdminUser(): User
|
||||
{
|
||||
$roleId = DB::table('roles')->insertGetId([
|
||||
'name' => 'administrator',
|
||||
'slug' => 'administrator',
|
||||
'is_active' => 1,
|
||||
]);
|
||||
|
||||
$userId = DB::table('users')->insertGetId([
|
||||
'firstname' => 'Admin',
|
||||
'lastname' => 'User',
|
||||
@@ -92,6 +102,11 @@ class TeacherClassAssignmentControllerTest extends TestCase
|
||||
'status' => 'Active',
|
||||
]);
|
||||
|
||||
DB::table('user_roles')->insert([
|
||||
'user_id' => $userId,
|
||||
'role_id' => $roleId,
|
||||
]);
|
||||
|
||||
return User::query()->findOrFail($userId);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Encryption\Encrypter;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TeacherAbsenceVacationRouteTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$key = 'base64:'.base64_encode(random_bytes(32));
|
||||
config([
|
||||
'app.key' => $key,
|
||||
'app.cipher' => 'aes-256-cbc',
|
||||
]);
|
||||
|
||||
$rawKey = base64_decode(substr($key, 7), true);
|
||||
$this->app->instance('encrypter', new Encrypter($rawKey, 'aes-256-cbc'));
|
||||
}
|
||||
|
||||
public function test_authenticated_teacher_absence_vacation_route_redirects_to_spa_page(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('/teacher/absence-vacation');
|
||||
|
||||
$response->assertRedirect('/app/teacher/absence-vacation');
|
||||
}
|
||||
|
||||
public function test_authenticated_legacy_teacher_absence_vacation_route_redirects_to_spa_page(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('/teacher/absence_vacation');
|
||||
|
||||
$response->assertRedirect('/app/teacher/absence-vacation');
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ class TeacherAssignmentServiceTest extends TestCase
|
||||
'teacher_id' => $teacherId,
|
||||
'class_section_id' => $classSectionId,
|
||||
'position' => 'main',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -43,6 +45,7 @@ class TeacherAssignmentServiceTest extends TestCase
|
||||
'teacher_id' => $teacherId,
|
||||
'class_section_id' => $classSectionId,
|
||||
'position' => 'ta',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
@@ -60,6 +63,8 @@ class TeacherAssignmentServiceTest extends TestCase
|
||||
'teacher_id' => $teacherId,
|
||||
'class_section_id' => $classSectionId,
|
||||
'position' => 'ta',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user