Skip to content
Snippets Groups Projects
AbonneControllerSuggestionAchatTest.php 33.4 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
class AbonneControllerSuggestionAchatAddFormTest extends AbstractControllerTestCase {
  protected $_storm_default_to_volatile = true;
  public function setUp() {
    parent::setUp();
    Class_CosmoVar::newInstanceWithId('types_docs', ['liste' => '']);
    $this->fixture('Class_TypeDoc', ['id' => 6 ,
                                     'label' => 'Blueray',
                                     'famille_id' => Class_CodifTypeDoc::VIDEO]);
    $this->fixture('Class_Bib', ['id' => 11,
                                 'libelle' => 'Bib de la plage']);
    Class_Profil::getCurrentProfil()
      ->setCfgModules(['abonne' => ['suggestion-achat-add' => ['help-text' => 'Entrez votre suggestion']]]);
    $this->dispatch('/opac/abonne/suggestion-achat-add', true);
  }
  /** @test */
  public function pageShouldContainsDivHelpTextWithEntrezVotreSuggestion() {
    $this->assertXPathContentContains('//div[@class="help-text"]', 'Entrez votre suggestion');
  }
  /** @test */
  public function pageTitleShouldBeSuggestionAchat() {
    $this->assertXPathContentContains('//title', 'Suggérer un achat');
  }
  /** @test */
  public function boiteShouldHaveTitleSuggestionAchat() {
    $this->assertXPathContentContains('//div[@class="boiteMilieu"]//h1', 'Suggérer un achat');
  }
  /** @test */
  public function formShouldContainsInputForTitre() {
    $this->assertXPath('//form//input[@name="titre"][@placeholder="ex: Harry Potter à l\'école des sorciers"]');
  }
  /** @test */
  public function formShouldContainsSelectForDocumentType() {
    $this->assertXPath('//form//select[@name="type_doc_id"]');
  }
  /** @test */
  public function typeDocBlueRayShouldBePresent() {
    $this->assertXPath('//form//select[@name="type_doc_id"]//option[@value="6"][@label="Blueray"]');
  }
  /** @test */
  public function rssShouldNotBePresent() {
    $this->assertNotXpath('//form//select[@name="type_doc_id"]//option[@value="9"][@label="fils rss"]');
  }
  /** @test */
  public function formShouldContainsInputForAuteur() {
    $this->assertXPath('//form//input[@name="auteur"][@placeholder="ex: Joanne Kathleen Rowling"]');
  }
  /** @test */
  public function formShouldContainsInputForDescriptionUrl() {
    $this->assertXPath('//form//input[@type="url"][@name="description_url"][@placeholder="ex: http://fr.wikipedia.org/wiki/Harry_Potter_à_l\'école_des_sorciers"]');
  }
  /** @test */
  public function formShouldContainsInputForISBN() {
    $this->assertXPath('//form//input[@name="isbn"][@placeholder="ex: 2-07-054127-4"]');
  }
  /** @test */
  public function libraryShouldBeSetByDefault() {
    $this->assertXPath('//form//select[@name="bib_id"]//option[@value="11"][@selected="selected"]');
  }
  /** @test */
  public function formShouldContainsTextAreaForCommentaire() {
    $this->assertXPath('//form//textarea[@name="commentaire"]');
  }
  /** @test */
  public function formShouldContainsSubmitButtonEnvoyer() {
    $this->assertXPath('//form//input[@type="submit"][@value="Envoyer"]');
  }
class AbonneControllerSuggestionAchatAddFormMultipleBibsTest extends AbstractControllerTestCase {
  public function setUp() {
    parent::setUp();
    $this->fixture('Class_Bib', ['id' => 11,
                                 'libelle' => 'Bib de la plage']);
    $this->fixture('Class_Bib', ['id' => 12,
                                 'libelle' => 'Bib de la plage 2']);
    $user = $this->fixture('Class_Users', [
                                           'id' => 3,
                                           'login' => 'test',
                                           'password' => 'test',
                                           'id_site' => 12,
                                           ]);
    ZendAfi_Auth::getInstance()->logUser($user);
    $this->dispatch('/opac/abonne/suggestion-achat-add', true);
  }
  /** @test */
  public function formShouldContainsSelectForLibrary() {
    $this->assertXPath('//form//select[@name="bib_id"]');
  }
  /** @test */
  public function librarySelectShouldContainBibDeLaPlage() {
    $this->assertXPath('//form//select[@name="bib_id"]//option[@value="11"][@label="Bib de la plage"]/following-sibling::option[@value="12"][@label="Bib de la plage 2"]');
  }
  /** @test */
  public function noLibraryShouldHaveBeenSelectedByDefault() {
    $this->assertXPath('//form//select[@name="bib_id"]//option[1][@value="0"]');
  }
class AbonneControllerSuggestionAchatAddFormMultipleBibsAndKohaNotRestfulTest extends AbstractControllerTestCase {
  public function setUp() {
    parent::setUp();
    $sigb_plage = $this->fixture('Class_IntBib',
                                 [
                                  'id' => 3,
                                  'comm_params' => ['url_serveur' => 'http://plage.com/cgi-bin/koha/ilsdi.pl',
                                                    'restful' => '0'],
                                  'comm_sigb' => Class_IntBib::COM_KOHA
                                 ]);

    $this->fixture('Class_Bib', ['id' => 12,
                                 'libelle' => 'Bib de la plage 2',
                                 'int_bib' => $sigb_plage]);

    $user = $this->fixture('Class_Users', [
                                           'id' => 3,
                                           'login' => 'test',
                                           'password' => 'test',
                                           'id_site' => 12,
                                           'int_bib' => $sigb_plage,
                                           ]);

    ZendAfi_Auth::getInstance()->logUser($user);

    $this->dispatch('/opac/abonne/suggestion-achat-add', true);
  }
  /** @test */
  public function formShouldContainsTextAreaForCommentaire() {
    $this->assertXPath('//form//textarea[@name="commentaire"]');
  }
Loading full blame...