fix parent pages and teachers and admin
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature\Api\V1\Reports;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -72,6 +73,93 @@ class FilesControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Disposition', 'inline; filename="1a_midterm_v2.pdf"');
|
||||
}
|
||||
|
||||
public function test_exam_draft_final_streams_when_requested_by_draft_id(): void
|
||||
{
|
||||
$user = $this->seedUser();
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
DB::table('classSection')->insert([
|
||||
'id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'class_section_name' => '1A',
|
||||
'class_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('exam_drafts')->insert([
|
||||
'id' => 1,
|
||||
'teacher_id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'exam_type' => 'Final Exam',
|
||||
'draft_title' => 'Final',
|
||||
'teacher_file' => 'draft1.pdf',
|
||||
'final_file' => 'final1.pdf',
|
||||
'version' => 3,
|
||||
'status' => 'finalized',
|
||||
]);
|
||||
|
||||
$dir = storage_path('uploads/exams/finals');
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0777, true);
|
||||
}
|
||||
$path = $dir.DIRECTORY_SEPARATOR.'final1.pdf';
|
||||
file_put_contents($path, 'PDFDATA');
|
||||
|
||||
$response = $this->get('/api/v1/files/exams/final/1');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertHeader('Content-Disposition', 'inline; filename="1a_final_exam_v3.pdf"');
|
||||
}
|
||||
|
||||
public function test_exam_draft_final_ignores_numeric_final_pdf_placeholder(): void
|
||||
{
|
||||
$user = $this->seedUser();
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
DB::table('classSection')->insert([
|
||||
'id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'class_section_name' => '1A',
|
||||
'class_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
$payload = [
|
||||
'id' => 1,
|
||||
'teacher_id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'exam_type' => 'Final Exam',
|
||||
'draft_title' => 'Final',
|
||||
'teacher_file' => 'draft1.pdf',
|
||||
'final_file' => 'final1.pdf',
|
||||
'version' => 3,
|
||||
'status' => 'finalized',
|
||||
];
|
||||
if (Schema::hasColumn('exam_drafts', 'final_pdf_file')) {
|
||||
$payload['final_pdf_file'] = '1';
|
||||
}
|
||||
|
||||
DB::table('exam_drafts')->insert($payload);
|
||||
|
||||
$dir = storage_path('uploads/exams/finals');
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0777, true);
|
||||
}
|
||||
$path = $dir.DIRECTORY_SEPARATOR.'final1.pdf';
|
||||
file_put_contents($path, 'PDFDATA');
|
||||
|
||||
$response = $this->get('/api/v1/files/exams/final/1');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertHeader('Content-Disposition', 'inline; filename="1a_final_exam_v3.pdf"');
|
||||
}
|
||||
|
||||
private function seedUser(): User
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
|
||||
Reference in New Issue
Block a user