-
Laurent authoredd870da2d
RechercheControllerAlbumWebSiteTest.php 6.55 KiB
<?php
/**
* Copyright (c) 2012, 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 RechercheControllerAlbumWebSiteTestCase extends AbstractControllerTestCase {
protected
$_wikipedia,
$_linuxfr,
$_framasoft,
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this
->_setupWikipedia()
->_setupLinuxFr()
->_setupFramasoft();
}
protected function _setupWikipedia() {
$this->_wikipedia = $this->fixture('Class_Album',
['id' => 1,
'type_doc_id' => Class_TypeDoc::WEBSITE,
'titre' => 'Wikipedia',
'status' => Class_Album::STATUS_VALIDATED]);
$this->_wikipedia
->addRessource($this->fixture('Class_AlbumRessource',
['id' => 1,
'titre' => 'Wikipedia',
'url' => 'http://www.wikipedia.org']))
->assertSave();
$this->_wikipedia->index();
return $this;
}
protected function _setupLinuxFr() {
$this->_linuxfr = $this->fixture('Class_Album',
['id' => 2,
'type_doc_id' => Class_TypeDoc::WEBSITE,
'titre' => 'Linuxfr',
'status' => Class_Album::STATUS_VALIDATED]);
$this->_linuxfr
->addRessource($this->fixture('Class_AlbumRessource',
['id' => 21,
'titre' => 'Linuxfr',
'description' => 'Toutes les news linux francophones',
'poster' => 'linuxfr.jpg',
'url' => 'http://www.linuxfr.org']))
->assertSave();
$this->_linuxfr->index();
return $this;
}
protected function _setupFramasoft() {
$this->_framasoft = $this->fixture('Class_Album',
['id' => 3,
'type_doc_id' => Class_TypeDoc::WEBSITE,
'titre' => 'Framasoft',
'status' => Class_Album::STATUS_VALIDATED]);
$this->_framasoft
->addRessource($this->fixture('Class_AlbumRessource',
['id' => 31,
'titre' => 'Framabee',
'poster' => 'framabee.jpg',
'url' => 'http://www.framabee.org']))
->addRessource($this->fixture('Class_AlbumRessource',
['id' => 32,
'titre' => 'Framasphere',
'poster' => 'framasphere.jpg',
'url' => 'http://www.framasphere.org']))
->addRessource($this->fixture('Class_AlbumRessource',
['id' => 33,
'titre' => 'Framabin',
'poster' => 'framabin.jpg',
'url' => 'http://www.framabin.org']))
->assertSave();
$this->_framasoft->index();
return $this;
}
}
class RechercheControllerAlbumWebSiteTest extends RechercheControllerAlbumWebSiteTestCase {
/** @test */
public function albumIsWebSiteShouldBeTrue() {
$this->assertTrue($this->_wikipedia->isWebSite());
}
}
class RechercheControllerAlbumWebSiteWikipediaResNumeriquesTest extends RechercheControllerAlbumWebSiteTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/noticeajax/resnumeriques/id_notice/1', true);
}
/** @test */
public function iframeShouldHaveSrcWikipediaDotOrg() {
$this->assertXPath('//a/iframe[@src="http://www.wikipedia.org"]',
$this->_response->getBody());
}
}
class RechercheControllerAlbumWebSiteLinuxFrResNumeriquesTest extends RechercheControllerAlbumWebSiteTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/noticeajax/resnumeriques/id_notice/2', true);
}
/** @test */
public function descriptionShouldBeDisplayedInAParagraph() {
$this->assertXPathContentContains('//section//p',
'Toutes les news linux',
$this->_response->getBody());
}
/** @test */
public function titleShouldBeDisplayedInAH3() {
$this->assertXPathContentContains('//section/h3',
'Linuxfr');
}
/** @test */
public function imageLinuxFRDotJpgShouldBeDisplayedInAnchorToLinuxFR() {
$this->assertXPath('//a[@href="http://www.linuxfr.org"]'.
'//img[contains(@src, "linuxfr.jpg")][@title="Ouvrir le site dans un nouvel onglet"]',
$this->_response->getBody());
}
}
class RechercheControllerAlbumWebSiteFramasoftResNumeriquesTest extends RechercheControllerAlbumWebSiteTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/noticeajax/resnumeriques/id_notice/3', true);
}
/** @test */
public function imageFramabeeDotJpgShouldBeDisplayedInAnchorToFramabee() {
$this->assertXPath('//a[@href="http://www.framabee.org"]'.
'//img[contains(@src, "framabee.jpg")][@title="Ouvrir le site dans un nouvel onglet"]',
$this->_response->getBody());
}
/** @test */
public function imageFramabinDotJpgShouldBeDisplayedInAnchorToFramabin() {
$this->assertXPath('//a[@href="http://www.framabin.org"]'.
'//img[contains(@src, "framabin.jpg")][@title="Ouvrir le site dans un nouvel onglet"]',
$this->_response->getBody());
}
}
?>