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 RechercheControllerPrintActionLinkTest extends AbstractControllerTestCase {
$this->fixture('Class_ModeleFusion', ['id' => 1,
'nom' => 'recherche',
'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> {titre_principal} <div>{article.contenu}</div>
'type' => 'Notice_List']);
$this->fixture('Class_Catalogue',
['id'=>3,
'libelle' => 'Nouveautés',
'auteur' => 'Paul']);
$mock_sql = $this->mock()
->whenCalled('fetchAll')
->with("select id_notice, facettes from notices Where MATCH(facettes) AGAINST('+(APaul)' IN BOOLEAN MODE) order by annee desc", true, false)
->answers([ [1, ''] ])
->whenCalled('fetchAll')
->answers([$this->fixture('Class_Notice',
['id' => 1])->toArray()])
->beStrict();
Zend_Registry::set('sql', $mock_sql);
$this->dispatch('/recherche/simple/id_catalogue/3/id_module/9/aleatoire/1', true);
}
$this->assertXPathContentContains('//a[contains(@href, "/recherche/print/id_catalogue/3/id_module/9/aleatoire/1/filtres/APaul%3B/ids/1/strategy/Notice_List/modele_fusion/1")][@target="_blank"]',
'Imprimer',
$this->_response->getBody());
}
class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTestCase {
$this->fixture('Class_ModeleFusion', ['id' => 1,
'nom' => 'recherche',
'contenu' => '<p> {notices.each[<img src="{url_vignette}"/> <h1>{titre_principal}</h1> <div>{article.contenu}</div> <div>{resume}</div>
Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 10,
'titre' => 'pomme',
'contenu' => '<p>blabla</p>',
'notice' => new Class_Notice(),
'type_doc_id' => Class_TypeDoc::ARTICLE]));
Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12,
'titre' => 'transmetropolitan',
'contenu' => '<p>bd</p>',
'notice' => new Class_Notice(),
'type_doc_id' => Class_TypeDoc::ARTICLE]));
$this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_List/ids/2;1/modele_fusion/1",true);
/** @test */
public function articlePommeShouldBeIndexed() {
$this->assertNotNull(Class_Notice::findFirstBy(['titres' => 'POMME POM']));
}
/** @test */
public function recordPommeShouldBeLinkedToPommeArticle() {
$this->assertNotNull(Class_Notice::findFirstBy(['titres' => 'POMME POM'])->getArticle());
}
/** @test */
public function displayShouldprintContent() {
$this->assertXPathContentContains("//div//p", "bd", $this->_response->getBody());
}
public function contenuShouldContainsTransmetropolitan() {
$this->assertXPathContentContains("//div//h1[1]", "transmetropolitan", $this->_response->getBody());
}
public function pommeShouldBeDisplayedAfterTransmetropolitan() {
$this->assertXPathContentContains("//h1[2]", "pomme", $this->_response->getBody());
}
/** @test */
public function displayShouldNotPrintTagResume() {
$this->assertNotXPathContentContains("//div", '{resume}');
}
class RechercheControllerViewNoticePrintActionWithRecordsTest extends AbstractControllerTestCase {
Class_AdminVar::set("AVIS_MIN_SAISIE", 5);
Class_AdminVar::set("AVIS_MAX_SAISIE", 500);
$this->fixture('Class_ModeleFusion', ['id' => 1,
'nom' => 'article',
'contenu' => '<p><h1> {notice.titre_principal}</h1> <div>{notice.article.contenu} </div>
<div>{notice.resume} </div>
</p>',
'type' => 'Notice_View']);
Class_Indexation_PseudoNotice::index( $this->fixture('Class_Article' , ['id' => 12,
'titre' => 'transmetropolitan',
'contenu' => '<p>bd</p>',
'notice' => new Class_Notice(),
'type_doc_id' => Class_TypeDoc::ARTICLE]));
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
$avis = [
$this->fixture('Class_AvisNotice', [
'id' => 1,
'id_user' => 1,
'avis' => 'Lies are news and truth is obsolete.',
'entete' => 'quotes',
'note' => 4,
'clef_oeuvre' => 'TRANSMETROPOLITAN---',
'notice' => 1,
'date_avis' => '2012-01-01',
]),
$this->fixture('Class_AvisNotice', [
'id' => 2,
'id_user' => 1,
'avis' => "The point is, the only real tools we have are our eyes and our heads. It's not the act of seeing with our eyes alone; it's correctly comprehending what we see. Treating life as an autopsy",
'entete' => 'quotes',
'note' => 4,
'notice' => 1,
'clef_oeuvre' => 'TRANSMETROPOLITAN---',
'date_avis' => '2012-01-01',
]),
];
$this->dispatch("/recherche/print/expressionRecherche/pomme/strategy/Notice_View/id/1/modele_fusion/1",true);
/** @test */
public function displayShouldprintContent() {
$this->assertXPathContentContains("//div//p", "bd", $this->_response->getBody());
}
public function contenuShouldContainsTransmetropolitan() {
$this->assertXPathContentContains("//div//h1[1]", "transmetropolitan", $this->_response->getBody());
}
/** @test */
public function avisShouldBeDisplayed() {
$this->assertXPathContentContains('//div//p', "Lies are news and truth is obsolete.",$this->_response->getBody());
}
/** @test */
public function displayShouldNotPrintNoticeDotResume() {
$this->assertNotXPathContentContains("//div", '{notice.resume}');
}