Commit b6d91308 authored by Patrick Barroca's avatar Patrick Barroca 😠
Browse files

Merge branch 'dev#104950_gpesrecherche_users_ajout_critere_age' into 'master'

ccdev #104950 add age criteria on search group

See merge request !3406
parents d09d74c6 72199392
Pipeline #9455 passed with stage
in 43 minutes and 11 seconds
- ticket #104950 : Groupes recherche d'utilisateurs : ajout du critère âge
\ No newline at end of file
<?php
(new Class_Migration_BirthdateFormatChanges())->run();
\ No newline at end of file
......@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'classe_abonne.php';
require_once 'ModelTestCase.php';
......@@ -35,10 +34,24 @@ abstract class AbonneIntegrationTestCase extends ModelTestCase {
['id' => 2,
'id_bib' => 2]);
$this->abon_config = new abonne();
$this->abon_config->setIdIntBib(2);
$this->abon_config = new Class_Cosmogramme_Integration_Record_Patron($this->getIntegration());
}
public function getIntegration() {
$this->fixture('Class_IntProfilDonnees',
['id' => 101,
'libelle' => 'Nanook Abonne',
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'type_fichier' => Class_IntProfilDonnees::FT_PATRONS,
'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII,
'attributs' => []
]);
$integration = new Class_Cosmogramme_Integration();
$integration->setBib(Class_IntBib::find(2));
$integration->setProfilDonnees(Class_IntProfilDonnees::find(101));
return $integration;
}
public function tearDown() {
Storm_Model_Loader::defaultToDb();
......@@ -56,14 +69,6 @@ abstract class AbonneIntegrationASCIITestCase extends AbonneIntegrationTestCase
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users')
->whenCalled('save')
->answers(true);
$this->abon_config->setChamps(['IDABON',
'ID_SIGB',
'NOM',
'PRENOM',
'PASSWORD',
'MAIL']);
}
}
......@@ -74,41 +79,15 @@ abstract class AbonneIntegrationXMLTestCase extends AbonneIntegrationTestCase {
public function setup(){
parent::setup();
$this->abon_config->setChamps(['IDABON'=>'LECTNUM',
'ID_SIGB'=>'LECTNUM',
'NOM' => 'LASTNAME',
'PRENOM' => 'FIRSTNAME',
'PASSWORD'=> 'MOT_DE_PASSE',
'MAIL'=> 'EMAIL',
'NAISSANCE'=>'DATEBIRTH']);
}
}
class AbonneIntegrationASCIIWithNoUsersInDbTest extends AbonneIntegrationASCIITestCase {
public function setup(){
parent::setup();
$champs_sigb = ['12 3 4','12','2','Tom','paul','ici','tp@afi-sa.fr'];
$champs_sigb_ascii = implode(chr(9), $champs_sigb);
$this->abon_config->importFicheAscii($champs_sigb_ascii);
$this->user_tom = Class_Users::getFirstAttributeForLastCallOn('save');
}
/** @test **/
public function abonneSigbTomIdShouldBe1234() {
$this->assertEquals('12 3 4', $this->user_tom->getIdabon());
}
}
class AbonneIntegrationPipedASCIITest extends AbonneIntegrationASCIITestCase {
protected $integration;
public function setup() {
parent::setup();
$this->fixture('Class_CodifAnnexe',
......@@ -117,209 +96,57 @@ class AbonneIntegrationPipedASCIITest extends AbonneIntegrationASCIITestCase {
'code' => 'CHAMWOIS',
'id_bib' => 42]);
$this->abon_config->setChamps(['IDABON',
'NUM_CARTE',
'NOM',
'PRENOM',
'NAISSANCE',
'DATE_DEBUT',
'DATE_FIN',
'MAIL',
'PASSWORD',
'LIBRARY_CODE']);
$this->abon_config->importFicheAscii(str_replace('|', chr(9), 'francoise.charbonnier|test|CHARBONNIER|Francoise|2013-01-04|2013-01-04|2015-04-29|sophie.meynieux@biblibre.com|test|CHAMOIS'));
$this->user = Class_Users::getFirstAttributeForLastCallOn('save');
}
/** @test */
public function idAbonShouldBeTest() {
$this->assertEquals("test", $this->user->getIdabon());
}
/** @test */
public function idIntBibShouldBe2() {
$this->assertEquals(2, $this->user->getIdIntBib());
}
/** @test */
public function idSiteShouldBe44() {
$this->assertEquals(42, $this->user->getIdSite());
}
$data = explode('|','francoise.charbonnier|test|CHARBONNIER|Francoise|2013-01-04|2013-01-04|2015-04-29|sophie.meynieux@biblibre.com|test|CHAMOIS');
(new Class_Cosmogramme_Integration_PhasePatrons(7,'',''))->importPatronRecord($data, $this->getIntegration());
/** @test */
public function unknownLibraryCodeShouldSetIdSiteTo2() {
$this->abon_config->importFicheAscii(str_replace('|', chr(9), 'francoise.charbonnier|test|CHARBONNIER|Francoise|2013-01-04|2013-01-04|2015-04-29|sophie.meynieux@biblibre.com|test|CHAT'));
$user = Class_Users::getFirstAttributeForLastCallOn('save');
$this->assertEquals(2, $user->getIdSite());
}
}
class AbonneIntegrationTabbedASCIIWithNoUsersInDbTest extends AbonneIntegrationASCIITestCase {
public function setup(){
parent::setup();
$this->abon_config->setChamps(['NULL',
'IDABON',
'NOM',
'PRENOM',
'NAISSANCE',
'DATE_FIN',
'NUM_CARTE',
'PASSWORD',
'NULL',
'NULL',
'NULL',
'NULL',
'NULL',
'NULL',
'NULL',
'NULL',
'NULL',
'MAIL']);
$this->abon_config->importFicheAscii('A 50 ANIMATION JEUNESSE 24/11/2013 50 jsecret8 5 14 10 1');
$this->user = Class_Users::getFirstAttributeForLastCallOn('save');
}
/** @test **/
public function abonneSigbMailShouldNotBeNull() {
$this->assertNotNull($this->user->getMail());
}
/** @test **/
public function idAbonShouldNotBe50() {
$this->assertEquals(50, $this->user->getIdabon());
}
public function getIntegration() {
$integration = parent::getIntegration();
$champs = "IDABON;NUM_CARTE;NOM;PRENOM;NAISSANCE;DATE_DEBUT;DATE_FIN;MAIL;PASSWORD;LIBRARY_CODE";
$integration->getProfilDonnees()->setAttributs([1 => ['champs' => $champs]] );
/** @test */
public function nomShouldBeAnimationJeunesse() {
$this->assertEquals('ANIMATION JEUNESSE', $this->user->getNom());
return $integration;
}
/** @test */
public function prenomShouldBeEmptyString() {
$this->assertSame('', $this->user->getPrenom());
}
/** @test */
public function naissanceShouldBeEmptyString() {
$this->assertSame('', $this->user->getNaissance());
}
/** @test */
public function dateFinShouldBe2013_11_24() {
$this->assertEquals('2013-11-24', $this->user->getDateFin());
}
/** @test */
public function loginShould50() {
$this->assertEquals('50', $this->user->getLogin());
public function idAbonShouldBeTest() {
$this->assertEquals("test", $this->user->getIdabon());
}
/** @test */
public function passwordShouldBejsecret8() {
$this->assertEquals('jsecret8', $this->user->getPassword());
}
}
class AbonneIntegrationASCIIWithRoutoInDbTest extends AbonneIntegrationTestCase {
protected $user_routo;
protected $routo_after_import;
public function setup(){
parent::setup();
$this->abon_config->setChamps(['IDABON',
'ID_SIGB',
'NOM',
'PRENOM',
'PASSWORD',
'MAIL']);
$this->user_routo = $this->fixture('Class_Users',
['id' => 5,
'nom'=>'Routo',
'prenom'=>'Pierre',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'idabon' => '123456',
'login'=>'5 5',
'id_site' => 2,
'id_int_bib' => 2,
'pseudo' => 'riri',
'password'=>'old']);
$champs_sigb_ascii = implode(chr(9), ['5 5',
'12',
'Routo',
'Pierre',
'la',
'"rp@afi-sa.fr "']);
$this->abon_config->importFicheAscii($champs_sigb_ascii);
$this->users = Class_Users::findAllBy(['login' => '5 5']);
public function idIntBibShouldBe2() {
$this->assertEquals(2, $this->user->getIdIntBib());
}
/** @test */
public function shouldNotBeSingleNanookPatron() {
$this->assertFalse(Class_IntBib::isSingleNanookPatrons());
public function idSiteShouldBe42() {
$this->assertEquals(42, $this->user->getIdSite());
}
/** @test */
public function onlyOneUserShouldHaveLogin55() {
$this->assertEquals(1, count($this->users));
}
/** @test */
public function mailShouldBeCleaned() {
$this->assertEquals('rp@afi-sa.fr',$this->users[0]->getMail());
}
/** @test **/
public function withRoutoInDbImportShouldUpdateRoutoWithIdabon55() {
$this->assertEquals('5 5',$this->users[0]->getIdabon());
}
public function unknownLibraryCodeShouldSetIdSiteTo2() {
$data = explode('|','francoise.charbonnier|test|CHARBONNIER|Francoise|2013-01-04|2013-01-04|2015-04-29|sophie.meynieux@biblibre.com|test|CHAT');
(new Class_Cosmogramme_Integration_PhasePatrons(7,'',''))->importPatronRecord($data, $this->getIntegration());
/** @test **/
public function pseudoShouldBeRiri() {
$this->assertEquals('riri',$this->users[0]->getPseudo());
$user = Class_Users::getFirstAttributeForLastCallOn('save');
$this->assertEquals(2, $user->getIdSite());
}
}
class AbonneIntegrationASCIIWithTwoUsersSameLoginDifferentPasswordAndOrdreAbonTest extends AbonneIntegrationTestCase {
public function setup(){
parent::setup();
$this->abon_config->setChamps(['IDABON',
'ORDREABON',
'NOM',
'PRENOM',
'NAISSANCE',
'DATE_DEBUT',
'DATE_FIN',
'MAIL']);
$this->fixture('Class_Users', ['id' => '4',
'login' => 'jsmith',
......@@ -330,18 +157,25 @@ class AbonneIntegrationASCIIWithTwoUsersSameLoginDifferentPasswordAndOrdreAbonTe
}
/** @test */
public function userWithOrdreAbon2ShouldBeCreated() {
$champs_sigb_ascii = implode(chr(9), ['jsmith',
'2',
'john',
'smith',
'1977-06-25',
'2012-03-25',
'2016-03-25',
'js@afi-sa.fr']);
public function getIntegration() {
$integration = parent::getIntegration();
$champs = "IDABON;ORDREABON;NOM;PRENOM;NAISSANCE;DATE_DEBUT;DATE_FIN;MAIL";
$integration->getProfilDonnees()->setAttributs([1 => ['champs' => $champs]] );
$integration->setBib(Class_IntBib::find(2));
return $integration;
}
$this->abon_config->importFicheAscii($champs_sigb_ascii);
/** @test
public function userWithOrdreAbon2ShouldBeCreated() {
$champs_sigb_ascii = ['jsmith',
'2',
'john',
'smith',
'1977-06-25',
'2012-03-25',
'2016-03-25',
'js@afi-sa.fr'];
(new Class_Cosmogramme_Integration_PhasePatrons(7,'',''))->importPatronRecord($champs_sigb_ascii, $this->getIntegration());
$jsmith2 = Class_Users::findFirstBy(['login' => 'jsmith',
'ordreabon' => 2]);
......@@ -354,16 +188,15 @@ class AbonneIntegrationASCIIWithTwoUsersSameLoginDifferentPasswordAndOrdreAbonTe
/** @test */
public function userWithOrdreAbon1ShouldBeUpdated() {
$champs_sigb_ascii = implode(chr(9), ['jsmith',
'1',
'john',
'smith',
'1977-06-25',
'2012-03-25',
'2016-03-25',
'js@afi-sa.fr']);
$this->abon_config->importFicheAscii($champs_sigb_ascii);
$champs_sigb_ascii = ['jsmith',
'1',
'john',
'smith',
'1977-06-25',
'2012-03-25',
'2016-03-25',
'js@afi-sa.fr'];
(new Class_Cosmogramme_Integration_PhasePatrons(7,'',''))->importPatronRecord($champs_sigb_ascii, $this->getIntegration());
$users = Class_Users::findAllBy(['login' => 'jsmith']);
$this->assertEquals(1, count($users));
......@@ -374,96 +207,29 @@ class AbonneIntegrationASCIIWithTwoUsersSameLoginDifferentPasswordAndOrdreAbonTe
class AbonneIntegrationXMLWithNoUsersInDbTest extends AbonneIntegrationXMLTestCase {
class AbonneIntegrationASCIIWithIDSigbAndLoginChangeTest extends AbonneIntegrationTestCase {
public function setup(){
parent::setup();
$this->fixture('Class_Users', ['id' => '4',
'login' => 'jsmith',
'password' => '1234',
'ordreabon' => 1,
'id_site' => 2,
'id_int_bib' => 2,
'id_sigb' => 24]);
$this->abon_config->importFicheArray(['IDABON' => 'johnny',
'ID_SIGB' => 24]);
$this->johny = Class_Users::findFirstBy(['id_sigb' => 24]);
}
/** @test */
public function loginShouldBeJohny() {
$this->assertEquals('johnny', $this->johny->getLogin());
}
/** @test */
public function onlyOneUserShouldHaveIDSigb24() {
$this->assertEquals(1, count(Class_Users::findAllBy(['id_sigb' => 24])));
}
}
class AbonneIntegrationASCIIWithIDSigbInDataAndNotInBaseTest extends AbonneIntegrationTestCase {
public function setup(){
parent::setup();
$this->fixture('Class_Users', ['id' => '4',
'login' => 'jsmith',
'password' => '1234',
'id_site' => 2,
'id_int_bib' => 2,
'id_sigb' => 0]);
$this->abon_config->importFicheArray(['IDABON' => 'jsmith',
'NOM' => 'johnny',
'ID_SIGB' => 24,
'MAIL' => ' " jsmith!@nomail.org "']);
$this->johny = Class_Users::findFirstBy(['id_sigb' => 24]);
}
$champs_sigb_xml = '<Item><TYPE_ABONNE>I</TYPE_ABONNE><LECTNUM>00003090</LECTNUM><LASTNAME>Pirly</LASTNAME><FIRSTNAME>Coco</FIRSTNAME><FULLNAME>Pirly, Coco</FULLNAME><DATEBIRTH>12/31/1982</DATEBIRTH><MOT_DE_PASSE>zoom</MOT_DE_PASSE></Item>';
/** @test */
public function loginShouldBeJohny() {
$this->assertEquals('jsmith', $this->johny->getLogin());
}
$fields = ['IDABON'=>'LECTNUM',
'ID_SIGB'=>'LECTNUM',
'NOM' => 'LASTNAME',
'PRENOM' => 'FIRSTNAME',
'PASSWORD'=> 'MOT_DE_PASSE',
'MAIL'=> 'EMAIL',
'NAISSANCE'=>'DATEBIRTH'];
/** @test */
public function onlyOneUserShouldHaveIDSigb24() {
$this->assertEquals(1, count(Class_Users::findAllBy(['id_sigb' => 24])));
}
/** @test */
public function userWithIdFourShouldBeJohnny() {
$this->assertEquals('johnny', Class_Users::find(4)->getNom());
}
$this->abon_config->import($champs_sigb_xml, $fields, 1);
$this->user_tom = Class_Users::findFirstBy(['nom'=> 'Pirly']);
/** @test */
public function mailJohnnyShouldBeCleaned() {
$this->assertEquals('jsmith@nomail.org',$this->johny->getMail());
}
}
class AbonneIntegrationXMLWithNoUsersInDbTest extends AbonneIntegrationXMLTestCase {
public function setup(){
parent::setup();
$champs_sigb_xml = '<Item><TYPE_ABONNE>I</TYPE_ABONNE><LECTNUM>00003090</LECTNUM><LASTNAME>Pirly</LASTNAME><FIRSTNAME>Coco</FIRSTNAME><FULLNAME>Pirly, Coco</FULLNAME><DATEBIRTH>12/31/1982</DATEBIRTH><MOT_DE_PASSE>zoom</MOT_DE_PASSE></Item>';
$this->abon_config->importFicheXml($champs_sigb_xml);
$this->user_tom = Class_Users::findFirstBy(['nom'=> 'Pirly']);
}
/** @test **/
public function abonneSigbTomIdShouldBe1234() {
$this->assertEquals('00003090', $this->user_tom->getIdabon());
......@@ -489,8 +255,16 @@ class AbonneIntegrationXMLWithRoutoInDbTest extends AbonneIntegrationXMLTestCase
$champs_sigb_xml = '<Item><TYPE_ABONNE>I</TYPE_ABONNE><LECTNUM>0100 3080</LECTNUM><LASTNAME>poirreau</LASTNAME><FIRSTNAME>Zozio</FIRSTNAME><FULLNAME>Piou Piou</FULLNAME><DATEBIRTH>12/31/2012</DATEBIRTH><MOT_DE_PASSE>poum</MOT_DE_PASSE><EMAIL>" ##zozio@nomail.org "</EMAIL></Item>';
$fields = ['IDABON'=>'LECTNUM',
'ID_SIGB'=>'LECTNUM',
'NOM' => 'LASTNAME',
'PRENOM' => 'FIRSTNAME',
'PASSWORD'=> 'MOT_DE_PASSE',
'MAIL'=> 'EMAIL',
'NAISSANCE'=>'DATEBIRTH'];
$this->abon_config->importFicheXml($champs_sigb_xml);
$this->abon_config->import($champs_sigb_xml, $fields, 1);
$this->zozio_after_import = Class_Users::findFirstby(['login'=>'0100 3080',
'id_site' => 2]);
......
......@@ -423,7 +423,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'CUSTOM_FIELDS_REPORT' => Class_AdminVar_Meta::newOnOff($this->_('Activation des rapports statistiques sur les champs personnalisés')),
'WEBSERVICE_TEST' => Class_AdminVar_Meta::newOnOff($this->_('Activation des tests de webservices')),
'IMPORT_AVIS_OPAC2' => Class_AdminVar_Meta::newOnOff($this->_('Activation de l\'import des avis de l\'opac2')),
'AGENDA_KEEP_LOCAL_CONTENT' => Class_AdminVar_Meta::newOnOff($this->_('Agenda externe : conserver les évenements modifiés localement'))
'AGENDA_KEEP_LOCAL_CONTENT' => Class_AdminVar_Meta::newOnOff($this->_('Agenda externe : conserver les évenements modifiés localement')),
'ENABLED_SEARCH_USER_AGE' => Class_AdminVar_Meta::newOnOff($this->_('Recherche utilisateur : ajouter le filtre d\'age')),
];
}
......
......@@ -88,6 +88,11 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract {
}
public function isFormatXml() {
return $this->getProfilDonnees()->getFormat() == Class_IntProfilDonnees::FORMAT_XML;
}
public function isBibliondemand() {
return $this->getProfilDonnees()->isBibliondemand();
}
......@@ -164,4 +169,5 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract {
$this->getTypeDoc(),
$this->getNomFichier()];
}
}
\ No newline at end of file
......@@ -86,8 +86,10 @@ class Class_Cosmogramme_Integration_PhaseAuthority
/** return true if given profil parameters are correct for this phase */
protected function _validateProfil($profil) {
return $profil->isAuthorityRecords();
protected function _validateProfil($integration) {
return ($profil = $integration->getProfilDonnees())
? $profil->isAuthorityRecords()
: false;
}
......
......@@ -59,8 +59,10 @@ class Class_Cosmogramme_Integration_PhaseDeleteItem extends Class_Cosmogramme_In
protected function _shouldIgnoreLine($line, $integration){}
/** return true if given profil parameters are correct for this phase */
protected function _validateProfil($profil){
return $profil->isBiblioRecords();
protected function _validateProfil($integration){
return ($profil = $integration->getProfilDonnees())
? $profil->isBiblioRecords()
: false;
}
/** hooked called after the file has been fully processed */
......
......@@ -98,8 +98,10 @@ class Class_Cosmogramme_Integration_PhaseNotice
protected function _shouldIgnoreLine($line, $integration) {}
/** return true if given profil parameters are correct for this phase */
protected function _validateProfil($profil) {
return $profil->isBiblioRecords();
protected function _validateProfil($integration) {
return ($profil = $integration->getProfilDonnees())
? $profil->isBiblioRecords()
: false;
}
......
......@@ -45,7 +45,7 @@ abstract class Class_Cosmogramme_Integration_PhaseOnDataSource extends Class_Cos
protected function _runOne($integration) {
if (!($profil = $integration->getProfilDonnees()) || !$this->_validateProfil($profil))