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 Cosmo_DataProfileControllerTestCase extends CosmoControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_IntProfilDonnees::forKoha()
->setId(56)
->setItemField(Class_IntProfilDonnees::FIELD_ITEM_ID_ORIGINE, ['zone' => '999',
'champ' => 'c'])
Class_IntProfilDonnees::forNanook()
->setId(105)
->save();
Class_IntProfilDonnees::forPergamePatrons()
->setId(106)
->save();
$this->fixture('Class_CosmoVar',
['id' => 'champs_pret',
'valeur' => null,
'liste' => "ID_PERGAME:id_pret Pergame\r\nIDABON:id abonné\r\nORDREABON:no d'ordre\r\nEN_COURS:prêt en cours\r\nDATE_PRET:date du prêt\r\nDATE_RETOUR:date de retour\r\nID_NOTICE_ORIGINE:id notice Pergame\r\nSUPPORT:code support\r\nETIQUETTE:numéro d'étiquette (incrémental)"]);
$this->fixture('Class_CosmoVar',
['id' => 'types_docs',
'valeur' => null,
'liste' => "0:non identifié\r\n1:Livres\r\n"]);
$this->fixture('Class_CosmoVar',
['id' => 'id_article_periodique',
'valeur' => null,
'liste' => "0:aucun\r\n1:pergame\r\n2:opsys indexpresse\r\n3:Koha\r\n4:Orphée"]);
public function tearDown() {
Class_IntProfilDonnees::clearCache();
Class_CosmoVar::clearCache();
Class_TypeDoc::clearCache();
Class_ScriptLoader::resetInstance();
parent::tearDown();
}
}
class Cosmo_DataProfileControllerIndexTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/data-profile', true);
}
public function addNewProfileShouldBePresent() {
$this->assertXPath('//div', 'Ajouter un profil');
}
public function secondTrShouldContainsKoha() {
$this->assertXPathContentContains('//table//tr[2]/td', 'Koha');
public function thirdTrShouldContainsRecordsFileType() {
$this->assertXPathContentContains('//table//tr[3]/td[2]', 'Notices');
/** @test */
public function thirdTrShouldContainsUnimarcFormat() {
$this->assertXPathContentContains('//table//tr[3]/td[3]', 'Unimarc');
}
/** @test */
public function thirdTrShouldContainsNonUsedFlag() {
$this->assertXPathContentContains('//table//tr[3]/td[4]', 'Non');
}
public function secondTrShouldContainsLinkEditKohaProfile() {
$this->assertXPath('//table//tr[2]/td/a[contains(@href, "/cosmo/data-profile/edit/id/56")]');
}
/** @test */
public function thirdTrShouldContainsNanook() {
$this->assertXPathContentContains('//table//tr[3]/td', 'Nanook');
}
/** @test */
public function tableSorterJsShouldBeloaded() {
$this->assertXPath('//script[contains(@src, "/public/opac/js/tablesorter/js/jquery.tablesorter.")]');
}
/** @test */
public function jQueryUIShouldBeLoaded() {
$this->assertXPath('//script[contains(@src, "/public/admin/js/jquery-ui")]');
}
/** @test */
public function jQueryShouldBeLoaded() {
$this->assertXPath('//script[contains(@src, "/public/admin/js/jquery-")]');
}
class Cosmo_DataProfileControllerEditPatronsTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
[
'id' => 57,
'libelle' => 'Some patrons',
'accents' => Class_IntProfilDonnees::ENCODING_WINDOWS_ANSI,
'rejet_periodiques' => 1,
'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_NONE,
'type_fichier' => Class_IntProfilDonnees::FT_PATRONS,
'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII,
'attributs' =>
[
[Class_IntProfilDonnees::FIELD_TYPE_DOC_RECOGNITION => [ ],
Class_IntProfilDonnees::FIELD_ITEM_BARCODE => '996',
Class_IntProfilDonnees::FIELD_ITEM_GENRE => '',
Class_IntProfilDonnees::FIELD_ITEM_SECTION => 'x',
Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT => '',
Class_IntProfilDonnees::FIELD_ITEM_ANNEXE => 'a'
],
['champs' => 'PRENOM;NOM; MAIL;PRENOM'],
['champs' => 'PRENOM;NOM; MAIL;PRENOM'],
['champs' => 'PRENOM;NOM; MAIL;PRENOM']
]
]);
$this->dispatch('cosmo/data-profile/edit/id/57', true);
/** @test */
public function subscriberSelectedFieldsShouldContainsTwoPrenom() {

Laurent
committed
$this->assertXPathCount('//div[@id="input_patron_fields"]/div[1]/ul/li[@data-value="PRENOM"]', 2);
/** @test */
public function subscriberSelectedFieldsShouldContainsMail() {
$this->assertXPath('//div[@id="input_patron_fields"]/div[1]/ul/li[@data-value="MAIL"]');
}
/** @test */
public function subscriberAvailableFieldsShouldContainsPrenom() {

Laurent
committed
$this->assertXPathCount('//div[@id="input_patron_fields"]/div[2]/ul/li[@data-value="PRENOM"]', 1, $this->_response->getBody());

Patrick Barroca
committed
/** @test */
public function subscriberAvailableFieldsShouldContainsLibraryCode() {
$this->assertXPath('//div[@id="input_patron_fields"]/div[2]/ul/li[@data-value="LIBRARY_CODE"]', $this->_response->getBody());
}
class Cosmo_DataProfileControllerEditUnimarcKohaTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('cosmo/data-profile/edit/id/56', true);
/** @test */
public function labelShouldBePresent() {
$this->assertXPath('//form//input[@type="text"][@name="libelle"][@value= "Unimarc Koha"]');
/** @test */
public function selectAccentsShouldContainsUTF8Selected() {
$this->assertXPathContentContains('//form//select[@name="accents"]/option[@value="0"][@selected]', 'UTF-8');
}
/** @test */
public function selectTypeFichierShouldContainsRecordsSelected() {
$this->assertXPathContentContains('//form//select[@name="type_fichier"]/option[@value="0"][@selected]',
'Notices');
}
/** @test */
public function selectFormatShouldContainsUnimarcSelected() {
$this->assertXPathContentContains('//form//select[@name="format"]/option[@value="0"][@selected]', 'Unimarc');
}
/** @test */
public function formatBibliondemandShouldBeAvailable() {
$this->assertXPathContentContains('//form//select[@name="format"]/option[@value="11"]', 'Dublin Core Bibliondemand');
}
/** @test */
public function fieldNouveauteJoursShouldBePresent() {
$this->assertXPath('//form//input[@id="nouveaute_jours"]');
}
/** @test */
public function multiInputNouveauteZoneChampShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_nouveaute_zone_champ"]');
}
/** @test */
public function nouveauteZoneAndChampShouldBe801AndC() {
$this->assertXPathContentContains('//script', 'values:{"nouveaute_zone":["801"],"nouveaute_champ":["c"]}');
}
/** @test */
public function selectNouveauteFormatShouldBePresent() {
$this->assertXPath('//form//select[@id="nouveaute_format"]/option[@value="' . Class_IntProfilDonnees::NOVELTY_DATE_FORMAT_AAAA_MM_JJ . '"][@selected]');
/** @test */
public function nouveauteFormatAAAAMMJJShouldExists() {
$this->assertXPathContentContains('//select[@id="nouveaute_format"]/option', 'AAAAMMJJ');
}
/** @test */
public function multiInputNouveauteValeursShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_nouveaute_valeurs"]');
}
/** @test */
public function noveltyDaysShouldBe90() {
$this->assertXPath('//form//input[@name="nouveaute_jours"][@value="90"]');
}
/** @test */
public function itemZoneValueShouldBe995() {
$this->assertXPath('//form//input[@name="item_zone"][@value="995"]');
}
/** @test */
public function itemCodebarreShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_code_barres"]/option[@value="f"][@selected]');

Patrick Barroca
committed
/** @test */
public function itemCodebarreIn949Dollar6ShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_code_barres"]/option[@value="949"][contains(@label,"949$6")]');

Patrick Barroca
committed
}
/** @test */
public function itemCoteShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_cote"]/option[@value="k"][@selected]');
}
/** @test */
public function itemTypeDocShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_type_doc"]/option[@value="r"][@selected]');
}
/** @test */
public function itemSectionShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_section"]/option[@value="q"][@selected]');
}
/** @test */
public function itemGenreShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_genre"]/option[@value=""]');
}
/** @test */
public function itemEmplacementShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_emplacement"]/option[@value="e"][@selected]');
}
/** @test */
public function itemAnnexeShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_annexe"]/option[@value="b"][@selected]');
}
/** @test */
public function itemDisponibiliteShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_availability"]/option[@value=""]');
}
/** @test */
public function multiInputItemUrlShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_item_url"]');
}
/** @test */
public function multiInputItemIdOrigineShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_item_id_origine"]');
}
/** @test */
public function scriptShouldSetMutiInputsItemIdOrigineTo999dollarC() {
$this->assertXPathContentContains('//script', 'values:{"id_origine_zone":["999"],"id_origine_champ":["c"]}');
}
/** @test */
public function multiInputInteretZoneShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_interests"]');
public function selectRejetPeriodiquesShoudHaveNoSelected() {
$this->assertXPathContentContains('//form//select[@id="rejet_periodiques"]/option[@value="0"][@selected]', 'Non');
}
/** @test */
public function selectIdArticlePeriodiqueShouldBePresent() {
$this->assertXPath('//form//select[@id="id_article_periodique"]/option[@value="' . Class_IntProfilDonnees::SERIAL_FORMAT_KOHA . '"][@selected]');
}
/** @test */
public function multiInputDocTypeZeroShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_item_doc_type_0"]');
}
/** @test */
public function multiInputDocTypeOneShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_item_doc_type_1"]');
}
/** @test */
public function docTypeBookShouldBeAmNaLivLivjLivaDocManuel() {
$this->assertXPathContentContains('//script', 'values:{"1_label":["am","na"],"1_zone":["LIV","LIVJ","LIVA","DOC","MANUEL"]}');
/** @test */
public function docTypeDiMusicShouldBeEmpty() {
$this->assertXPathContentContains('//script', 'values:{"DiMusic_label":[],"DiMusic_zone":[]}');
}
class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$post = ['libelle' => 'New Koha',
'accents' => Class_IntProfilDonnees::ENCODING_ISO2709,
'type_fichier' => Class_IntProfilDonnees::FT_RECORDS,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC,
'xml_balise_abonne' => 'subscribers',
'xml_abonne_IDABON' => 'id',
'item_zone'=> '996',
'champ_code_barres'=> 'f',
'champ_cote' => 'k',
'champ_type_doc' => 'x',
'champ_section' => 'q',
'champ_genre' => 'z',
'champ_emplacement' => 'u',
'champ_annexe' => 'a',
'champ_availability' => 't',
'url_zone' => [0 => '932'],
'url_champ' => [0 => 'n'],
'id_origine_zone' => [0 => '999'],
'id_origine_champ' => [0 => 'c'],
'rejet_periodiques' => 1,
'id_article_periodique' => 1,
'nouveaute_format' => 4,
'nouveaute_jours' => 80,
'nouveaute_zone' => [0 => '932'],
'nouveaute_champ' => [0 => 'a'],
'nouveaute_valeurs' => ['nouveau',
'new'],
'interest_zone' => [0 => '932'],
'interest_champ' => [0 => '7'],
'holds' => 'SUPPORT; SUPPORT',
'carts' => 'LIBELLE; ROLE',
'loans' => 'ID_PERGAME; ID_PERGAME',
'patron_fields' => 'ORDREABON; ORDREABON'];
$this->postDispatch('cosmo/data-profile/edit/id/56', $post, true);
$this->_koha = Class_IntProfilDonnees::find(56);
}
/** @test */
public function shouldRedirectToCosmoSlashDataProfileSlashEditSlashIdSlashOne() {
$this->assertRedirectTo('/cosmo/data-profile/edit/id/56');
}
/** @test */
public function libelleShouldBeNewKoha() {
$this->assertEquals('New Koha', $this->_koha->getLibelle());
}
/** @test */
public function accentsShouldBeISO2709() {
$this->assertEquals(Class_IntProfilDonnees::ENCODING_ISO2709, $this->_koha->getAccents());
/** @test */
public function itemZoneShouldBe996() {
$this->assertEquals('996', $this->_koha->getItemZone());
}
/** @test */
public function champsCodeBarresShouldBeF() {
$this->assertEquals('f', $this->_koha->getBarCode());
}
/** @test */
public function champsAvailabilityBeT() {
$this->assertEquals('t', $this->_koha->getAvailability());
/** @test */
public function urlLabelShouldBeIn932() {
$this->assertEquals('932', $this->_koha->getUrlLabel());
}
/** @test */
public function urlFieldShouldBeInN() {
$this->assertEquals('n', $this->_koha->getUrlField());
}
/** @test */
public function idOrigineZoneShouldBe999() {
$this->assertEquals('999', $this->_koha->getIdOrigineZone());
}
/** @test */
public function idOrigineFieldShouldBeC() {
$this->assertEquals('c', $this->_koha->getIdOrigineField());
}
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
/** @test */
public function serialsRejectShouldBeOne() {
$this->assertEquals(1, $this->_koha->getRejetPeriodiques());
}
/** @test */
public function noveltyFormatShouldBe4() {
$this->assertEquals(4, $this->_koha->getNoveltyFormat());
}
/** @test */
public function noveltyDaysShouldBe80() {
$this->assertEquals(80, $this->_koha->getNoveltyDays());
}
/** @test */
public function noveltyLabelShouldBe932() {
$this->assertEquals(932, $this->_koha->getNoveltyLabel());
}
/** @test */
public function noveltyFieldShouldBeA() {
$this->assertEquals('a', $this->_koha->getNoveltyField());
}
/** @test */
public function noveltyValeursShouldBeNouveauAndNew() {
$this->assertEquals('nouveau;new', $this->_koha->getNoveltyValues());
}
/** @test */
public function interestLabelShouldBe932() {
$this->assertEquals(932, $this->_koha->getInterestLabel());
}
/** @test */
public function interestFieldShouldBe7() {
$this->assertEquals('7', $this->_koha->getInterestField());
}
class Cosmo_DataProfileControllerPostEditFieldsTest extends Cosmo_DataProfileControllerTestCase {
protected
$_nanook_profile;
public function setUp() {
parent::setUp();
$this->_nanook_profile = Class_IntProfilDonnees::find(105);
/** @test */
public function patronsFieldsShouldContainsIdPergame() {
$this->postDispatch('cosmo/data-profile/edit/id/105',
[Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_PATRONS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_CSV,
'carts' => 'ID_ABO',
Class_IntProfilDonnees::PROFILE_PATRON_FIELDS => 'ID_PERGAME; ID_PERGAME'], true);
$this->assertEquals('ID_PERGAME; ID_PERGAME', $this->_nanook_profile->getPatronsFieldsValues());
}
/** @test */
public function loansFieldsShouldContainsIdPergame() {
$this->postDispatch('cosmo/data-profile/edit/id/105',
[Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_LOANS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_CSV,
'carts' => 'ID_ABO',
Class_IntProfilDonnees::PROFILE_LOANS_FIELDS => 'ID_PERGAME; ID_PERGAME'], true);
$this->assertEquals('ID_PERGAME; ID_PERGAME', $this->_nanook_profile->getLoansFieldsValues());
}
/** @test */
public function lightRecordsFieldsShouldContainsEan() {
$this->postDispatch('cosmo/data-profile/edit/id/105',
[Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_RECORDS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_CSV,
Class_IntProfilDonnees::PROFILE_ITEM_FIELDS => 'ean;ean'], true);
$this->assertEquals('ean;ean', $this->_nanook_profile->getCSVRecordFieldsValues());
}
/** @test */
public function holdsFieldsShouldContainsSupport() {
$this->postDispatch('cosmo/data-profile/edit/id/105',
[Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_HOLDS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_CSV,
$this->assertEquals('SUPPORT; SUPPORT', $this->_nanook_profile->getHoldsFieldsValues());
}
/** @test */
public function cartsFieldsShouldContainsLibelleAndRole() {
$this->postDispatch('cosmo/data-profile/edit/id/105',
[Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_BASKETS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_CSV,
$this->assertEquals('LIBELLE; ROLE', $this->_nanook_profile->getCartsFieldsValues());
}
/** @test */
public function docTypeFieldsShouldBeAsExpected() {
$doc_type = ['1_label' => ['am',
'af',
'bb'],
'1_zone' => ['z',
't',
'u'],
Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_RECORDS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_UNIMARC];
$this->postDispatch('cosmo/data-profile/edit/id/105', $doc_type, true);
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
$this->assertEquals(['code' => '1', 'label' => 'am;af;bb', 'zone_995' => 'z;t;u'],
$this->_nanook_profile->getItemDocTypesPrefs()[1]);
}
/** @test */
public function postXMLPatronsShouldFillXmlPatronField() {
$this->postDispatch('cosmo/data-profile/edit/id/105',
[Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_PATRONS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_XML,
'xml_balise_abonne' => 'items',
'xml_abonne_IDABON'=> 'id',
'xml_abonne_DATE_DEBUT' => 'start',
'xml_abonne_DATE_FIN' => 'end',
], true);
$this->assertEquals('items', $this->_nanook_profile->getXmlPatronField());
return $this->_nanook_profile;
}
/**
* @depends postXMLPatronsShouldFillXmlPatronField
* @test
*/
public function postXMLPatronsShouldFillXmlPatronFieldForIDABON($profile) {
$this->assertEquals($profile->getXmlPatronFieldsAt('IDABON'), 'id');
}
/**
* @depends postXMLPatronsShouldFillXmlPatronField
* @test
*/
public function postXMLPatronsShouldFillXmlPatronFieldForDATEFIN($profile) {
$this->assertEquals($profile->getXmlPatronFieldsAt('DATE_FIN'), 'end');
}
/** @test */
public function subscribersFieldsShouldContainsOrdreabon() {
$this->postDispatch('cosmo/data-profile/edit/id/105',
[Class_IntProfilDonnees::PROFILE_FILE_TYPE => Class_IntProfilDonnees::FT_PATRONS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => Class_IntProfilDonnees::FORMAT_PIPED_ASCII,
'patron_fields' => 'ORDREABON; ORDREABON'], true);
$this->assertEquals('ORDREABON; ORDREABON', $this->_nanook_profile->getPatronsFieldsValues());
class Cosmo_DataProfileControllerAddActionTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/data-profile/add', true);
}
/** @test */
public function formShouldBePresent() {
$this->assertXPath('//form');
}
/** @test */
public function authorityTypeShouldBeAvailable() {
$this->assertXPath('//form//select[@id="type_fichier"]//option[@value="' . Class_IntProfilDonnees::FT_AUTHORITY . '"]');
}
}
class Cosmo_DataProfileControllerDeleteActionTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/data-profile/delete/id/56', true);
}
/** @test */
public function shouldRedirectToCosmoSlashDataProfileSlashIndex() {
$this->assertRedirectTo('/cosmo/data-profile/index');
}
}
class Cosmo_DataProfileControllerEditPergamePatronsTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('cosmo/data-profile/edit/id/106', true);
}
/** @test */
public function inputForLibelleShouldContainsPergamePatrons() {
$this->assertXPath('//input[@name="libelle"][@value="Pergame patrons"]');
}
/** @test */
public function inputSubscribersLightShouldContainsFieldsIDABON_ORDREABON_etc() {

Laurent
committed
$this->assertXPath('//input[@name="patron_fields"][@value="IDABON;ORDREABON;NOM;PRENOM;NAISSANCE;DATE_DEBUT;DATE_FIN;MAIL"]',
$this->_response->getBody());
}
class Cosmo_DataProfileControllerEditNanookPatronsRegressionTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
[
'id' => 59,
'libelle' => 'Nanook patrons',
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'rejet_periodiques' => 1,
'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_NONE,
'type_fichier' => Class_IntProfilDonnees::FT_PATRONS,
'format' => Class_IntProfilDonnees::FORMAT_CSV,
'attributs' =>
[ 0 => [Class_IntProfilDonnees::FIELD_TYPE_DOC_RECOGNITION => [ ],
Class_IntProfilDonnees::FIELD_ITEM_BARCODE => '996',
Class_IntProfilDonnees::FIELD_ITEM_GENRE => '',
Class_IntProfilDonnees::FIELD_ITEM_SECTION => 'x',
Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT => '',
Class_IntProfilDonnees::FIELD_ITEM_ANNEXE => 'a'
],
1 => ['champs' => 'IDABON;PIKA_PIKA;ORDREABON;NOM;PRENOM;PASSWORD;MAIL'],
2 => ['champs' => 'IDABON;PIKA_PIKA;ORDREABON;NOM;PRENOM;PASSWORD;MAIL'],
3 => ['champs' => 'IDABON;PIKA_PIKA;ORDREABON;NOM;PRENOM;PASSWORD;MAIL'],
4 => ['zone' => '', 'champ' => '', 'format' => '', 'jours' => '', 'valeurs' => ''],
5 => ['xml_balise_abonne' => '',
'xml_champs_abonne' => [
'IDABON' => '',
'ORDREABON' => '',
'NOM' => '',
'PRENOM' => '',
'NAISSANCE' => '',
'PASSWORD' => '',
'MAIL' => '',
'DATE_DEBUT' => '',
'DATE_FIN' => '',
'ID_SIGB' => '']]
]]);
$this->dispatch('cosmo/data-profile/edit/id/59', true);
}
/** @test */

Laurent
committed
public function inputPatronFieldsShouldContainsIDABON_ORDREABON_etc() {
$this->assertXPath('//input[@name="patron_fields"][@value="IDABON;ORDREABON;NOM;PRENOM;PASSWORD;MAIL"]', $this->_response->getBody());
}
/** @test */

Laurent
committed
public function paragraphForPatronFieldsShouldContainsPRENOM() {
$this->assertXPath('//div[@id="input_patron_fields"]/div[1]/ul/li[@data-value="PRENOM"]',
$this->_response->getBody());
}
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
class Cosmo_DataProfileControllerDispatchPatronProfileTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('cosmo/data-profile/edit/id/106', true);
}
/** @test */
public function loanFieldIdAbonShouldBeDraggable() {
$this->assertXPathContentContains('//form//ul//li', 'id abonné', $this->_response->getBody());
}
}
class Cosmo_DataProfileControllerDispatchXMLPatronProfileTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Nanook patrons',
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'rejet_periodiques' => 1,
'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_NONE,
'type_fichier' => Class_IntProfilDonnees::FT_PATRONS,
'format' => Class_IntProfilDonnees::FORMAT_XML,
'attributs' =>
[0 => [Class_IntProfilDonnees::FIELD_TYPE_DOC_RECOGNITION => [ ]],
1 => [],
2 => [],
3 => [],
4 => [],
5 => ['xml_balise_abonne' => 'subscribers',
'xml_champs_abonne' => [
'IDABON' => 'id_abon',
'ORDREABON' => '',
'NOM' => '',
'PRENOM' => '',
'NAISSANCE' => '',
'PASSWORD' => '',
'MAIL' => '',
'DATE_DEBUT' => 'subscription_date',
'DATE_FIN' => '',
'ID_SIGB' => '']]]]);
$this->dispatch('cosmo/data-profile/edit/id/654', true);
}
/** @test */
public function inputXmlBaliseAbonneShouldBeSubscribers() {
$this->assertXPath('//form//input[@id="xml_balise_abonne"][@value="subscribers"]');
}
/** @test */
public function inputXmlBaliseIDABONShouldBePresent() {
$this->assertXPath('//form//input[@id="xml_abonne_IDABON"][@value="id_abon"]');
}
/** @test */
public function inputXmlBaliseDateDebutShouldBePresent() {
$this->assertXPath('//form//input[@id="xml_abonne_DATE_DEBUT"][@value="subscription_date"]');
}
}
class Cosmo_DataProfileControllerDispatchLoansProfileTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Nanook loans',
'type_fichier' => Class_IntProfilDonnees::FT_LOANS,
'format' => Class_IntProfilDonnees::FORMAT_CSV,
'attributs' =>
[0 => [],
1 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
2 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
3 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
4 => [],
5 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
6 => []]]);
$this->dispatch('cosmo/data-profile/edit/id/654', true);
}
/** @test */
public function fieldIdLoansShouldBeEmpty() {

Laurent
committed
$this->assertXPath('//form//input[@id="loans"][@value=""]');
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
}
}
class Cosmo_DataProfileControllerDispatchHoldsProfileTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Nanook Holds',
'type_fichier' => Class_IntProfilDonnees::FT_HOLDS,
'format' => Class_IntProfilDonnees::FORMAT_CSV,
'attributs' =>
[0 => [],
1 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
2 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
3 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
4 => [],
5 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
6 => []]]);
$this->dispatch('cosmo/data-profile/edit/id/654', true);
}
/** @test */
public function fieldIdHoldsShouldBeEmpty() {

Laurent
committed
$this->assertXPath('//form//input[@id="holds"][@value=""]');
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
}
}
class Cosmo_DataProfileControllerDispatchBasketsProfileTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Nanook baskets',
'type_fichier' => Class_IntProfilDonnees::FT_BASKETS,
'format' => Class_IntProfilDonnees::FORMAT_CSV,
'attributs' =>
[0 => [],
1 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
2 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
3 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
4 => [],
5 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
6 => []]]);
$this->dispatch('cosmo/data-profile/edit/id/654', true);
}
/** @test */
public function fieldIdCartShouldBeEmpty() {

Laurent
committed
$this->assertXPath('//form//input[@id="carts"][@value=""]');
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
}
}
class Cosmo_DataProfileControllerDispatchCSVItemsProfileTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Nanook loans',
'type_fichier' => Class_IntProfilDonnees::FT_RECORDS,
'format' => Class_IntProfilDonnees::FORMAT_CSV,
'attributs' =>
[0 => [],
1 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
2 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
3 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
4 => [],
5 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
6 => []]]);
$this->dispatch('cosmo/data-profile/edit/id/654', true);
}
/** @test */

