mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 07:11:18 +02:00
fix: unify CSV import/export columns, fix import JS error, fix createThesis VALUES
- Fix createThesis SQL: extra ? placeholder in VALUES (27 values for 26 columns) - Add createThesis integration tests to catch column/value mismatches - Add CSV_COLUMNS as single source of truth in ExportController, deriving csvHeaders() and positional fallback from it - Add missing columns to export query + CSV: duration_pages, duration_minutes, has_annexes, license_custom, contact_visible, objet - Add missing columns to import INSERT: license_id, license_custom, cc2r, exemplaire_baiu, exemplaire_erg, objet, contact_visible, duration_pages, duration_minutes, has_annexes - Resolve license name → license_id during import - Fix XamxamInitFilePonds: add file-upload-filepond.js to admin-entry.js so FilePond initialization code is available on the admin list page - Add FilePond vendor CSS to admin.min.css bundle (import dialog styling) - Generate .admin-file-hint from csvHeaders() instead of hardcoded stale list - Use positional fallback from CSV_COLUMNS for import cell parsing
This commit is contained in:
@@ -345,4 +345,103 @@ class DatabaseExtendedTest extends TestCase
|
||||
$deleted = $pdo->query("SELECT deleted_at FROM tags WHERE id = $tagB")->fetchColumn();
|
||||
$this->assertNotNull($deleted);
|
||||
}
|
||||
|
||||
// ── createThesis ────────────────────────────────────────────────────────
|
||||
|
||||
public function testCreateThesisMinimalFields(): void
|
||||
{
|
||||
$id = $this->db->createThesis([
|
||||
'title' => 'Minimal Thesis',
|
||||
'year' => 2025,
|
||||
'synopsis' => 'A minimal synopsis.',
|
||||
]);
|
||||
|
||||
$this->assertGreaterThan(0, $id);
|
||||
|
||||
$row = TestDatabase::getPDO()
|
||||
->query("SELECT * FROM theses WHERE id = $id")
|
||||
->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$this->assertSame('Minimal Thesis', $row['title']);
|
||||
$this->assertSame(2025, (int)$row['year']);
|
||||
$this->assertSame('tfe', $row['objet']);
|
||||
$this->assertSame('draft', $row['status']);
|
||||
$this->assertSame(0, (int)$row['is_published']);
|
||||
$this->assertSame(0, (int)$row['exemplaire_baiu']);
|
||||
$this->assertSame(0, (int)$row['exemplaire_erg']);
|
||||
$this->assertSame(0, (int)$row['cc2r']);
|
||||
$this->assertSame(0, (int)$row['has_annexes']);
|
||||
$this->assertStringStartsWith('2025-', $row['identifier']);
|
||||
$this->assertNotNull($row['submitted_at']);
|
||||
}
|
||||
|
||||
public function testCreateThesisAllOptionalFields(): void
|
||||
{
|
||||
$id = $this->db->createThesis([
|
||||
'title' => 'Full Thesis',
|
||||
'subtitle' => 'With a subtitle',
|
||||
'year' => 2024,
|
||||
'synopsis' => 'Full synopsis.',
|
||||
'context_note' => 'Some context.',
|
||||
'contact_visible' => 'Visible info',
|
||||
'baiu_link' => 'https://example.com/thesis',
|
||||
'license_id' => null,
|
||||
'license_custom' => 'CC BY 4.0',
|
||||
'access_type_id' => 1,
|
||||
'objet' => 'tfe',
|
||||
'remarks' => 'No remarks.',
|
||||
'jury_points' => '16.5',
|
||||
'exemplaire_baiu' => '1',
|
||||
'exemplaire_erg' => '1',
|
||||
'cc2r' => '1',
|
||||
'duration_pages' => '42',
|
||||
'duration_minutes' => '30',
|
||||
'has_annexes' => '1',
|
||||
]);
|
||||
|
||||
$this->assertGreaterThan(0, $id);
|
||||
|
||||
$row = TestDatabase::getPDO()
|
||||
->query("SELECT * FROM theses WHERE id = $id")
|
||||
->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$this->assertSame('Full Thesis', $row['title']);
|
||||
$this->assertSame('With a subtitle', $row['subtitle']);
|
||||
$this->assertSame(2024, (int)$row['year']);
|
||||
$this->assertSame('Full synopsis.', $row['synopsis']);
|
||||
$this->assertSame('Some context.', $row['context_note']);
|
||||
$this->assertSame('Visible info', $row['contact_visible']);
|
||||
$this->assertSame('https://example.com/thesis', $row['baiu_link']);
|
||||
$this->assertSame('CC BY 4.0', $row['license_custom']);
|
||||
$this->assertSame(1, (int)$row['exemplaire_baiu']);
|
||||
$this->assertSame(1, (int)$row['exemplaire_erg']);
|
||||
$this->assertSame(1, (int)$row['cc2r']);
|
||||
$this->assertSame(42, (int)$row['duration_pages']);
|
||||
$this->assertSame(30, (int)$row['duration_minutes']);
|
||||
$this->assertSame(1, (int)$row['has_annexes']);
|
||||
$this->assertSame('No remarks.', $row['remarks']);
|
||||
$this->assertEquals(16.5, (float)$row['jury_points']);
|
||||
}
|
||||
|
||||
public function testCreateThesisGeneratesUniqueIdentifiers(): void
|
||||
{
|
||||
$id1 = $this->db->createThesis([
|
||||
'title' => 'First',
|
||||
'year' => 2025,
|
||||
'synopsis' => 'One.',
|
||||
]);
|
||||
$id2 = $this->db->createThesis([
|
||||
'title' => 'Second',
|
||||
'year' => 2025,
|
||||
'synopsis' => 'Two.',
|
||||
]);
|
||||
|
||||
$pdo = TestDatabase::getPDO();
|
||||
$ident1 = $pdo->query("SELECT identifier FROM theses WHERE id = $id1")->fetchColumn();
|
||||
$ident2 = $pdo->query("SELECT identifier FROM theses WHERE id = $id2")->fetchColumn();
|
||||
|
||||
$this->assertNotSame($ident1, $ident2);
|
||||
$this->assertSame('2025-001', $ident1);
|
||||
$this->assertSame('2025-002', $ident2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user