mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
test: add ShareLinkTest + PureLogicTest (TDD), fix coverMap undefined in SearchController
This commit is contained in:
@@ -183,6 +183,8 @@ class ThesisCreateController
|
||||
'synopsis' => $data['synopsis'],
|
||||
'context_note' => $data['contextNote'],
|
||||
'file_size_info' => $data['durationInfo'],
|
||||
'duration_pages' => $data['durationPages'],
|
||||
'duration_minutes'=> $data['durationMinutes'],
|
||||
'baiu_link' => $data['lien'],
|
||||
'license_id' => $data['licenseId'],
|
||||
'license_custom' => $data['licenseCustom'],
|
||||
@@ -338,14 +340,15 @@ class ThesisCreateController
|
||||
$subtitle = $this->sanitiseString($post['subtitle'] ?? '');
|
||||
$synopsis = $this->validateRequired($this->sanitiseString($post['synopsis'] ?? ''), 'Synopsis');
|
||||
|
||||
$durationInfo = $this->sanitiseString($post['duration_pages'] ?? '');
|
||||
$durationPages = $this->sanitiseString($post['duration_pages'] ?? '');
|
||||
$durationMinutes = $this->sanitiseString($post['duration_minutes'] ?? '');
|
||||
if ($durationInfo !== '' && $durationMinutes !== '') {
|
||||
$durationInfo = $durationInfo . ' pages + ' . $durationMinutes . ' minutes';
|
||||
$durationInfo = '';
|
||||
if ($durationPages !== '' && $durationMinutes !== '') {
|
||||
$durationInfo = $durationPages . ' pages + ' . $durationMinutes . ' minutes';
|
||||
} elseif ($durationMinutes !== '') {
|
||||
$durationInfo = $durationMinutes . ' minutes';
|
||||
} elseif ($durationInfo !== '') {
|
||||
$durationInfo = $durationInfo . ' pages';
|
||||
} elseif ($durationPages !== '') {
|
||||
$durationInfo = $durationPages . ' pages';
|
||||
}
|
||||
if (!empty($post['has_annexes'])) {
|
||||
$durationInfo = $durationInfo ? $durationInfo . ' + annexe(s)' : 'Annexe(s)';
|
||||
@@ -430,6 +433,14 @@ class ThesisCreateController
|
||||
$languageIds = isset($post['languages']) && is_array($post['languages'])
|
||||
? array_map('intval', $post['languages'])
|
||||
: [];
|
||||
$autreRaw = trim($post['language_autre'] ?? '');
|
||||
if ($autreRaw !== '') {
|
||||
foreach (array_map('trim', explode(',', $autreRaw)) as $langName) {
|
||||
if ($langName !== '') {
|
||||
$languageIds[] = $this->db->getOrCreateLanguage($langName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($languageIds)) {
|
||||
throw new Exception('Veuillez sélectionner au moins une langue.');
|
||||
}
|
||||
@@ -508,6 +519,8 @@ class ThesisCreateController
|
||||
'subtitle',
|
||||
'synopsis',
|
||||
'durationInfo',
|
||||
'durationPages',
|
||||
'durationMinutes',
|
||||
'juryMembers',
|
||||
'keywords',
|
||||
'languageIds',
|
||||
@@ -676,7 +689,7 @@ class ThesisCreateController
|
||||
/**
|
||||
* Determine the logical file_type from MIME type, extension, and original filename.
|
||||
*/
|
||||
private function detectFileType(string $mimeType, string $ext, string $originalName): string
|
||||
protected function detectFileType(string $mimeType, string $ext, string $originalName): string
|
||||
{
|
||||
if ($ext === 'vtt' || $mimeType === 'text/vtt') {
|
||||
return 'caption';
|
||||
@@ -725,7 +738,7 @@ class ThesisCreateController
|
||||
* Generate a filesystem-safe author slug from the author name.
|
||||
* Converts to uppercase, replaces spaces with underscores, removes accents.
|
||||
*/
|
||||
private function generateAuthorSlug(string $authorName): string
|
||||
protected function generateAuthorSlug(string $authorName): string
|
||||
{
|
||||
// Remove accents using iconv if available, otherwise simple mapping
|
||||
$normalized = $authorName;
|
||||
@@ -764,7 +777,7 @@ class ThesisCreateController
|
||||
* Sanitize a filename: remove accents, replace spaces with underscore, remove special chars.
|
||||
* Keeps extension.
|
||||
*/
|
||||
private function sanitizeFilename(string $filename): string
|
||||
protected function sanitizeFilename(string $filename): string
|
||||
{
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
$name = pathinfo($filename, PATHINFO_FILENAME);
|
||||
@@ -800,7 +813,7 @@ class ThesisCreateController
|
||||
* Find a unique folder name inside theses/{year}/.
|
||||
* Pattern: {year}_{authorSlug} or {year}_{authorSlug}_{suffix} if exists.
|
||||
*/
|
||||
private function ensureUniqueFolder(int $year, string $authorSlug): string
|
||||
protected function ensureUniqueFolder(int $year, string $authorSlug): string
|
||||
{
|
||||
$baseDir = STORAGE_ROOT . '/theses/' . $year . '/';
|
||||
if (!is_dir($baseDir)) {
|
||||
@@ -822,7 +835,7 @@ class ThesisCreateController
|
||||
* The URL is stored in file_path; no filesystem operation is performed.
|
||||
* label and sort_order from the POST are preserved.
|
||||
*/
|
||||
private function handleWebsiteUrl(int $thesisId, array $post): void
|
||||
protected function handleWebsiteUrl(int $thesisId, array $post): void
|
||||
{
|
||||
$websiteUrl = trim($post['website_url'] ?? '');
|
||||
if ($websiteUrl === '') {
|
||||
|
||||
Reference in New Issue
Block a user