Skip to content
Snippets Groups Projects
RechercheControllerTest.php 33.2 KiB
Newer Older
class RechercheControllerWithPanierTest extends AbstractControllerTestCase {
	public function setUp() {
		parent::setUp();
		$this->panier_bd = Class_PanierNotice::newInstanceWithId(2,
																														 ['id_panier' => 1,
																															'libelle' => 'Mes BD',
																															'date_maj' => '10/02/2011',
																															'notices' => 'COMBAT ORDINAIRE;BLACKSAD']);
		$this->dispatch('/recherche/simple/id_panier/2/retour_panier/2', true);
	}

	/** @test */
	public function retourRechercheInitialeShouldLinkToPanierAbonne() {
		$this->assertXPath('//a[contains(@href, "/panier/index/id_panier/2")]');
	}
class RechercheControllerActionSimpleWithResetTest extends AbstractControllerTestCase {
	/** @test */
	public function responseShouldDisplayActionSaisie() {
		$this->dispatch('/recherche/simple/statut/reset', true);
		$this->assertXPath('//input[@name="expressionRecherche"]');
	}
}




efalcy's avatar
efalcy committed
class RechercheControllerGuideeThesaurusTest extends  RechercheControllerGuideeHomePageTest{
	public function setUp() {
		parent::setUp();

		$this->mock_sql = Storm_Test_ObjectWrapper::mock();
efalcy's avatar
efalcy committed
		$this->mock_thesaurus = Storm_Test_ObjectWrapper::mock();
		$this->mock_thesaurus ->whenCalled('findByIdOrigineAndCode')
													->answers([Class_CodifThesaurus::newInstanceWithId(59, ['libelle' => 'Generalites'])]);

		Zend_Registry::set('sql', $this->mock_sql);
		$this->mock_sql
		  ->whenCalled('fetchAll')
			->with('select * from codif_dewey where LENGTH(id_dewey)=1 order by id_dewey')
			->answers([ ['id_dewey'=>66,
					 'libelle' => 'Generalites',
								'nb_notices'=>1],
									['id_dewey'=>77,
									 'libelle' => 'Arts',
									'nb_notices' => 0]]
									)->beStrict();

		$this->mock_sql
			->whenCalled('fetchOne')
			->with('select libelle from codif_thesaurus where id_thesaurus=\'59\'')
efalcy's avatar
efalcy committed
			->answers( 'Generalites')
			->whenCalled('fetchOne')
			->with("Select count(*) from notices Where MATCH(facettes) AGAINST('+H59*' IN BOOLEAN MODE)")
			->answers('10');

		$this->dispatch('/recherche/simple/rubrique/H59', true);
	}


	/** @test */
	public function generaliteThesaurusShouldBeDisplayed() {
		$this->assertXPathContentContains("//a[contains(@href,'recherche/simple/rubrique/H59')]", 
																			'Generalites',
																			$this->_response->getBody());