Skip to content
Snippets Groups Projects
Commit 2c67def9 authored by Laurent's avatar Laurent
Browse files

dev #27067 koha restful suggestion service

koha suggest form validation
parent 4947d9f4
Branches
Tags
3 merge requests!1132Hotline#29412 images des articles dans le resultat de recherche,!1016Dev#27067 koha restful suggestion service,!1014Dev#27067 koha restful suggestion service
......@@ -34,11 +34,15 @@ class Class_WebService_SIGB_Koha_BuySuggestForm extends ZendAfi_Form_SuggestionA
->addElement('text', 'Title', ['label' => $this->_('Titre').' *',
'placeholder' => $this->_('ex: Harry Potter à l\'école des sorciers'),
'size' => 80])
'size' => 80,
'required' => true,
'allowEmpty' => false])
->addElement('text', 'Author', ['label' => $this->_('Auteur'),
'placeholder' => 'ex: Joanne Kathleen Rowling',
'size' => 80])
'size' => 80,
'required' => true,
'allowEmpty' => false])
->addElement('text', 'Isbn', ['label' => $this->_('Code-barres / ISBN'),
'placeholder' => 'ex: 2-07-054127-4',
......@@ -47,7 +51,8 @@ class Class_WebService_SIGB_Koha_BuySuggestForm extends ZendAfi_Form_SuggestionA
->addElement('text', 'PublicationYear', ['label' => $this->_('Année de publication'),
'size' => 4,
'maxlength' => 4,
'placeholder' => '2015'])
'placeholder' => '2015',
'validators' => ['Int']])
->addElement('textarea', 'PatronReason', ['label' => '',
'cols' => 80,
......
......@@ -310,12 +310,48 @@ class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaRestfulPostTest e
'suggestedby' => '234'],
$datas);
}
}
class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaRestfulPostWrongDataTest extends AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch('/opac/abonne/suggestion-achat-add',
['Title' => '',
'Author' => '',
'Isbn' => '',
'PatronReason' => '',
'PublicationYear' => 'toto',
'submit' => 'Envoyer']);
}
/** @test */
public function inputTitleShouldHaveErrorRequiredValue() {
$this->assertXPathContentContains('//input[@id="Title"]/following-sibling::ul/li',
'Une valeur est requise');
}
/** @test */
public function inputAuthorShouldHaveErrorRequiredValue() {
$this->assertXPathContentContains('//input[@id="Author"]/following-sibling::ul/li',
'Une valeur est requise');
}
/** @test */
public function inputPublicationYearShouldHaveErrorBeInt() {
$this->assertXPathContentContains('//input[@id="PublicationYear"]/following-sibling::ul/li',
"'toto' n'est pas un nombre entier");
}
}
abstract class AbonneControllerSuggestionAchatAddPostTestCase extends AbstractControllerTestCase {
protected
$_suggestion,
......
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