diff --git a/VERSIONS_HOTLINE/218050 b/VERSIONS_HOTLINE/218050 new file mode 100644 index 0000000000000000000000000000000000000000..8bfb6245cf5b5a65117d29533e1753e211728bb6 --- /dev/null +++ b/VERSIONS_HOTLINE/218050 @@ -0,0 +1 @@ + - correctif #218050 : Activités : Ne pas afficher de message d'eereur si on ne renseigne pas un champ non obligatoire. \ No newline at end of file diff --git a/library/Class/SessionActivityInscription.php b/library/Class/SessionActivityInscription.php index d58729de0c6841d8aee3acc8b9dcafeb12b152d3..925be0065eb6f303771a3dd8c71d9b076ff9f560 100644 --- a/library/Class/SessionActivityInscription.php +++ b/library/Class/SessionActivityInscription.php @@ -86,7 +86,7 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract if (0 === $max_adulte) $this->checkAttribute('adults', 0 === $this->getAdults(), - $this->_('Vous ne pouvez pas inscrire d\'adultes pour cette activitée')); + $this->_('Vous ne pouvez pas inscrire d\'adultes pour cette activité')); return $this; } @@ -105,7 +105,7 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract if (0 === $max_children) $this->checkAttribute('children', 0 === $this->getChildren(), - $this->_('Vous ne pouvez pas inscrire d\'enfants pour cette activitée')); + $this->_('Vous ne pouvez pas inscrire d\'enfants pour cette activité')); return $this; } @@ -816,6 +816,18 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract } + public function setChildren($number) + { + return parent::setChildren((int) $number); + } + + + public function setAdults($number) + { + return parent::setAdults((int) $number); + } + + public function isEditable() { return Class_AdminVar::isActivitySessionQuotasEnabled() && ($session = $this->getSessionActivity()) diff --git a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerNoAdulteTest.php b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerNoAdulteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2f59ae65f60dadd8d30f57145c1f73b97d082a5d --- /dev/null +++ b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerNoAdulteTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Copyright (c) 2012-2024, 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 + */ + + +class SessionActivityInscriptionControllerNoAdulteTest + extends Admin_AbstractControllerTestCase +{ + public function setUp(): void + { + parent::setUp(); + + Class_AdminVar::set('ACTIVITY_SESSION_QUOTAS', 1); + + $group = $this->fixture(Class_UserGroup::class, + ['id' => 12, + 'libelle' => 'Le groupe des activités', + 'rights' => [Class_UserGroup::RIGHT_SUIVRE_ACTIVITY]]); + + $this->fixture(Class_Users::class, + ['id' => 10, + 'nom' => 'Pistache', + 'prenom' => 'Amandine', + 'login' => 'Amd', + 'password' => 'fx9k', + 'mail' => 'pist@che.io', + 'user_groups' => [$group]]); + + $learn_haskell = $this->fixture(Class_Activity::class, + ['id' => 30, + 'libelle' => 'Learn Haskell', + 'description' => 'Learn useless things']); + + $this->fixture(Class_SessionActivity::class, + ['id' => 32, + 'activity' => $learn_haskell, + 'date_debut' => '2025-02-10', + 'date_fin' => '2025-03-29', + 'effectif_min' => 0, + 'effectif_max' => 0, + 'effectif_child_min' => 1, + 'effectif_child_max' => 5, + 'age_child_max' => 5, + 'effectif_inscription_max' => 0, + 'effectif_inscription_child_max' => 5, + 'duree'=> 8, + 'contenu' => 'Intro à la syntaxe', + 'horaires' => '9h - 12h, 13h - 18h', + 'date_limite_inscription'=>'2025-01-31']); + + $this->postDispatch('/admin/session-activity-inscription/subscribe/id/32/stagiaire_id/10', + ['adults' => '0', + 'children' => '2']); + + } + + /** @test */ + public function withQuotasAsStringSubscriptionShouldBeCreated() + { + $this + ->assertNotNull(Class_SessionActivityInscription::findFirstBy(['stagiaire_id' => 10, + 'session_activity_id' => 32])); + + } +} diff --git a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerNoChildrenTest.php b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerNoChildrenTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8f75630c0ed38e41451e548d3f4c0de0e2154905 --- /dev/null +++ b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerNoChildrenTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Copyright (c) 2012-2024, 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 + */ + + +class SessionActivityInscriptionControllerNoChildrenTest + extends Admin_AbstractControllerTestCase +{ + public function setUp(): void + { + parent::setUp(); + + Class_AdminVar::set('ACTIVITY_SESSION_QUOTAS', 1); + + $group = $this->fixture(Class_UserGroup::class, + ['id' => 12, + 'libelle' => 'Le groupe des activités', + 'rights' => [Class_UserGroup::RIGHT_SUIVRE_ACTIVITY]]); + + $this->fixture(Class_Users::class, + ['id' => 10, + 'nom' => 'Pistache', + 'prenom' => 'Amandine', + 'login' => 'Amd', + 'password' => 'fx9k', + 'mail' => 'pist@che.io', + 'user_groups' => [$group]]); + + $learn_haskell = $this->fixture(Class_Activity::class, + ['id' => 30, + 'libelle' => 'Learn Haskell', + 'description' => 'Learn useless things']); + + $this->fixture(Class_SessionActivity::class, + ['id' => 32, + 'activity' => $learn_haskell, + 'date_debut' => '2025-02-10', + 'date_fin' => '2025-03-29', + 'effectif_min' => 1, + 'effectif_max' => 5, + 'effectif_child_min' => 0, + 'effectif_child_max' => 0, + 'age_child_max' => 5, + 'effectif_inscription_max' => 5, + 'effectif_inscription_child_max' => 0, + 'duree'=> 8, + 'contenu' => 'Intro à la syntaxe', + 'horaires' => '9h - 12h, 13h - 18h', + 'date_limite_inscription'=>'2025-01-31']); + + $this->postDispatch('/admin/session-activity-inscription/subscribe/id/32/stagiaire_id/10', + ['adults' => '1', + 'children' => '0']); + + } + + /** @test */ + public function withQuotasAsStringSubscriptionShouldBeCreated() + { + $this + ->assertNotNull(Class_SessionActivityInscription::findFirstBy(['stagiaire_id' => 10, + 'session_activity_id' => 32])); + + } +} diff --git a/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php b/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php index 0c0c91ae8d633649306a60b8e69a4f90c5c7b473..5245a459e0071cb10343d4300d7b195775ce7c16 100644 --- a/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php +++ b/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php @@ -953,7 +953,7 @@ class Activities_AbonneControllerWithQuotasRegisterSessionTotalWithoutInscriptio $this->postDispatch('/abonne/inscrire-session/id/32', ['children' => 5]); - $this->assertFlashMessengerContentContains('Vous ne pouvez pas inscrire d\'enfants pour cette activitée'); + $this->assertFlashMessengerContentContains('Vous ne pouvez pas inscrire d\'enfants pour cette activité'); } @@ -997,7 +997,7 @@ class Activities_AbonneControllerWithQuotasRegisterSessionTotalWithoutInscriptio $this->postDispatch('/abonne/inscrire-session/id/32', ['adults' => 5]); - $this->assertFlashMessengerContentContains('Vous ne pouvez pas inscrire d\'adultes pour cette activitée'); + $this->assertFlashMessengerContentContains('Vous ne pouvez pas inscrire d\'adultes pour cette activité'); } }