Newer
Older
<?php
/**
* Copyright (c) 2012-2014, 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
abstract class RechercheControllerReservationTestCase
extends AbstractControllerTestCase {
protected $_json, $_xpath,
$_storm_default_to_volatile = true;
$this->fixture(Class_CodifAnnexe::class,
'code' => '36',
'id_origine' => '36',
$this->fixture(Class_CodifAnnexe::class,
'code' => '37',
'id_origine' => '37',
$this->fixture(Class_Notice::class,
['id' => 124,
'titre' => 'Aimer'
]);
$this->fixture(Class_IntBib::class,
['id' => 12,
'sigb_comm' => Class_IntBib::COM_NANOOK,
'comm_params' => ['url_serveur' => 'http://valensol.net']]);
$this->fixture(Class_Exemplaire::class,
['id' => 13425,
'id_origine' => 12,
'id_int_bib' => 12,
'notice_id' => 124,
'code_barres' => '1242',
]);
$this->_xpath = new Storm_Test_XPath();
}
}
abstract class RechercheControllerReservationWithPickupChoiceTestCase
extends RechercheControllerReservationTestCase {
public function setUp() {
parent::setUp();
Class_CosmoVar::setValueOf('site_retrait_resa',
Class_CosmoVar::PICKUP_LOCATION_CHOICE);
}
}
class RechercheControllerReservationPickupAjaxActionWithChosenPickupTest
extends RechercheControllerReservationWithPickupChoiceTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=36©_id=13425',true);
$this->_json = json_decode($this->_response->getBody());
}
/** @test */
public function shouldRenderAnnecyCheckedRadio() {
$this->_xpath->assertXPath($this->_json->content,
'//input[@name="code_annexe"][@value="36"][@checked="checked"]',$this->_json->content);
/** @test */
public function shouldRenderCranRadio() {
$this->_xpath->assertXPath($this->_json->content,
'//input[@name="code_annexe"][@value="37"]');
/** @test */
public function layoutShouldBeEmpty() {
$this->_xpath->assertNotXPath($this->_json->content, '//div[@id="banniere"]');
}
class RechercheControllerReservationPickupAjaxActionPostTest
extends RechercheControllerReservationWithPickupChoiceTestCase {
/** @test */
public function responseShouldRedirectToReservationajaxAction() {
$this->postDispatch('recherche/reservation-pickup-ajax',
['id_bib' => 2,
'id_origine' => 12,
'code_annexe' => '36']);

Ghislain Loas
committed
$this->assertRedirectTo('/recherche/reservationajax/code_annexe/36');

Arthur Suzuki
committed
/** @test */
public function withoutAvailablePickupLocationPostResponseShouldAnswerError() {
Class_CodifAnnexe::deleteBy([]);
$this->postDispatch('recherche/reservation-pickup-ajax',
['id_bib' => 2,
'id_origine' => 12,

Arthur Suzuki
committed
'code_annexe' => '36']);
$json = json_decode($this->_response->getBody(), true);
$this->assertContains('Aucun site de retrait disponible', $json['content']);
}
/** @test */
public function withoutAvailablePickupLocationGETResponseShouldAnswerError() {
Class_CodifAnnexe::deleteBy([]);
$this->dispatch('recherche/reservation-pickup-ajax/id_bib/2/id_origine/12/copy_id/13425');

Arthur Suzuki
committed
$json = json_decode($this->_response->getBody(), true);
$this->assertContains('Aucun site de retrait disponible', $json['content']);
}
/** @test */
public function withPopupAndInspectorGadgetResponseShouldStillSendJSON() {
Zend_Registry::get('session')->inspectorCalls = [serialize(new Class_InspectorGadget_ServiceCall('I', 'love', 'milk', 'coffee', '418'))];

Arthur Suzuki
committed
$this->postDispatch('recherche/reservation-pickup-ajax/render/popup/inspector_gadget/1',
['id_bib' => 2,
'id_origine' => 12,

Arthur Suzuki
committed
'code_annexe' => '36']);
$this->assertNotNull($json = json_decode($this->_response->getBody(), true));
$this->assertContains('<script>location.reload();</script>', $json['content']);
}
public function responseShouldContainsJsonRedirectToReservationajaxAction() {
$this->postDispatch('recherche/reservation-pickup-ajax/render/popup',
['id_bib' => 2,
'id_origine' => 12,
'code_annexe' => '36']);
$json = json_decode($this->_response->getBody(), true);
$this->assertContains('<script>location.reload();</script>', $json['content']);
}
class RechercheControllerReservationPickupAjaxActionTestWithChosenPickupDispatch
extends RechercheControllerReservationWithPickupChoiceTestCase {

Henri-Damien LAURENT
committed
protected $_sent_mails;
$bib = $this
['id' => 1,
'comm_sigb' => Class_IntBib::COM_NANOOK,
'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]);
Loading full blame...