Laurent
committed
public function inputCsvItemFieldsShouldBeEmpty() {
$this->assertXPath('//form//input[@name="csv_item_fields"][@value=""]',
$this->_response->getBody());
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
}
class Cosmo_DataProfileControllerAutoFormatTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Nanook loans',
'type_fichier' => Class_IntProfilDonnees::FT_LOANS,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC,
'attributs' =>
[0 => [],
1 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
2 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
3 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
4 => [],
5 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
6 => []]]);
$this->dispatch('cosmo/data-profile/edit/id/654', true);
}
/** @test */
public function formatShouldBeSetToCSV() {
$this->assertXPath('//form//select[@id="format"]/option[@value="5"][@selected]', $this->_response->getBody());
}
/** @test */
public function formatShouldHaveBeenUpdatedToCSV() {
$this->assertEquals(Class_IntProfilDonnees::FORMAT_CSV, Class_IntProfilDonnees::find(654)->getFormat());
}
}
class Cosmo_DataProfileControllerAutoFormatPostTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Nanook loans',
'type_fichier' => Class_IntProfilDonnees::FT_RECORDS,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC,
'attributs' =>
[0 => [],
1 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
2 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
3 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
4 => [],
5 => ['champs' => 'PRENOM; NAISSANCE; PRENOM'],
6 => []]]);
$this->postDispatch('cosmo/data-profile/edit/id/654',
['type_fichier' => Class_IntProfilDonnees::FT_LOANS,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC],
true);
}
/** @test */
public function formatShouldHaveBeenUpdatedToCSV() {
$this->assertEquals(Class_IntProfilDonnees::FORMAT_CSV, Class_IntProfilDonnees::find(654)->getFormat());
}
class Cosmo_DataProfileControllerMultiValuesTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$type_doc = [['code' => '0', 'label' => '', 'zone_995' => 'IND' ],
['code' => '1', 'label' => 'am;;bm;;em;mm;;;;;;;;', 'zone_995' => 'BDA;;BDJ;LFA;LFJ;LDA;LDJ;LCDA;LCDJ;PATIMP;PATMS;PERIP;PATINC;' ],
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
['code' => '2', 'label' => 'as', 'zone_995' => 'REV;REVA;REVJ;'],
['code' => '3', 'label' => 'i;j', 'zone_995' => 'CD'],
['code' => '4', 'label' => 'g', 'zone_995' => 'DVD;JDVD;DVDA;DVDJ;VID'],
['code' => '5', 'label' => 'l;m', 'zone_995' => 'CDROM;CDR'],
['code' => '6', 'label' => '', 'zone_995' => 'LCD' ],
['code' => '7', 'label' => '', 'zone_995' => 'PAR;JPAR;' ],
['code' => '8', 'label' => '', 'zone_995' => ''],
['code' => '9', 'label' => '', 'zone_995' => ''],
['code' => '10', 'label' => ' ', 'zone_995' => ''],
['code' => '11', 'label' => '', 'zone_995' => 'JVID'],
['code' => '12', 'label' => '', 'zone_995' => 'MAT'],
['code' => '13', 'label' => 'km', 'zone_995' => 'EST'],
['code' => '14', 'label' => '', 'zone_995' => 'TLU'],
['code' => '15', 'label' => '', 'zone_995' => 'CAR'],
['code' => '16', 'label' => '', 'zone_995' => 'DIS']];
$this->fixture('Class_IntProfilDonnees',
['id' => 321,
'libelle' => 'Records',
'type_fichier' => Class_IntProfilDonnees::FT_RECORDS,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC,
'attributs' => [
0 => [Class_IntProfilDonnees::PROFILE_DOC_TYPES => $type_doc,
Class_IntProfilDonnees::FIELD_ITEM_BARCODE => 'f',
Class_IntProfilDonnees::FIELD_ITEM_COTE => 'k',
Class_IntProfilDonnees::FIELD_ITEM_TYPE_DOC => 'r',
Class_IntProfilDonnees::FIELD_ITEM_GENRE => '',
Class_IntProfilDonnees::FIELD_ITEM_SECTION => 'q',
Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT => 'e',
Class_IntProfilDonnees::FIELD_ITEM_ANNEXE => 'b',
Class_IntProfilDonnees::FIELD_ITEM_URL => ['zone' => '995',
'champ' => 'i']],
1 => ['zone' => '801',
'champ' => 'c',
'format' => Class_IntProfilDonnees::NOVELTY_DATE_FORMAT_AAAA_MM_JJ,
'jours' => '90',
'valeurs' => 'nouveau;new'],
2 => [],
3 => [],
4 => [],
5 => [],
6 => ['zone' => '995',
'champ' => 'z']
]]);
$this->dispatch('cosmo/data-profile/edit/id/321', true);
}
/** @test */
public function nouveauteValeursShouldBeNouveauAndNew() {
$this->assertXPathContentContains('//script', 'values:{"nouveaute_valeurs":["nouveau","new"]}');
}
/** @test */
public function interestShouldBeTakeIn995AndZ() {
$this->assertXPathContentContains('//script', 'values:{"interest_zone":["995"],"interest_champ":["z"]}');
}
/** @test */
public function itemUrlShouldBe995AndI() {
$this->assertXPathContentContains('//script', 'values:{"url_zone":["995"],"url_champ":["i"]}');
}
/** @test */
public function scriptShouldSetMutiInputsItemIdOrigineTo001() {
$this->assertXPathContentContains('//script', 'values:{"id_origine_zone":["001"],"id_origine_champ":[null]}');
}
/** @test */
public function docTypeWithLabelSkipsShouldHaveAllItsValues() {
$this->assertXPathContentContains('//script', 'values:{"1_label":["am","bm","","em","mm","","","","","","",""],"1_zone":["BDA","BDJ","LFA","LFJ","LDA","LDJ","LCDA","LCDJ","PATIMP","PATMS","PERIP","PATINC"]}',
$this->_response->getBody());
}
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
}
abstract class Cosmo_DataProfileControllerAuthorityTestCase
extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$attributs = [[Class_IntProfilDonnees::PROFILE_INDEX_SYSTEMS_FIELDS
=> [['rule' => 'ISO',
'system' => 'rameau',
'default_type' => 'a',
'thesaurus' => '3']]]];
$this->fixture('Class_IntProfilDonnees',
['id' => 654,
'libelle' => 'Authorities',
'type_fichier' => Class_IntProfilDonnees::FT_AUTHORITY,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC,
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'attributs' => serialize($attributs)]);
$this->fixture('Class_CodifThesaurus',
['id' => 5,
'libelle' => 'Mots-clés TESS',
'rule_zone' => '609',
'rule_label_field' => 'a',
'rule_id_field' => '9',
'id_thesaurus' => 'MOTS']);
}
}
class Cosmo_DataProfileControllerAuthorityEditTest
extends Cosmo_DataProfileControllerAuthorityTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('cosmo/data-profile/edit/id/654', true);
}
/** @test */
public function fieldsetIndexationShouldBePresent() {
$this->assertXPathContentContains('//fieldset//legend', 'Indexation');
}
/** @test */
public function indexSystemsMultiInputRootShouldBePresent() {
$this->assertXPath('//div[@id="multi_inputs_index_systems"]');
}
/** @test */
public function indexSystemsMultiInputShouldBeInitialized() {
$this->assertXPathContentContains('//script', '$("#multi_inputs_index_systems").multi_inputs(');
}
/** @test */
public function multiInputRuleShouldBePresent() {
$this->assertXPathContentContains('//script', '"name":"index_system_rule"');
}
/** @test */
public function ruleValueShouldBePresent() {
$this->assertXPathContentContains('//script', '"index_system_rule":["ISO"]');
}
/** @test */
public function multiInputSystemLabelShouldBePresent() {
$this->assertXPathContentContains('//script', '"name":"index_system_label"');
}
/** @test */
public function systemLabelValueShouldBePresent() {
$this->assertXPathContentContains('//script', '"index_system_label":["rameau"]');
}
/** @test */
public function multiInputDefaultTypeShouldBePresent() {
$this->assertXPathContentContains('//script', '"name":"index_system_default_type"');
}
/** @test */
public function defaultTypeValueShouldBePresent() {
$this->assertXPathContentContains('//script', '"index_system_default_type":["a"]');
}
/** @test */
public function multiInputThesaurusIdShouldBePresent() {
$this->assertXPathContentContains('//script', '"name":"index_system_thesaurus"');
}
/** @test */
public function systemThesaurusValueShouldBePresent() {
$this->assertXPathContentContains('//script', '"index_system_thesaurus":["3"]');
}
/** @test */
public function multiInputShouldContainsTESSThesaurusOption() {
$this->assertXPathContentContains('//script', '"5":"Mots-cl\\u00e9s TESS (609$9)"');
}
}
class Cosmo_DataProfileControllerAuthorityEditPostTest
extends Cosmo_DataProfileControllerAuthorityTestCase {
protected $_prefs;
public function setUp() {
parent::setUp();
$this->postDispatch('cosmo/data-profile/edit/id/654',
['libelle' => 'Authorities',
'type_fichier' => Class_IntProfilDonnees::FT_AUTHORITY,
'format' => Class_IntProfilDonnees::FORMAT_UNIMARC,
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'index_system_rule' => ['AFNOR'],
'index_system_label' => ['TESS'],
'index_system_default_type' => ['j'],
'index_system_thesaurus' => ['5']]);
Class_IntProfilDonnees::clearCache();
$this->_prefs = Class_IntProfilDonnees::find(654)->getIndexSystemsPrefs()[0];
}
/** @test */
public function ruleShouldBeAFNOR() {
$this->assertEquals('AFNOR', $this->_prefs['rule']);
}
/** @test */
public function systemShouldBeTESS() {
$this->assertEquals('TESS', $this->_prefs['system']);
}
/** @test */
public function defaultTypeShouldBeJ() {
$this->assertEquals('j', $this->_prefs['default_type']);
}
/** @test */
public function thesaurusShouldBe5() {
$this->assertEquals('5', $this->_prefs['thesaurus']);
}