Newer
Older
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

gloas
committed
class AbonneControllerSuggestionAchatAddFormTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_CosmoVar::newInstanceWithId('types_docs', ['liste' => '']);
$this->fixture('Class_TypeDoc', ['id' => 6 ,
'label' => 'Blueray',
'famille_id' => Class_CodifTypeDoc::VIDEO]);
$this->fixture('Class_Bib', ['id' => 11,

gloas
committed
$this->dispatch('/opac/abonne/suggestion-achat-add', true);
}
/** @test */
public function pageTitleShouldBeSuggestionAchat() {

gloas
committed
$this->assertXPathContentContains('//title', 'Suggérer un achat');
}
/** @test */
public function boiteShouldHaveTitleSuggestionAchat() {

gloas
committed
$this->assertXPathContentContains('//div[@class="boiteMilieu"]//h1', 'Suggérer un achat');
}
/** @test */
public function formShouldContainsInputForTitre() {
$this->assertXPath('//form//input[@name="titre"][@placeholder="ex: Harry Potter à l\'école des sorciers"]');
/** @test */
public function formShouldContainsSelectForDocumentType() {
$this->assertXPath('//form//select[@name="type_doc_id"]');
}
/** @test */
public function typeDocBlueRayShouldBePresent() {
$this->assertXPath('//form//select[@name="type_doc_id"]//option[@value="6"][@label="Blueray"]');
}

Ghislain Loas
committed
/** @test */
public function rssShouldNotBePresent() {
$this->assertNotXpath('//form//select[@name="type_doc_id"]//option[@value="9"][@label="fils rss"]');
}
/** @test */
public function formShouldContainsInputForAuteur() {
$this->assertXPath('//form//input[@name="auteur"][@placeholder="ex: Joanne Kathleen Rowling"]');
}
/** @test */
public function formShouldContainsInputForDescriptionUrl() {
$this->assertXPath('//form//input[@type="url"][@name="description_url"][@placeholder="ex: http://fr.wikipedia.org/wiki/Harry_Potter_à_l\'école_des_sorciers"]');
/** @test */
public function formShouldContainsInputForISBN() {
$this->assertXPath('//form//input[@name="isbn"][@placeholder="ex: 2-07-054127-4"]');
}
/** @test */
public function libraryShouldBeSetByDefault() {
$this->assertXPath('//form//select[@name="bib_id"]//option[@value="11"][@selected="selected"]');
/** @test */
public function formShouldContainsTextAreaForCommentaire() {
$this->assertXPath('//form//textarea[@name="commentaire"]');
}
/** @test */
public function formShouldContainsSubmitButtonEnvoyer() {
$this->assertXPath('//form//input[@type="submit"][@value="Envoyer"]');
}
class AbonneControllerSuggestionAchatAddFormMultipleBibsTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Bib', ['id' => 11,
$this->fixture('Class_Bib', ['id' => 12,
'libelle' => 'Bib de la plage 2']);
$user = $this->fixture('Class_Users', [
'id' => 3,
'login' => 'test',
'password' => 'test',
'id_site' => 12,
]);
ZendAfi_Auth::getInstance()->logUser($user);
$this->dispatch('/opac/abonne/suggestion-achat-add', true);
}
/** @test */
public function formShouldContainsSelectForLibrary() {
$this->assertXPath('//form//select[@name="bib_id"]');
/** @test */
public function librarySelectShouldContainBibDeLaPlage() {
$this->assertXPath('//form//select[@name="bib_id"]//option[@value="11"][@label="Bib de la plage"]/following-sibling::option[@value="12"][@label="Bib de la plage 2"]');

Ghislain Loas
committed
public function noLibraryShouldHaveBeenSelectedByDefault() {
$this->assertXPath('//form//select[@name="bib_id"]//option[1][@value="0"]');
}
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaNotRestfulTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$sigb_plage = $this->fixture('Class_IntBib',
[
'id' => 3,
'comm_params' => ['url_serveur' => 'http://plage.com/cgi-bin/koha/ilsdi.pl',
'restful' => '0'],
'comm_sigb' => Class_IntBib::COM_KOHA
]);
$this->fixture('Class_Bib', ['id' => 12,
'libelle' => 'Bib de la plage 2',
'int_bib' => $sigb_plage]);
$user = $this->fixture('Class_Users', [
'id' => 3,
'login' => 'test',
'password' => 'test',
'id_site' => 12,
'int_bib' => $sigb_plage,
]);
ZendAfi_Auth::getInstance()->logUser($user);
$this->dispatch('/opac/abonne/suggestion-achat-add', true);
}
/** @test */
public function formShouldContainsTextAreaForCommentaire() {
$this->assertXPath('//form//textarea[@name="commentaire"]');
}
}
abstract class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$sigb_plage = $this->fixture('Class_IntBib',
[
'id' => 3,
'comm_params' => ['url_serveur' => 'http://plage.com/cgi-bin/koha/ilsdi.pl',
'restful' => '1'],
'comm_sigb' => Class_IntBib::COM_KOHA
]);
$this->fixture('Class_Bib', ['id' => 11,
'libelle' => 'Bib de la plage',
'int_bib' => $sigb_plage]);
$this->fixture('Class_Bib', ['id' => 12,
'libelle' => 'Bib de la plage 2',
'int_bib' => $sigb_plage]);
$this->fixture('Class_Bib', ['id' => 14,
'libelle' => 'Bib de la montagne']);
$user = $this->fixture('Class_Users', [
'id' => 3,
'login' => 'test',
'password' => 'test',
'id_site' => 12,
'int_bib' => $sigb_plage,
]);
ZendAfi_Auth::getInstance()->logUser($user);
$this->mock_web_client = $this->mock();
$sigb_comm = Class_IntBib::find(3)->getSIGBComm();
$sigb_comm->setWebClient($this->mock_web_client);
public function tearDown() {
Class_IntBib::find(3)->getSIGBComm()->setWebClient(null);
parent::tearDown();
}
class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaRestfulTest extends AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase {
public function setUp() {
parent::setup();
$this->dispatch('/opac/abonne/suggestion-achat-add', true);
}
public function formShouldContainsTextAreaForPatronReason() {
$this->assertXPath('//form//textarea[@name="PatronReason"]');
public function formShouldContainsInputForTitle() {
$this->assertXPath('//form//input[@name="Title"][@placeholder="ex: Harry Potter à l\'école des sorciers"]');
public function formShouldContainsInputForAuthor() {
$this->assertXPath('//form//input[@name="Author"][@placeholder="ex: Joanne Kathleen Rowling"]');
public function formShouldContainsInputForIsbn() {
$this->assertXPath('//form//input[@name="Isbn"][@placeholder="ex: 2-07-054127-4"]');
public function formShouldContainsInputForPublicationYear() {
$this->assertXPath('//form//input[@name="PublicationYear"][@placeholder="2015"]');
}
}
class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaRestfulPostTest extends AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase {
public function setUp() {
parent::setUp();
$this->mock_web_client
->whenCalled('open_url')
->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=azerty&id_type=cardnumber')
->answers('<xml><id>234</id></xml>');
$this->postDispatch('/opac/abonne/suggestion-achat-add',
['Title' => 'Harry Potter',
'Author' => 'J.K.Rowling',
'Isbn' => '2-07-0541 27_4',
'PatronReason' => 'Je veux le lire',
'PublicationYear' => '2014',
'submit' => 'Envoyer']);
}
/** @test */
public function dataShouldHaveBeenPosted() {
$this->assertTrue($this->mock_web_client->methodHasBeenCalled('postData'));
public function dataShouldBeJsonEncoded() {
$datas = json_decode($this->mock_web_client->getAttributesForLastCallOn('postData')[1]['data'],
true);
$this->assertEquals(['title' => 'Harry Potter',
'author' => 'J.K.Rowling',
'isbn' => '2-07-0541 27_4',
'patronreason' => 'Je veux le lire',
'publicationyear' => '2014',
'suggestedby' => '234'],
$datas);
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
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,
$_storm_default_to_volatile = true,
$_mail;
protected function _loginHook($account) {
$account->username = 'Arnaud';
$account->ID_USER = 666;
}
public function setUp() {
parent::setUp();
Class_CosmoVar::newInstanceWithId('types_docs', ['liste' => '']);
$codif_type_doc=$this->fixture('Class_CodifTypeDoc', ['id' => 102,
'famille_id' => Class_CodifTypeDoc::LIVRE,
'bibliotheques' => '2;3',
'annexes' => '4;8',
'sections' => '9;10']);
$this->fixture('Class_TypeDoc', ['id' => Class_TypeDoc::LIVRE,
'codif_type_doc' => $codif_type_doc,
'label'=> 'Livres Numériques']);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_SuggestionAchat')
->whenCalled('save')
->willDo(
function($suggestion){
$this->_suggestion = $suggestion->setId(66);
});
}
}
class AbonneControllerSuggestionAchatAddPostValidDataTest extends AbonneControllerSuggestionAchatAddPostTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Bib', ['id' => 11,
'libelle' => 'Bib de la plage',
'mail' => 'albert@jean.fr',
'mail_suggestions' => '']);
$mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($mock_transport);
$this->postDispatch('/opac/abonne/suggestion-achat-add',
['titre' => 'Harry Potter',
'auteur' => 'J.K.Rowling',
'type_doc_id' => Class_TypeDoc::LIVRE,
'description_url' => 'http://harrypotter.fr',
'isbn' => '2-07-0541 27_4',
'bib_id' => '11',
'submit' => 'Envoyer']);
$this->_mail = $mock_transport->sent_mail;
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
}
/** @test */
public function newSuggestionShouldHaveTitreHarryPotter() {
$this->assertEquals('Harry Potter', $this->_suggestion->getTitre());
}
/** @test */
public function newSuggestionShouldHaveAuteurJKRowling() {
$this->assertEquals('J.K.Rowling', $this->_suggestion->getAuteur());
}
/** @test */
public function newSuggetionShouldHaveDescriptionUrlHarryPotterDotFr() {
$this->assertEquals('http://harrypotter.fr', $this->_suggestion->getDescriptionUrl());
}
/** @test */
public function newSuggestionsShouldHaveIsbn2070541274() {
$this->assertEquals('2070541274', $this->_suggestion->getIsbn());
}
/** @test */
public function newSuggestionsShouldHaveDocumentType2() {
$this->assertEquals('Livres Numériques', $this->_suggestion->getTypeDoc()->getLibelle());
}
/** @test */
public function shouldNotHaveSubmitAttribute() {
$this->assertNotContains('submit', array_keys($this->_suggestion->toArray()));
}
/** @test */
public function newSuggestionShouldHaveCommentaireJeVeuxLeLire() {
$this->assertEquals('Je veux le lire', $this->_suggestion->getCommentaire());
}
/** @test */
public function newSuggestionShouldBelongsToArnaud() {
$this->assertEquals('Arnaud', $this->_suggestion->getUser()->getLogin());
}
/** @test */
public function newSuggetionShouldDateCreationShouldBeToday() {
$this->assertEquals(date('Y-m-d'), $this->_suggestion->getDateCreation());
}
/** @test */
public function responseShouldRedirectToSuggestionAchatId66() {
$this->assertRedirectTo('/opac/abonne/suggestion-achat');
/** @test */
public function sentMailSubjectShouldBeSuggestionAchatHarryPotter() {
$this->assertEquals('Suggestion d\'achat: Harry Potter', $this->_mail->getSubject());
}
/** @test */
public function fromShouldBeNoReplyAtLocalhost() {
$this->assertEquals('noreply@localhost', $this->_mail->getFrom());
}

llaffont
committed
/** @test */
public function toShouldBeJeanJeanFr() {
$this->assertEquals('albert@jean.fr', $this->_mail->getRecipients()[0]);
}

llaffont
committed
/** @test */
public function saveShouldBeNotified() {
$this->assertFlashMessengerContentContains('Suggestion d\'achat enregistrée');

llaffont
committed
}
}
class AbonneControllerSuggestionAchatAddPostWithMailSuggestions extends AbonneControllerSuggestionAchatAddPostTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Bib', ['id' => 11,
'libelle' => 'Bib de la plage',
'mail' => 'jean@jean.fr',
'mail_suggestions' => 'jean@jean.fr']);
$mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($mock_transport);
$this->postDispatch('/opac/abonne/suggestion-achat-add',
['titre' => 'Harry Potter',
'auteur' => 'J.K.Rowling',
'type_doc_id' => Class_TypeDoc::LIVRE,
'description_url' => 'http://harrypotter.fr',
'isbn' => '2-07-0541 27_4',
'bib_id' => '11',
'commentaire' => 'Je veux le lire',
'submit' => 'Envoyer']);
$this->_mail = $mock_transport->sent_mail;
}
/** @test */
public function toShouldBeJeanJeanFr() {
$this->assertEquals('jean@jean.fr', $this->_mail->getRecipients()[0]);
}
}

gloas
committed
class AbonneControllerSuggestionAchatAddPostValidDataButNoMailSentTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;

llaffont
committed
protected $_suggestion;
protected $_mail;
public function setUp() {
parent::setUp();
Class_Users::getIdentity()->setMail('');
Class_Profil::getPortail()->setMailSite('');
Class_Profil::getCurrentProfil()->setMailSite('');
$mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($mock_transport);

llaffont
committed
$mock_transport->onSendDo(function() {throw new Zend_Mail_Exception('some error');});

llaffont
committed
$this->postDispatch('/opac/abonne/suggestion-achat-add',

llaffont
committed
['titre' => 'Harry Potter',
'description_url' => '',

llaffont
committed
'isbn' => '',
'commentaire' => '',

llaffont
committed
}
/** @test */
public function notificationShouldContainsAucunCourrielEnvoye() {
$this->assertFlashMessengerContentContains('Aucun courriel envoyé, erreur: some error');

llaffont
committed
}
/** @test */
public function newSuggestionShouldHaveTitreHarryPotter() {
$this->assertNotNull(Class_SuggestionAchat::findFirstBy(['titre' => 'Harry Potter']));

llaffont
committed
}

gloas
committed
class AbonneControllerSuggestionAchatAddPostWrongDataTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_Profil::getCurrentProfil()
->setCfgModules(['index' => ['formulairecontact' => ['bib_selector' => 1]]]);
$this->fixture('Class_Bib',
['id' => 2,
'libelle' => 'My Bib',
'mail' => 'my_bib@afi-sa.fr']);
Class_SuggestionAchat::beVolatile();
$this->postDispatch('/opac/abonne/suggestion-achat-add',
['titre' => '',
'auteur' => '',
'description_url' => 'h p',
'isbn' => '207',
'commentaire' => '']);
}
/** @test */
public function errorForTitreAndCommentaireShouldBeTitreOuCommentaireRequis() {
$this->assertXPathContentContains('//li', 'Titre ou commentaire requis');
}
/** @test */
public function errorForDescriptionUrlShouldBeURLInvalide() {
$this->assertXPathContentContains('//li', '\'h p\' n\'est pas une URL valide');
}
/** @test */
public function errorForIsbnShouldBeFormatIncorrect() {
$this->assertXPathContentContains('//li', '\'207\' n\'est pas un ISBN valide');
}
/** @test */
public function errorForBibSelectorShouldBePresent() {
$this->assertXPathContentContains('//li', 'Veuillez sélectionner une bibliothèque');
}
}

gloas
committed
class AbonneControllerSuggestionAchatAddDataWithEmptyFieldsNotRequiredTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_SuggestionAchat')
->whenCalled('save')
->answers(true);
$this->postDispatch('/opac/abonne/suggestion-achat-add',
['titre' => 'Millenium',
'auteur' => 'Stieg Larsson',
'type_doc_id' => 2,
'description_url' => '',
'isbn' => '',
'commentaire' => ''],
}
/** @test */
public function responseShouldBeARedirect() {
$this->assertRedirect();
}
}

gloas
committed
class AbonneControllerSuggestionAchatAddWithIdTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_SuggestionAchat::newInstanceWithId(66);

gloas
committed
$this->dispatch('/opac/abonne/suggestion-achat-add/id/66', true);
}
/** @test */
public function pageShouldDisplaySuggestionPriseEnCompte() {
$this->assertXPathContentContains('//p', 'Votre suggestion d\'achat');
}
/** @test **/
public function pageShouldContainsALinkToSuggestionAchat() {
$this->assertXPath('//a[contains(@href, "/abonne/suggestion-achat")]',$this->_response->getBody());
}

gloas
committed
class AbonneControllerSuggestionAchatWithOutSuggestionTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;

gloas
committed
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/suggestion-achat', true);
}
/** @test */
public function pageShouldDisplayLinkForSuggererSuggestion() {
$this->assertXPath('//a[contains(@href,"/abonne/suggestion-achat-add")]');
}

gloas
committed
/** @test **/
public function pageShouldDisplayPasDeSuggestion() {
$this->assertXpathContentContains('//div/span', 'Vous n\'avez pas encore fait de suggestion.',$this->_response->getBody());
}
}
class AbonneControllerSuggestionAchatWithOneSuggestionTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$user = $this->fixture('Class_Users',
['id' => 1,
'login' => 'Tom',
'password' => 'pwd']);
ZendAfi_Auth::getInstance()->logUser($user);
$suggestion = $this->fixture('Class_SuggestionAchat',
['id' => 1,
'commentaire' => 'New edition is available.',
'description_url' => '',
'isbn' => '',
'type_doc_id' => Class_CodifTypeDoc::VIDEO]);
$user->setSuggestionAchat([$suggestion])->save();
$this->dispatch('/opac/abonne/suggestion-achat', true);
}
/** @test */
public function loggedUserShouldHaveOneSuggestion() {
$this->assertXPathContentContains('//dl/dt', 'Commentaire');
}
/** @test */
public function suggestionShouldHaveTypeDocDVD() {
$this->assertXPathContentContains('//dl//dd', 'DVD');
}
}
class AbonneControllerSuggestionAchatWithOneRestfulSuggestionTest
extends AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase {
public function setUp() {
parent::setUp();
$logger = $this->mock()
->whenCalled('log')->answers(true)
->whenCalled('logError')
->willDo(
function($url, $message) {
throw new RuntimeException($url . ' :: ' . $message);
});
Class_WebService_SIGB_AbstractService::setLogger($logger);
$this->mock_web_client
->whenCalled('open_url')
->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=azerty&id_type=cardnumber')
->answers('<xml><id>234</id></xml>')
->whenCalled('open_url')
->with('http://plage.com/cgi-bin/koha/rest.pl/suggestions?suggestedby=234')
->answers('[{
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
"date" : "2014-04-01 16:08:36",
"STATUS" : "ASKED",
"suggestionid" : "6197",
"branchcodemanagedby" : "",
"accepteddate" : "",
"borrnummanagedby" : "",
"emailmanagedby" : "",
"branchcodesuggestedby" : "IST",
"isbn" : "9782814101425 ",
"emailsuggestedby" : "",
"branchcode" : "IST",
"copyrightdate" : "0",
"budgetid" : "",
"reason" : null,
"ASKED" : 1,
"total" : "",
"surnamemanagedby" : "",
"branchnamesuggestedby" : "Test",
"price" : "",
"title" : "En piste ! : Créations en couture pour petits et grands Enfant",
"collectiontitle" : "",
"publicationyear" : "2012",
"itemtype" : "",
"place" : "",
"author" : "Laëtitia Gheno",
"suggesteddate" : "2013-11-14",
"currency" : "",
"borrnumsuggestedby" : "234",
"biblionumber" : "",
"categorycodesuggestedby" : "",
"manageddate" : "",
"acceptedby" : "",
"firstnamesuggestedby" : "",
"surnamesuggestedby" : "",
"publishercode" : "",
"suggestedby" : "234",
"rejecteddate" : null,
"firstnamemanagedby" : "",
"rejectedby" : null,
"quantity" : "0",
"note" : "D.L.",
"patronreason" : "Je veux le lire",
"categorydescriptionsuggestedby" : "",
"volumedesc" : null,
"mailoverseeing" : "0",
"managedby" : ""}]')
->beStrict();
$this->fixture('Class_CodifAnnexe',
['id' => 15,
'libelle' => 'Istres',
'code' => 'IST']);
$this->dispatch('/opac/abonne/suggestion-achat', true);
}
public function tearDown() {
Class_WebService_SIGB_AbstractService::setLogger(null);
parent::tearDown();
}
/** @test */
public function titleShouldBePresent() {
$this->assertXPathContentContains('//dd', 'En piste ! : Créations en couture pour petits et grands Enfant');
}
/** @test */
public function authorShouldBePrensent() {
$this->assertXPathContentContains('//dd', 'Laëtitia Gheno');
}
/** @test */
public function publicationYearShouldBePresent() {
$this->assertXPathContentContains('//dd', '2012');
}
/** @test */
public function libraryShouldBePresent() {
$this->assertXPathContentContains('//dd', 'Istres');
}
/** @test */
public function suggestDateShouldBePresent() {
$this->assertXPathContentContains('//dd', '2013-11-14');
}
/** @test */
public function patronReasonShouldBePresent() {
$this->assertXPathContentContains('//dd', 'Je veux le lire');
}
/** @test */
public function statusShouldBePresent() {
$this->assertXPathContentContains('//dd', 'En attente');
}
}
class AbonneControllerSuggestionAchatWithRestfulErrorTest
extends AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaTestCase {
public function setUp() {
parent::setUp();
$logger = $this->mock()
->whenCalled('log')->answers(true)
->whenCalled('logError')
->willDo(
function($url, $message) {
throw new RuntimeException($url . ' :: ' . $message);
});
Class_WebService_SIGB_AbstractService::setLogger($logger);
$this->mock_web_client
->whenCalled('open_url')
->with('http://plage.com/cgi-bin/koha/ilsdi.pl?service=LookupPatron&id=azerty&id_type=cardnumber')
->answers('<?xml version="1.0" encoding="UTF-8" ?>
<LookupPatron>
<id>234</id>
</LookupPatron>')
->whenCalled('open_url')
->with('http://plage.com/cgi-bin/koha/rest.pl/suggestions?suggestedby=234')
->answers('[
"Forbidden. 178.16.171.35 is not allowed to use this service. Are you sure configuration variable \'authorizedips\' is correctly configured?"
]');
$this->fixture('Class_CodifAnnexe',
['id' => 15,
'libelle' => 'Istres',
'code' => 'IST']);
$this->dispatch('/opac/abonne/suggestion-achat', true);
}
public function tearDown() {
Class_WebService_SIGB_AbstractService::setLogger(null);
parent::tearDown();
}
/** @test */
public function shouldNotDisplaySuggestionsList() {
$this->assertNotXPath('//dl');
}
/** @test */
public function shouldDisplayWebserviceError() {
$this->assertXPathContentContains('//div',
'Forbidden. 178.16.171.35 is not allowed to use this service. Are you sure configuration variable \'authorizedips\' is correctly configured?');
}
}
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
class ModulesControllerAbonneSuggestionAchatTest extends Admin_AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_Profil::getCurrentProfil()
->setCfgModules(['abonne' => ['suggestion-achat' => ['help-text' => 'Entrez votre suggestion']]]);
$this->dispatch('/admin/modules/abonne?id_profil=2&action1=suggestion-achat&type_module=abonne&config=site', true);
}
/** @test */
public function titleShouldBeProperty() {
$this->assertXPathContentContains('//h1', 'Propriétés du module : Abonne');
}
/** @test */
public function textareHelpTextShouldContainsEntrezVotreSuggestion() {
$this->assertXPathContentContains('//textarea[@name="help-text"]',
'Entrez votre suggestion');
}
/** @test */
public function textareHelpTextShouldBeCkeditor() {
$this->assertXPathContentContains('//script',
'CKEDITOR.replace(\'cke-help-text\'');
}
}
?>