Skip to content
Snippets Groups Projects
Commit bd029468 authored by efalcy's avatar efalcy
Browse files

dev #14454 autocomplete remove 'de' when author is empty

parent 17cf3987
Branches
Tags
5 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!215Dev#12992 Custom Fields,!209Hotline#13914 Album Link Config Menu,!199Dev#14454 Autocompletion De,!191Dev#14454 Autocompletion De
......@@ -27,7 +27,10 @@ class Class_Autocomplete_IndexTitle extends Class_Autocomplete_Index {
protected $model_name='Class_Notice';
protected function getRecordData($record) {
return str_replace('<br />', ': ', $record->getTitrePrincipal() . $this->_(' de ') . $record->getAuteurPrincipal());
$author = $record->getAuteurPrincipal() ;
if ($author)
$author = $this->_(' de ') .$author;
return str_replace('<br />', ': ', $record->getTitrePrincipal() . $author);
}
}
?>
\ No newline at end of file
......@@ -69,5 +69,26 @@ class Class_Autocomplete_IndexTest extends Storm_Test_ModelTestCase{
$this->assertTrue(
$this->_file_system->methodHasBeenCalledWithParams('fwrite', [$handle, "Bone of my bones de Charle\n"]));
}
/** @test */
public function shouldWriteBoneOfMyBonesWithoutAuthor() {
$handle = new stdClass;
$this->_file_system
->whenCalled('file_exists')->answers(true)
->whenCalled('fopen')->answers($handle)
->whenCalled('fwrite')->answers(null);
$this->fixture('Class_Notice',
['id' => 1301,
'titre_principal' => 'Bone of my bones',
'auteur_principal' => '']);
Class_Autocomplete_Index::indexRecordsTitle();
$this->assertTrue(
$this->_file_system->methodHasBeenCalledWithParams('fwrite', [$handle, "Bone of my bones\n"]));
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment