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
*/
abstract class RechercheControllerSearchExtensionTestCase extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Zend_Registry::set('sql',
$this->mock()
->whenCalled('fetchAll')
->answers([]));
$this->_prepareFixtures();
$this->dispatch('/opac/recherche/simple?expressionRecherche=sport', true);
}
protected function _prepareFixtures() {
$this->fixture('Class_AdminVar',
['id' => 'SEARCH_ALSO_IN',
'valeur' => json_encode($this->_extensionSites())]);
}
protected function _extensionSites() {
return ['site_label' => [''], 'site_url' => ['']];
}
}
class RechercheControllerSearchExtensionDisabledTest
extends RechercheControllerSearchExtensionTestCase {
protected function _prepareFixtures() {}
/** @test */
public function shouldNotContainsExtensionLinks() {
$this->assertNotXPathContentContains('//div', 'Rechercher aussi sur');
class RechercheControllerSearchExtensionEnabledWithEmptySiteAndUrlTest
extends RechercheControllerSearchExtensionTestCase {
/** @test */
public function shouldNotContainsExtensionLinks() {
$this->assertNotXPathContentContains('//div', 'Rechercher aussi sur');
}
class RechercheControllerSearchExtensionEnabledWithSiteAndNoUrlTest
extends RechercheControllerSearchExtensionTestCase {
protected function _extensionSites() {
return ['site_label' => ['Jumel'], 'site_url' => ['']];
}
/** @test */
public function shouldNotContainsExtensionLinks() {
$this->assertNotXPathContentContains('//div', 'Rechercher aussi sur');
}
}
class RechercheControllerSearchExtensionEnabledWithUrlAndNoSiteTest
extends RechercheControllerSearchExtensionTestCase {
protected function _extensionSites() {
return ['site_label' => [''], 'site_url' => ['http://jumel.org?q=%s']];
}
/** @test */
public function shouldNotContainsExtensionLinks() {
$this->assertNotXPathContentContains('//div', 'Rechercher aussi sur');
}
}
class RechercheControllerSearchExtensionEnabledTest
extends RechercheControllerSearchExtensionTestCase {
protected function _extensionSites() {
return ['site_label' => ['Jumel',
'Trouvons.org',
'Gallica'],
'site_url' => ['http://www.jumel39.fr/rechercher?search_api_views_fulltext=%s',
'http://trouvons.org/#q=%s',
'http://gallica.bnf.fr/services/engine/search/sru?operation=searchRetrieve&version=1.2&query=(gallica all "%s")']];
/** @test */
public function shouldContainsExtensionLinks() {
$this->assertXPathContentContains('//div', 'Rechercher aussi sur');
}
/** @test */
public function shouldContainsJumelLink() {
$this->assertXPathContentContains('//a[contains(@href, "rechercher?search_api_views_fulltext=sport")]',
'Jumel');
}
public function shouldNotDisplayIncompletLink() {
$this->assertNotXPathContentContains('//a', 'Incomplete');
}
/** @test */
public function shouldContainsTrouvonsLink() {
$this->assertXPathContentContains('//a[contains(@href, "#q=sport")]',
'Trouvons.org');
/** @test */
public function gallicaLinkShouldBeRendered() {
$this->assertXPathContentContains('//a[contains(@href, "gallica all ")][contains(@href, "sport")]',
}
class RechercheControllerSearchExtensionWithoutTermsTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Zend_Registry::set('sql',
$this->mock()
->whenCalled('fetchAll')
->answers([]));
$this->fixture('Class_AdminVar',
['id' => 'SEARCH_ALSO_IN',
'valeur' => json_encode(['site_label' => ['Jumel'],
'site_url' => ['http://www.jumel39.fr/rechercher?search_api_views_fulltext=%s']])]);
$this->dispatch('/opac/recherche/simple?type_doc=&tri=*&expressionRecherche=', true);
}
/** @test */
public function shouldNotContainsExtensionLinks() {
$this->assertNotXPathContentContains('//div', 'Rechercher aussi sur');