Commit e600064f authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge branch...

Merge branch 'hotline#69403_catalogue_ajout_d_un_album_a_partir_d_une_notice_en_front_ko' into 'hotline-master'

hotline #69403 add new required input "created_at" to album popup form

See merge request afi/opacce!2477
parents 61bb90ca df43fe75
- ticket #69403 : Administration : correction du formulaire de création d'un album en popup.
\ No newline at end of file
......@@ -417,10 +417,7 @@ class ZendAfi_Controller_Plugin_Manager_Album extends ZendAfi_Controller_Plugin_
protected function _validateAndSaveAlbum($album, $form) {
$this->_view->form = $form;
if (
!$this->_request->isPost()
or !$form->isValid($this->_request->getPost())
)
if (!$this->_request->isPost() || !$form->isValid($this->_request->getPost()))
return;
$values = $form->getValues();
......
......@@ -20,6 +20,7 @@
*/
class ZendAfi_Form_Album extends ZendAfi_Form {
public static function newWithAlbum($album) {
$form = new self();
......@@ -381,6 +382,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form {
['titre',
'cat_id',
'type_doc_id',
'created_at',
'visible',
'status',
'frbr_multi']))
......@@ -400,4 +402,4 @@ class ZendAfi_Form_Album extends ZendAfi_Form {
$post = array_filter($this->getValues());
return parent::deleteUnchanged($post);
}
}
}
\ No newline at end of file
......@@ -3230,31 +3230,61 @@ class Admin_AlbumControllerAddAlbumToAjaxPostNoVisibleTest extends Admin_AlbumCo
class Admin_AlbumControllerAddAlbumToAjaxWithErrorsTest extends Admin_AlbumControllerTestCase {
/** @test */
public function withoutTitleShouldDisplayError() {
$this->postDispatch('/admin/album/link_album_to/id_notice/8',
['titre' => '',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'type_doc_id' => 100,
'frbr_type' => ['1:source'],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);
$this->assertXPathContentContains('//ul[@class="errors"]/li',
'Une valeur est requise',
$this->_response->getBody());
$this->postDispatch('/admin/album/link_album_to/id_notice/8/render/popup',
['titre' => '',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'type_doc_id' => 100,
'created_at' => '2018-01-25',
'frbr_type' => ['1:source'],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']]);
$this->assertContains('<ul class="errors"><li>Une valeur est requise</li></ul>',
json_decode($this->_response->getBody())->content);
}
/** @test */
public function withoutFrbrTypeShouldDisplayError() {
$this->postDispatch('/admin/album/link_album_to/id_notice/8',
['titre' => 'Dark chocolate',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'type_doc_id' => 100,
'frbr_type' => [''],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);
$this->assertXPathContentContains('//script',
'Un champ de cette ligne ne peut \\u00eatre vide',
$this->_response->getBody());
$this->postDispatch('/admin/album/link_album_to/id_notice/8/render/popup',
['titre' => 'Dark chocolate',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'type_doc_id' => 100,
'created_at' => '2018-01-25',
'frbr_type' => [''],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);
$this->assertContains('Un champ de cette ligne ne peut \\u00eatre vide',
json_decode($this->_response->getBody())->content);
}
/** @test */
public function withoutCreatedDateShouldDisplayError() {
$this->postDispatch('/admin/album/link_album_to/id_notice/8/render/popup',
['titre' => 'no created date',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'created_at' => '',
'type_doc_id' => 100,
'frbr_type' => ['1:source'],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);
$this->assertContains('<ul class="errors"><li>Une valeur est requise</li></ul>',
json_decode($this->_response->getBody())->content);
}
/** @test */
public function withoutErrorsShouldNotDisplayError() {
$this->postDispatch('/admin/album/link_album_to/id_notice/8/render/popup',
['titre' => 'no created date',
'visible' => '0',
'status' => Class_Album::STATUS_VALIDATED,
'created_at' => '2018-01-25',
'type_doc_id' => 100,
'frbr_type' => ['1:source'],
'frbr_url' => [Class_Url::siteUrl().'/admin/recherche/viewnotice/id_notice/8/clef/DIAMANTSEMPOISONNES--HENRYA--PAYOT-2007-1/id/8']], true);
$this->assertNotContains('<ul class="errors">',
json_decode($this->_response->getBody())->content);
}
}
......
Markdown is supported
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