-
Patrick Barroca authoredc17ae678
DataProfileControllerTest.php 38.47 KiB
<?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)
->save();
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' => 'champs_abonne',
'valeur' => null,
'liste' => "IDABON:id abonné (n° de carte)\r\nORDREABON:n° d'ordre dans la famille\r\nNOM:nom\r\nPRENOM:prénom\r\nNAISSANCE:date de naissance\r\nPASSWORD:mot de passe\r\nMAIL:adresse e-mail\r\nDATE_DEBUT:date début abonnement\r\nDATE_FIN:date fin abonnement\r\nNULL:ignorer ce champ"]);
$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"]);
$this->fixture('Class_CosmoVar',
['id' => 'champ_code_barres',
'valeur' => null,
'liste' => "f:995$f\r\nh:995$h\r\nb:995$b\r\n997:997$a\r\n852:852$g\r\na:995$a\r\n999:999$i\r\n996:996$f\r\n949:949$6"]);
$this->fixture('Class_CosmoVar',
['id' => 'champ_cote',
'valeur' => null,
'liste' => "k:995$k\r\nf:995$f"]);
}
}
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');
}
/** @test */
public function secondTrShouldContainsKoha() {
$this->assertXPathContentContains('//table//tr[2]/td', 'Koha');
}
/** @test */
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');
}
/** @test */
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/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;PRENOM'],
['champs' => 'PRENOM;NOM;PRENOM'],
['champs' => 'PRENOM;NOM;PRENOM']
]
]);
$this->dispatch('cosmo/data-profile/edit/id/57', true);
}
/** @test */
public function subscriberSelectedFieldsShouldContainsTwoPrenom() {
$this->assertXPathCount('//div[@id="input_patron_fields"]/div[1]/ul/li[@data-value="PRENOM"]', 2,
$this->_response->getBody());
}
/** @test */
public function subscriberAvailableFieldsShouldContainsPrenom() {
$this->assertXPathCount('//div[@id="input_patron_fields"]/div[2]/ul/li[@data-value="PRENOM"]', 1);
}
}
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 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 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 itemCodebarreShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_code_barres"]/option[@value="f"][@selected]');
}
/** @test */
public function itemCodebarreIn949Dollar6ShouldBePresent() {
$this->assertXPath('//form//select[@id="champ_code_barres"]/option[@value="949"][@label="949$6"]');
}
/** @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 multiInputInteretZoneShouldBePresent() {
$this->assertXPath('//form//div[@id="multi_inputs_interests"]');
}
/** @test */
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 docTypeOneDToucheShouldBeEmpty() {
$this->assertXPathContentContains('//script', 'values:{"114_label":[],"114_zone":[]}');
}
}
class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo_DataProfileControllerTestCase {
protected $_koha;
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',
'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'],
'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',
'csv_item_fields' => 'ean;ean',
'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 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 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,
'holds' => 'SUPPORT; SUPPORT'], true);
$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,
'carts' => 'LIBELLE; ROLE'], true);
$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);
$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');
}
}
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() {
$this->assertXPath('//input[@name="patron_fields"][@value="IDABON;ORDREABON;NOM;PRENOM;NAISSANCE;DATE_DEBUT;DATE_FIN;MAIL"]');
}
}
class Cosmo_DataProfileControllerEditNanookPatronsRegressionTest extends Cosmo_DataProfileControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_CosmoVar',
['id' => 'champs_abonne',
'valeur' => null,
'liste' => " IDABON:id abonné (n° de carte)\r\n ORDREABON:n° d'ordre dans la famille\r\n NOM:nom\r\n PRENOM:prénom\r\n NAISSANCE:date de naissance\r\n PASSWORD:mot de passe\r\n MAIL:adresse e-mail\r\n DATE_DEBUT:date début abonnement\r\n DATE_FIN:date fin abonnement\r\n NULL:ignorer ce champ"]);
$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;ID_SIGB;ORDREABON;NOM;PRENOM;PASSWORD;MAIL'],
2 => ['champs' => 'IDABON;ID_SIGB;ORDREABON;NOM;PRENOM;PASSWORD;MAIL'],
3 => ['champs' => 'IDABON;ID_SIGB;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 */
public function inputPatronFieldsShouldContainsIDABON_ID_SIGB_etc() {
$this->assertXPath('//input[@name="patron_fields"][@value="IDABON;ID_SIGB;ORDREABON;NOM;PRENOM;PASSWORD;MAIL"]', $this->_response->getBody());
}
/** @test */
public function paragraphForPatronFieldsShouldContainsDateDeNaissance() {
$this->assertXPath('//div[@id="input_patron_fields"]/div[1]/ul/li[@data-value="PRENOM"]',
$this->_response->getBody());
}
}
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() {
$this->assertXPath('//form//input[@id="loans"][@value="PRENOM; NAISSANCE; PRENOM"]');
}
}
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() {
$this->assertXPath('//form//input[@id="holds"][@value="PRENOM; NAISSANCE; PRENOM"]');
}
}
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() {
$this->assertXPath('//form//input[@id="carts"][@value="PRENOM; NAISSANCE; PRENOM"]');
}
}
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 */
public function fieldIdLightRecordsShouldBeEmpty() {
$this->assertXPath('//form//input[@id="csv_item_fields"][@value="PRENOM; NAISSANCE; PRENOM"]');
}
}
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;' ],
['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 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());
}
}