Skip to content
Snippets Groups Projects
NoticeAjaxControllerCdScriptTest.php 4.2 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
 *
 * BOKEH is free software; you can redistribute it and/or modify
 * 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).
 *
 * BOKEH is distributed in the hope that it will be useful,
 * 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
 * along with BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */


class NoticeAjaxControllerCdScriptRecordTest extends AbstractControllerTestCase {
  protected
    $_storm_default_to_volatile = true,
    $_sigb_le_kiosque,
    $_paul;
    $this->_paul = $this->fixture('Class_Users',
                                  ['id' => 15,
                                   'login' => 'paul',
                                   'nom' => 'Le Pollux',
                                   'prenom' => 'Paul',
                                   'id_sigb' => '654987',
                                   'mail' => 'anemail@web.com',
                                   'naissance' => '2002-12-14',
                                   'password' => 'pollux',
                                   'date_fin' => '2015-12-14']);

    ZendAfi_Auth::getInstance()->logUser($this->_paul);

    $config = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray();
    $config['exemplaires']['grouper'] = '1';
    Class_Profil::getCurrentProfil()->setCfgNotice($config);

    $this->fixture('Class_IntBib',
Ghislain Loas's avatar
Ghislain Loas committed
                   ['id' => 31,
                    'libelle' => 'le kiosque library',
                    'comm_sigb' => Class_IntBib::COM_CDSCRIPT]);

    $this->fixture('Class_Bib',
                   ['id' => 3,
                    'libelle' => 'Le kiosque library']);

    $this->_item_le_kiosque = $this->fixture('Class_Exemplaire',
                                        ['id' => 1,
                                         'code_barres' => '456789',
                                         'id_origine' => '456789',
Ghislain Loas's avatar
Ghislain Loas committed
                                         'id_int_bib' => 31,
                                         'id_bib' => 3,
                                         'zone995' => 'a:3:{i:0;a:2:{s:4:"code";s:1:"a";s:6:"valeur";s:10:"Le Kiosque";}i:1;a:2:{s:4:"code";s:1:"b";s:6:"valeur";s:3:"kio";}i:2;a:2:{s:4:"code";s:1:"f";s:6:"valeur";s:3:"319";}}']);
    $this->_record_le_kiosque = $this->fixture('Class_Notice',
                                               ['id' => 2,
                                               'exemplaires' => [$this->_item_le_kiosque]]);

    $this->_service = Class_WebService_SIGB_CdScript::getService(['server_url' => 'www.jumel39.fr/docnum.php',
                                                                  'remote_library_id' => 2]);
    $this->_service->setTimeSource(new TimeSourceForTest('2015-10-28 09:00:00'));
    $this->_sigb_le_kiosque = $this->_service->getNotice('456789')->getExemplaireByCodeBarre('456789');

    $this->dispatch('/opac/noticeajax/exemplaires/id_notice/2', true);
  }


  /** @test */
  public function linkToJumelShouldBePresent() {
    $this->assertXPathContentContains('//table//a[contains(@href, "www.jumel39.fr/docnum.php?bib=2&res=kio&lien=456789&time=1446019200&user=654987:Le Pollux:Paul:2002-12-14::2015-12-14")]', 'Description en ligne', $this->_response->getBody());
  }


  /** @test */
  public function libraryLabelShouldBeLeKiosqueLibrary() {
    $this->assertXPathContentContains('//table//td', 'Le kiosque library');


  /** @test */
  public function scriptTargetBlankShouldBePresent() {
    $this->assertXPathContentContains('//script', 'setupAnchorsTarget');