mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-27 00:59:18 +02:00
test: add ShareLinkTest + PureLogicTest (TDD), fix coverMap undefined in SearchController
This commit is contained in:
@@ -1477,6 +1477,23 @@ class Database
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ID of an existing language by name, inserting it if absent.
|
||||
* Name is trimmed and stored as-is (case-preserved).
|
||||
*/
|
||||
public function getOrCreateLanguage(string $name): int
|
||||
{
|
||||
$name = trim($name);
|
||||
$stmt = $this->pdo->prepare('SELECT id FROM languages WHERE LOWER(name) = LOWER(?) LIMIT 1');
|
||||
$stmt->execute([$name]);
|
||||
$id = $stmt->fetchColumn();
|
||||
if ($id !== false) {
|
||||
return (int)$id;
|
||||
}
|
||||
$this->pdo->prepare('INSERT INTO languages (name) VALUES (?)')->execute([$name]);
|
||||
return (int)$this->pdo->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all format associations for a thesis.
|
||||
* @param int $thesisId
|
||||
@@ -1581,7 +1598,7 @@ class Database
|
||||
public function getThesisRawFields(int $thesisId): ?array
|
||||
{
|
||||
$stmt = $this->pdo->prepare(
|
||||
'SELECT license_id, license_custom, access_type_id, context_note, remarks, jury_points, exemplaire_baiu, exemplaire_erg, cc4r FROM theses WHERE id = ? LIMIT 1'
|
||||
'SELECT license_id, license_custom, access_type_id, context_note, remarks, jury_points, exemplaire_baiu, exemplaire_erg, cc4r, duration_pages, duration_minutes FROM theses WHERE id = ? LIMIT 1'
|
||||
);
|
||||
$stmt->execute([$thesisId]);
|
||||
$row = $stmt->fetch();
|
||||
@@ -1697,6 +1714,8 @@ class Database
|
||||
synopsis = ?,
|
||||
context_note = ?,
|
||||
file_size_info = ?,
|
||||
duration_pages = ?,
|
||||
duration_minutes = ?,
|
||||
baiu_link = ?,
|
||||
license_id = ?,
|
||||
license_custom = ?,
|
||||
@@ -1720,6 +1739,8 @@ class Database
|
||||
$data['synopsis'],
|
||||
!empty($data['context_note']) ? $data['context_note'] : null,
|
||||
!empty($data['file_size_info']) ? $data['file_size_info'] : null,
|
||||
isset($data['duration_pages']) && $data['duration_pages'] !== '' ? (int)$data['duration_pages'] : null,
|
||||
isset($data['duration_minutes']) && $data['duration_minutes'] !== '' ? (int)$data['duration_minutes'] : null,
|
||||
!empty($data['baiu_link']) ? $data['baiu_link'] : null,
|
||||
$data['license_id'] ?? null,
|
||||
!empty($data['license_custom']) ? $data['license_custom'] : null,
|
||||
@@ -1765,6 +1786,7 @@ class Database
|
||||
identifier, title, subtitle, year,
|
||||
orientation_id, ap_program_id, finality_id,
|
||||
synopsis, context_note, file_size_info,
|
||||
duration_pages, duration_minutes,
|
||||
baiu_link, license_id, license_custom,
|
||||
access_type_id,
|
||||
objet,
|
||||
@@ -1773,7 +1795,7 @@ class Database
|
||||
exemplaire_baiu, exemplaire_erg,
|
||||
cc4r,
|
||||
submitted_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
');
|
||||
|
||||
$validObjet = ['tfe', 'thèse', 'frart'];
|
||||
@@ -1790,6 +1812,8 @@ class Database
|
||||
$data['synopsis'],
|
||||
!empty($data['context_note']) ? $data['context_note'] : null,
|
||||
!empty($data['file_size_info']) ? $data['file_size_info'] : null,
|
||||
isset($data['duration_pages']) && $data['duration_pages'] !== '' ? (int)$data['duration_pages'] : null,
|
||||
isset($data['duration_minutes']) && $data['duration_minutes'] !== '' ? (int)$data['duration_minutes'] : null,
|
||||
!empty($data['baiu_link']) ? $data['baiu_link'] : null,
|
||||
$data['license_id'] ?? null,
|
||||
!empty($data['license_custom']) ? $data['license_custom'] : null,
|
||||
|
||||
Reference in New Issue
Block a user