diff --git a/application/modules/admin/controllers/ModoController.php b/application/modules/admin/controllers/ModoController.php index fde99b0cfe654b52b6a8dff6313e63846548cb60..57e57b1f79f0648ff7cd6b5bd88012744ddd581d 100644 --- a/application/modules/admin/controllers/ModoController.php +++ b/application/modules/admin/controllers/ModoController.php @@ -293,7 +293,23 @@ class Admin_ModoController extends ZendAfi_Controller_Action { public function membreviewAction() { $this->view->titre = $this->_('Demandes d\'inscription'); - $this->view->registrations = Class_UsersNonValid::findAll(); + $this->view->registrations = Class_UsersNonValid::findAllByLoggedUser(); + } + + + public function rejectRegistrationAction() { + $registration = Class_UsersNonValid::find($this->_getParam('id')); + + if ($registration->hasUser()){ + $registration->getUser()->delete(); + $this->_helper->notify($this->_('Le compte "%s" a été supprimé', + $registration->getLogin())); + } + $registration->delete(); + + $this->_helper->notify($this->_('La demande d\'inscription pour "%s" a été supprimée', + $registration->getLogin())); + $this->_redirect('admin/modo/membreview'); } diff --git a/application/modules/admin/views/scripts/modo/index.phtml b/application/modules/admin/views/scripts/modo/index.phtml index 2c22e86ea2ba73a81be236dc70a1d78eaefc0d29..6f638794f0675ee807ce4fdf9e1aadd80c2937bd 100644 --- a/application/modules/admin/views/scripts/modo/index.phtml +++ b/application/modules/admin/views/scripts/modo/index.phtml @@ -3,28 +3,32 @@ $moderer = new Class_Moderer(); $modstats = $moderer->getModerationStats(); $menus = [["icon" => "articles", - "label" => "Articles", + "label" => $this->_('Articles'), + 'title' => $this->_('Avis sur des articles à modérer'), "url" => $this->url(['module' => 'admin', 'controller' => 'modo', 'action' => 'aviscms'], null, true), "count" => $modstats['avis_articles']['count']], ["icon" => "books", - "label" => "Notices", + "label" => $this->_('Notices'), + 'title' => $this->_('Avis sur des notices à modérer'), "url" =>$this->url(['module' => 'admin', 'controller' => 'modo', 'action' => 'avisnotice'], null, true), "count" => $modstats['avis_notices']['count']], ["icon" => "tag", - "label" => "Tags notices", + "label" => $this->_('Tags notices'), + 'title' => $this->_('Tags sur des notices à modérer'), "url" => $this->url(['module' => 'admin', 'controller' => 'modo', 'action' => 'tagnotice'], null, true), "count" => $modstats['tags_notices']['count']], ["icon" => "suggestion", - "label" => "Suggestions d'achat", + "label" => $this->_('Suggestions d\'achat'), + "title" => $this->_('Suggestions d\'achat à modérer'), "url" => $this->url(['module' => 'admin', 'controller' => 'modo', 'action' => 'suggestion-achat'], null, true), "count" => $modstats['suggestions_achat']['count']] - ]; if (isset($modstats['formulaires'])) { $menus[] = ["icon" => "formulaires_16.png", - "label" => "Formulaires", + "label" => $this->_('Formulaires'), + 'title' => $this->_('Réponses aux formulaires dans les articles'), "url" => $this->url(['action' => 'formulaires', 'id_article' => null, 'status' => null, 'active_tab' => null, 'page' => null]), "count" => $modstats['formulaires']['count']] ;} diff --git a/application/modules/admin/views/scripts/modo/membreview.phtml b/application/modules/admin/views/scripts/modo/membreview.phtml index b73cb6d8a10881713fb6985e83914efa2a78860b..f0edec8ea37f8fcf85e27e6599daf490a2bb768e 100644 --- a/application/modules/admin/views/scripts/modo/membreview.phtml +++ b/application/modules/admin/views/scripts/modo/membreview.phtml @@ -7,22 +7,45 @@ if(empty($this->registrations)) { $description = (new Class_TableDescription('registration')) ->addColumn($this->_('Identifiant'), 'login') ->addColumn($this->_('Email'), function($registration) {return $registration->getMail();}) + ->addColumn($this->_('Bibliothèque'), function($registration) {return $registration->getBibLibelle();}) ->addColumn($this->_('Date'), function($registration) {return $registration->getDate();}) ->addColumn($this->_('Expirée'), function($registration) {return $registration->isExpired() ? $this->_('Oui') : $this->_('Non');}) - ->addRowAction(function($model) - { - return $this->renderModelActions($model, - [['url' => ['action' => 'validate-registration', - 'id' => $model->getId()], - 'icon' => 'validate', - 'label' => $this->_('Valider la demande d\'inscription de "%s"', $model->getLogin())], - ['url' => ['action' => 'delete-registration', - 'id' => $model->getId()], - 'icon' => 'delete', - 'label' => $this->_('Supprimer la demande d\'inscription de "%s"', $model->getLogin()), - 'anchorOptions' => ['onclick' => sprintf('return confirm(\'%s\')', - $this->_('Etes-vous sûr de vouloir supprimer cette demande ?'))]]]); -}); + ->addRowAction( + function($model) + { + return $this->renderModelActions($model, + [['url' => ['action' => 'reject-registration', + 'id' => $model->getId()], + 'icon' => 'delete', + 'label' => $this->_('Rejeter la demande d\'inscription de "%s"', $model->getLogin()), + 'anchorOptions' => ['onclick' => sprintf('return confirm(\'%s\')', + $this->_('Etes-vous sûr de vouloir rejeter cette inscription ?')) ]], + + + ['url' => ['action' => 'validate-registration', + 'id' => $model->getId()], + 'icon' => 'add_user', + 'condition' => function($model) {return !$model->hasUser();}, + 'label' => $this->_('Valider la demande d\'inscription de "%s"', $model->getLogin())], + + + ['url' => ['controller' => 'users', + 'action' => 'edit', + 'id' => $model->getBibUserId()], + 'icon' => 'user', + 'condition' => 'hasUser', + 'label' => $this->_('Visualiser les informations du compte "%s"', $model->getLogin())], + + + ['url' => ['action' => 'delete-registration', + 'id' => $model->getId()], + 'icon' => 'validate', + 'condition' => 'hasUser', + 'label' => $this->_('Confirmer l\'inscription de "%s"', $model->getLogin())], + + + ]); + }); echo $this->renderTable($description, $this->registrations); diff --git a/cosmogramme/sql/patch/patch_367.php b/cosmogramme/sql/patch/patch_367.php new file mode 100644 index 0000000000000000000000000000000000000000..9841a0f26ca2f1703e64fa8a78755bab96c12052 --- /dev/null +++ b/cosmogramme/sql/patch/patch_367.php @@ -0,0 +1,13 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); +try { + $adapter + ->query('alter table bib_admin_users_non_valid add column bib_user_id int(11)'); +} catch(Exception $e) {} + + + +try { + $adapter + ->query('alter table bib_admin_users_non_valid add index id_site (id_site)'); +} catch(Exception $e) {} diff --git a/library/Class/Moderer.php b/library/Class/Moderer.php index 9e1a7cf5dc7ea6e6e2eb6d9e998b9f81913762c3..e96cdb39bcbfb16e04546a5f8478e593ce0bb08c 100644 --- a/library/Class/Moderer.php +++ b/library/Class/Moderer.php @@ -96,7 +96,7 @@ class Class_Moderer { 'demandes_inscription' => ['label' => $this->_('Demandes d\'inscription'), 'url' => BASE_URL . '/admin/modo/membreview', - 'count' => Class_UsersNonValid::count()], + 'count' => Class_UsersNonValid::countByLoggedUser()], 'suggestions_achat' => ['label' => $this->_('Suggestions d\'achat'), 'url' => BASE_URL . '/admin/modo/suggestion-achat', diff --git a/library/Class/Users.php b/library/Class/Users.php index 5c917a7adea4143d91341b66749c80a8b0589684..0769db3dece8fce47d94dd16b5934a5341b85e68 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -363,6 +363,7 @@ class Class_Users extends Storm_Model_Abstract { CIVILITE_MONSIEUR = 2, STATUT_TO_BE_DELETED = 1; + protected $_fiche_sigb, $_loans, diff --git a/library/Class/UsersNonValid.php b/library/Class/UsersNonValid.php index 1f3f267c2f1ed8d58390a3198c0fbb111e245a8b..a3ebd40ee509d04c29a2df8cf5ded3ba9909c51a 100644 --- a/library/Class/UsersNonValid.php +++ b/library/Class/UsersNonValid.php @@ -57,22 +57,53 @@ class UsersNonValidLoader extends Storm_Model_Loader { } return implode($pass); } + + + public function findAllByLoggedUser() { + return ($user = Class_Users::getIdentity()) + ? Class_UsersNonValid::findAllBy($this->_filterBySiteOf($user)) + : []; + } + + + public function countByLoggedUser() { + return ($user = Class_Users::getIdentity()) + ? Class_UsersNonValid::countBy($this->_filterBySiteOf($user)) + : 0; + } + + + protected function _filterBySiteOf($user) { + return $user->isAdminBib() + ? ['id_site' => $user->getIdSite()] + : []; + } } + + class Class_UsersNonValid extends Storm_Model_Abstract { protected $_table_name = 'bib_admin_users_non_valid', $_table_primary = 'ID_USER', $_loader_class = 'UsersNonValidLoader', $_user, - $_default_attribute_values = ['id_site' => 0, + $_default_attribute_values = ['id_site' => null, 'mail' => '', 'login' => '', 'date' => '', 'idabon' => '', 'lastname' => '', - 'firstname' => '']; + 'firstname' => '', + 'bib_user_id' => null ], + $_belongs_to = [ + 'user' => ['model' => 'Class_Users', + 'referenced_in' => 'bib_user_id'], + 'bib'=> [ 'model' => 'Class_Bib', + 'referenced_in' => 'id_site'] + ]; + public function activate() { $user = new Class_Users(); @@ -87,8 +118,11 @@ class Class_UsersNonValid extends Storm_Model_Abstract { ->save()) return false; + $this + ->setUser($user) + ->save(); + $this->_user = $user; - $this->delete(); return true; } @@ -98,6 +132,13 @@ class Class_UsersNonValid extends Storm_Model_Abstract { } + public function getBibLibelle() { + return $this->hasBib() + ? $this->getBib()->getLibelle() + : ''; + } + + public function isExpired() { if(!$limit_day = Class_AdminVar::get('MAX_DAY_INVALID_MEMBRE')) $limit_day = 30; diff --git a/library/ZendAfi/View/Helper/Admin/Nav.php b/library/ZendAfi/View/Helper/Admin/Nav.php index 9c3763a5014acef0e50492ef58c902479e6bc09a..d1eb5defd361bbafe2fdab61ccf9b17afdf879ae 100644 --- a/library/ZendAfi/View/Helper/Admin/Nav.php +++ b/library/ZendAfi/View/Helper/Admin/Nav.php @@ -30,6 +30,7 @@ class ZendAfi_View_Helper_Admin_Nav extends ZendAfi_View_Helper_BaseHelper { $redmine = Class_AdminVar::isRedmineEnabled() ? ['icon' => 'redmine', 'label' => $this->_('Assistance'), + 'title' => $this->_('Voir et créer des demandes de support'), 'count' => Class_WebService_Redmine_Workflow::current()->getNumberOfIssuesNotification(), 'url' => $this->view->url(['module' => 'admin', 'controller' => 'redmine', @@ -41,16 +42,19 @@ class ZendAfi_View_Helper_Admin_Nav extends ZendAfi_View_Helper_BaseHelper { $menus = [ ['icon' => 'home', 'label' => $this->_('Accueil'), + 'title' => $this->_('Aller à l\'accueil de l\'administration du portail'), 'url' => $this->view->url(['module' => 'admin', 'controller' => 'index', 'action' => 'index'], null, true)], ['icon' => 'back_to_front', 'label' => $this->_('Retour au site'), + 'title' => $this->_('Retourner sur la partie publique du portail'), 'url' => $this->view->url(['id_profil' => Class_Profil::getCurrentProfil()->getId()], null, true)], ['icon' => 'identity', 'label' => $identity->getLogin() . ' (' . $identity->getLibelleRole() . ')', + 'title' => $this->_('Modifier votre compte'), 'url' => $this->view->url(['module' => 'admin', 'controller' => 'users', 'action' => 'edit', @@ -60,13 +64,15 @@ class ZendAfi_View_Helper_Admin_Nav extends ZendAfi_View_Helper_BaseHelper { ['icon' => '', 'label' => $this->_('Fonctionnalités'), + 'title' => $this->_('Découvrez les fonctionnalités de Bokeh'), 'count' => $feature->countNewFor($identity), 'url' => $this->view->url(['module' => 'admin', 'controller' => 'feature', 'action' => 'index'], null, true)], ['icon' => 'logout', - 'label' => $this->translate()->_('Se déconnecter'), + 'label' => $this->_('Se déconnecter'), + 'title' => $this->_('Fermer la session pour le compte "%s"', $identity->getNomAff()), 'url' => $this->view->url(['module' => 'admin', 'controller' => 'auth', 'action' => 'logout'], null, true)]]; @@ -90,7 +96,7 @@ class ZendAfi_View_Helper_Admin_Nav extends ZendAfi_View_Helper_BaseHelper { $this->getImgUrl($entry['icon'], $entry['label']) . $entry['label'] . $this->getCountInfo($entry), - array_filter(['title' => $entry['label'], + array_filter(['title' => $entry['title'], 'data-count' => isset($entry['count']) ? $entry['count'] : null, 'class' => $this->getSelectedClass($entry['url'])]))); diff --git a/public/admin/skins/bokeh72/config.json b/public/admin/skins/bokeh72/config.json index 25a85907f00c4c50128e625a01093bbc70a384af..27476d09ee8a1c69d8a45ef8a8554f68b3e1b772 100644 --- a/public/admin/skins/bokeh72/config.json +++ b/public/admin/skins/bokeh72/config.json @@ -107,6 +107,7 @@ "groups": "../../images/picto/groupes_16.png", "groups_star": "../../images/ico/groupe_dynamique.png", "users": "../../images/picto/abonnes.gif", + "user": "../../images/picto/utilisateurs_16.png", "up": "../../images/ico/up.gif", "down": "../../images/ico/down.gif", diff --git a/public/admin/skins/bokeh74/config.json b/public/admin/skins/bokeh74/config.json index b6c7d0ed01d2d82ff7744426d3df1a5bfa156031..3a0dffd51496a4d980412293693e860347466f5f 100644 --- a/public/admin/skins/bokeh74/config.json +++ b/public/admin/skins/bokeh74/config.json @@ -111,7 +111,7 @@ "groups": "icons/actions/groupe_24.png", "groups_star": "icons/actions/groupe_dynamique_16.png", "users": "icons/actions/groupe_16.png", - + "user": "icons/actions/user_16.png", "up": "icons/actions/up_16.png", "down": "icons/actions/down_16.png", diff --git a/public/admin/skins/bokeh74/icons/actions/user_16.png b/public/admin/skins/bokeh74/icons/actions/user_16.png new file mode 100644 index 0000000000000000000000000000000000000000..dadd84147b7467ef3328a5dac558b73d3343c522 Binary files /dev/null and b/public/admin/skins/bokeh74/icons/actions/user_16.png differ diff --git a/public/admin/skins/retro/config.json b/public/admin/skins/retro/config.json index ed13884c614a995af8d5697d90742808d20cf9fa..d3a4ea1c3e01d008b87d04617a6c3f2f804973dd 100644 --- a/public/admin/skins/retro/config.json +++ b/public/admin/skins/retro/config.json @@ -111,6 +111,7 @@ "groups": "icons/actions/groupe_24.png", "groups_star": "icons/actions/groupe_dynamique_16.png", "users": "icons/actions/groupe_16.png", + "user": "icons/actions/user_16.png", "up": "icons/actions/up_16.png", "down": "icons/actions/down_16.png", diff --git a/public/admin/skins/retro/icons/actions/user_16.png b/public/admin/skins/retro/icons/actions/user_16.png new file mode 100644 index 0000000000000000000000000000000000000000..dadd84147b7467ef3328a5dac558b73d3343c522 Binary files /dev/null and b/public/admin/skins/retro/icons/actions/user_16.png differ diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index c8c90b3017645b7fd4b93777f29102c7ce65c1ba..11b01d8b418116eb71ded3bde1490c91a9fea1d8 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -365,7 +365,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe if(!empty($links)) $this->fail(sprintf("\n %s \n\nFailed asserting no anchors without title:\n%s", $message, - implode('\n* \n', $links))); + '* ' . implode("\n* ", $links))); return $this; } diff --git a/tests/application/modules/admin/controllers/ModoControllerTest.php b/tests/application/modules/admin/controllers/ModoControllerTest.php index 66aac78b3b91ab7a12bf6b95e646b55ec184bff6..0603db5cee8e33b65b54d91538184ad6eb20bcd7 100644 --- a/tests/application/modules/admin/controllers/ModoControllerTest.php +++ b/tests/application/modules/admin/controllers/ModoControllerTest.php @@ -882,7 +882,7 @@ class ModoControllerArchivedReviewsActionTest extends ModoControllerIndexActionT -class ModoControllerMembreviewDispatchTest extends Admin_AbstractControllerTestCase { +abstract class ModoControllerRegistrationsTestCase extends Admin_AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -895,6 +895,60 @@ class ModoControllerMembreviewDispatchTest extends Admin_AbstractControllerTestC 'date' => '2018-16-01', 'mail' => 'pwd@afi-sa.fr']); + $this->fixture('Class_UsersNonValid', + ['id' => 2, + 'login' => 'chewe', + 'password' => 'ehhhhhh', + 'id_site'=> 3, + 'date' => '2019-16-01', + 'mail' => 'chewe@afi-sa.fr'])->activate(); + + $this->fixture('Class_Bib', + ['id' => 3, + 'libelle' => 'Tatoine']); + } +} + + + + +class ModoControllerMembreviewAsAdminTatoineTest extends ModoControllerRegistrationsTestCase { + public function setUp() { + parent::setUp(); + Class_Users::getIdentity() + ->beAdminBib() + ->setPassword('secret') + ->setBib(Class_Bib::find(3)) + ->assertSave(); + + $this->dispatch('/admin/modo/membreview', true); + } + + + /** @test */ + public function pageShouldNotContainsRegistrationPwd() { + $this->assertNotXPathContentContains('//td', 'pwd'); + } + + + /** @test */ + public function pageShouldContainsRegistrationChewe() { + $this->assertXPathContentContains('//td', 'chewe'); + } + + + /** @test */ + public function leftMenuRegistrationCountShouldBeOne() { + $this->assertXPath('//ul[@class="menuAdmin"]//a[contains(@href, "/modo/membreview")][following-sibling::span[@class="menu_info"][text()="1"]]'); + } +} + + + + +class ModoControllerMembreviewDispatchTest extends ModoControllerRegistrationsTestCase { + public function setUp() { + parent::setUp(); $this->dispatch('/admin/modo/membreview', true); } @@ -906,33 +960,113 @@ class ModoControllerMembreviewDispatchTest extends Admin_AbstractControllerTestC /** @test */ - public function deleteRegisterRequestShouldBeDisplay() { - $this->assertXPath('//a[contains(@href, "admin/modo/delete-registration/id/1")]'); + public function libraryNameShouldBeDisplay() { + $this->assertXPathContentContains('//td', 'Tatoine'); } /** @test */ - public function validateRegisterRequestShouldBeDisplay() { - $this->assertXPath('//a[contains(@href, "/admin/modo/validate-registration/id/1")]'); + public function pageShouldContainsRejectRegistrationLinkForPwd() { + $this->assertXPath('//a[contains(@href, "admin/modo/reject-registration/id/1")]'); } -} + /** @test */ + public function pageShouldContainsRejectRegistrationLinkForChewee() { + $this->assertXPath('//a[contains(@href, "admin/modo/reject-registration/id/2")]'); + } + + + /** @test */ + public function pageShouldNotContainsDeleteRegistrationLinkForPwd() { + $this->assertNotXPath('//a[contains(@href, "admin/modo/delete-registration/id/1")]'); + } + + + /** @test */ + public function pageShouldContainsDeleteRegistrationLinkForChewee() { + $this->assertXPath('//a[contains(@href, "admin/modo/reject-registration/id/2")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToValidateRegistrationForInexistingUserPwd() { + $this->assertXPath('//tbody/tr[1]//a[contains(@href, "admin/modo/validate-registration/id/")]'); + } + + + /** @test */ + public function pageShouldNotContainsLinkToValidateRegistrationForUserChewe() { + $this->assertNotXPath('//tbody/tr[2]//a[contains(@href, "admin/modo/validate-registration/id/")]'); + } + + + /** @test */ + public function pageShouldNotContainsLinkToEditInexistingUserPwd() { + $this->assertNotXPath('//tbody/tr[1]//a[contains(@href, "admin/users/edit/id/")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToEditUserChewe() { + $this->assertXPath(sprintf('//a[contains(@href, "admin/users/edit/id/%d")]', + Class_UsersNonValid::find(2)->getUser()->getId())); + } + + + /** @test */ + public function pageShouldBeHTML5Valid() { + $this->assertHTML5(); + } +} + -class ModoControllerDeleteRegistrationTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; +class ModoControllerMembreViewRejectCheweeRegistrationTest extends ModoControllerRegistrationsTestCase { public function setUp() { parent::setUp(); - $this->fixture('Class_UsersNonValid', - ['id' => 1, - 'login' => 'pwd', - 'password' => 'pwd', - 'date' => '2018-16-01', - 'mail' => 'pwd@afi-sa.fr']); + $this->dispatch('/admin/modo/reject-registration/id/2', true); + } + + + /** @test */ + public function cheweeRegistrationShouldHaveBeenDeleted() { + $this->assertNull(Class_UsersNonValid::find(2)); + } - $this->dispatch('/admin/modo/delete-registration/id/1', true); + + /** @test */ + public function userCheweeShouldHaveBeenDeleted() { + $this->assertNull(Class_Users::findFirstBy(['login' => 'chewe'])); + } + + + /** @test */ + public function responseShouldRedirectToModoMembreView() { + $this->assertRedirectTo('/admin/modo/membreview'); + } + + + /** @test */ + public function responseShouldNotifyRegistrationHasBeenDeleted() { + $this->assertFlashMessengerContentContains('La demande d\'inscription pour "chewe" a été supprimée'); + } + + + /** @test */ + public function responseShouldNotifyCheweeHasBeenDeleted() { + $this->assertFlashMessengerContentContains('Le compte "chewe" a été supprimé'); + } +} + + + + +class ModoControllerMembreViewRejectPwdRegistrationTest extends ModoControllerRegistrationsTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/modo/reject-registration/id/1', true); } @@ -942,6 +1076,34 @@ class ModoControllerDeleteRegistrationTest extends Admin_AbstractControllerTestC } + /** @test */ + public function responseShouldNotifyRegistrationHasBeenDeleted() { + $this->assertFlashMessengerContentContains('La demande d\'inscription pour "pwd" a été supprimée'); + } +} + + + + +class ModoControllerDeleteRegistrationTest extends ModoControllerRegistrationsTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/modo/delete-registration/id/2', true); + } + + + /** @test */ + public function registrationCheweShouldHaveBeenDeleted() { + $this->assertNull(Class_UsersNonValid::find(2)); + } + + + /** @test */ + public function userCheweShouldNotHaveBeenDeleted() { + $this->assertNotNull(Class_Users::findFirstBy(['login' => 'chewe'])); + } + + /** @test */ public function shouldRedirect() { $this->assertRedirect(); @@ -969,20 +1131,25 @@ class ModoControllerValidateRegistrationTest extends Admin_AbstractControllerTes /** @test */ - public function registrationPwdShouldHaveBeenDeleted() { - $this->assertNull(Class_UsersNonValid::find(1)); + public function shouldRedirect() { + $this->assertRedirect(); } /** @test */ - public function shouldRedirect() { - $this->assertRedirect(); + public function registrationShouldHaveAUser() { + $registration = Class_UsersNonValid::find(1); + $this->assertNotNull($registration->hasUser()); + return $registration->getUser(); } - /** @test */ - public function userPwdShouldHaveBeenCreated() { - $this->assertNotNull(Class_Users::findFirstBy(['login' => 'pwd'])); + /** + * @test + * @depends registrationShouldHaveAUser + */ + public function createdUserLoginShouldBePwd($user) { + $this->assertEquals('pwd', $user->getLogin()); } } diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index f8ca49851ae129384b511cb62f9161c42eb9ca66..e8e88a808ed98e132d8e0d0db8e08120b7dc690d 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -76,7 +76,7 @@ class AuthControllerInviteLoggedTest extends PortailWithOneLoginModuleTestCase { /** @test */ public function linkSeDeconnecterShouldBePresent() { $this->assertXPath('//div[@id="boite_login"]//a[contains(@href, "auth/logout")]'); - } + } /** @test */ @@ -356,6 +356,8 @@ class AuthControllerNobodyLoggedActivateSuccessTest extends AuthControllerNobody 'mail' => 'harlock@afi-sa.fr', 'password' => 'cosmos']); $this->dispatch('/opac/auth/activeuser/c/777', true); + Class_UsersNonValid::clearCache(); + Class_Users::clearCache(); } @@ -373,8 +375,15 @@ class AuthControllerNobodyLoggedActivateSuccessTest extends AuthControllerNobody /** @test */ - public function registerRequestShouldHaveBeenDeleted() { - $this->assertEquals(0, Class_UsersNonValid::countBy([])); + public function registerRequestShouldNotHaveBeenDeleted() { + $this->assertEquals(1, Class_UsersNonValid::countBy([])); + } + + + /** @test */ + public function usersNonValidEntryShouldBeLinkedToCreatedUser() { + $this->assertEquals('harlock', + Class_UsersNonValid::find(12)->getUser()->getLogin()); } } diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index 4eb5ae89b45542799e95045101302cadc1579ed2..5b79da63bbfca7756eb8df20e993ba5819f012f0 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -2505,3 +2505,26 @@ class UpgradeDB_366_Test extends UpgradeDBTestCase { $this->assertIndex('codif_auteur', 'wikidata_id'); } } + + + + +class UpgradeDB_367_Test extends UpgradeDBTestCase { + public function prepare() { + $this + ->silentQuery('ALTER TABLE bib_admin_users_non_valid DROP COLUMN bib_user_id') + ->silentQuery('ALTER TABLE bib_admin_users_non_valid DROP KEY id_site'); + } + + + /** @test */ + public function tableBibAdminUsersNonValidShouldContainsColumnBibUserId() { + $this->assertFieldType('bib_admin_users_non_valid', 'bib_user_id', 'int(11)'); + } + + + /** @test */ + public function idSiteShouldBeIndexed() { + $this->assertIndex('bib_admin_users_non_valid', 'id_site'); + } +}