Skip to content
Snippets Groups Projects
OAIControllerListSetsTest.php 3.49 KiB
Newer Older
<?php
/**
 * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
 *
Laurent's avatar
Laurent committed
 * 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).
 *
Laurent's avatar
Laurent committed
 * 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
Laurent's avatar
Laurent committed
 * along with BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
 */
require_once 'AbstractControllerTestCase.php';
class OAIControllerListSetsTest extends AbstractControllerTestCase {
Patrick Barroca's avatar
Patrick Barroca committed
  protected $_xpath;
Patrick Barroca's avatar
Patrick Barroca committed
  public function setUp() {
    parent::setUp();
Patrick Barroca's avatar
Patrick Barroca committed
    $this->_xpath = TestXPathFactory::newOai();
Patrick Barroca's avatar
Patrick Barroca committed
    $catalogue_bd = Class_Catalogue::getLoader()->newInstanceWithId(1)
      ->setLibelle('BDs')
      ->setOaiSpec('livres:bd');
    $catalogue_musique = Class_Catalogue::getLoader()->newInstanceWithId(2)
      ->setLibelle('Musique')
      ->setDescription('La musique qui balance')
      ->setOaiSpec('music');
Patrick Barroca's avatar
Patrick Barroca committed
    Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue')
      ->whenCalled('findAllBy')
      ->with(array('where' => 'oai_spec is not null',
                   'where' => 'oai_spec !=\'\'',
                   'order' => 'oai_spec'))
      ->answers(array($catalogue_bd, $catalogue_musique));
Patrick Barroca's avatar
Patrick Barroca committed
    $this->dispatch('/opac/oai/request?verb=ListSets');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function setMusiqueShouldContainSpecMusic() {
    $this->_xpath->assertXpathContentContains($this->_response->getBody(),
                                              '//oai:ListSets/oai:set/oai:setSpec',
                                              'music');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function setMusiqueShouldContainNameMusique() {
    $this->_xpath->assertXpathContentContains($this->_response->getBody(),
                                              '//oai:ListSets/oai:set/oai:setName',
                                              'Musique');
  }


  /** @test */
Patrick Barroca's avatar
Patrick Barroca committed
  public function setMusiqueShouldContainDescriptionLaMusiqueQuiBalance() {
    $this->_xpath->assertXpathContentContains($this->_response->getBody(),
                                              '//oai:ListSets/oai:set/oai:setDescription',
                                              'La musique qui balance');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function setBdsShouldContainsSpecLivresColonBds() {
    $this->_xpath->assertXpathContentContains($this->_response->getBody(),
                                              '//oai:ListSets/oai:set/oai:setSpec',
                                              'livres:bd');
  }
Patrick Barroca's avatar
Patrick Barroca committed
  /** @test */
  public function setBdsShouldContainsNameBds() {
    $this->_xpath->assertXpathContentContains($this->_response->getBody(),
                                              '//oai:ListSets/oai:set/oai:setName',
                                              'BDs');     
  }


  /** @test */
Patrick Barroca's avatar
Patrick Barroca committed
  public function setBdsShouldNotContainDescription() {
    $this->_xpath->assertNotXpath($this->_response->getBody(),
                                  '//oai:ListSets/oai:set/oai:setSpec[text()="livres:bd"][following-sibling::oai:setDescription]');
  }