From abfbacb4d1b6b4f447356e3c0daa355d3acb9f68 Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Wed, 12 Feb 2025 11:45:30 +0100
Subject: [PATCH 1/3] hotline#207656 : fix checking quotas with queue mode
 enabled

---
 VERSIONS_HOTLINE/207656                       |   1 +
 .../subscribe.phtml                           |   5 +-
 library/Class/SessionActivity.php             |   9 ++
 library/Class/SessionActivityAttendees.php    |   1 +
 library/Class/SessionActivityInscription.php  |  19 ++-
 .../Plugin/Manager/AbonneSessionActivity.php  |  16 ++-
 .../SessionActivityInscriptionBasic.php       |   6 +-
 .../Form/SessionActivityInscription.php       |   5 +
 .../View/Helper/Template/TruncateList.php     |  28 ++++-
 .../Library/Widget/Carousel/View.php          |   3 +-
 .../modules/AbstractControllerTestCase.php    |   6 +
 ...rollerGetExceededQuotaWithoutQueueTest.php | 106 ++++++++++++++++
 ...taWithQueueAndExistingSubscriptionTest.php | 107 ++++++++++++++++
 ...trollerPostExceedingQuotaWithQueueTest.php |  85 +++++++++++++
 .../AbonneControllerWithQuotasTest.php        |  17 ++-
 ...ireSessionWithQuotasAndQueueExistsTest.php |   2 +-
 ...eInscrireSessionWithQuotasAndQueueTest.php |   2 +-
 .../AbonneInscrireSessionWithQuotasTest.php   |   2 +-
 .../ActivitiesWithQueueAbonneTest.php         |  34 ++++-
 .../TemplatesActivitiesWidgetCachedTest.php   | 117 ++++++++++++++++++
 20 files changed, 544 insertions(+), 27 deletions(-)
 create mode 100644 VERSIONS_HOTLINE/207656
 create mode 100644 tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php
 create mode 100644 tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueAndExistingSubscriptionTest.php
 create mode 100644 tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueTest.php
 create mode 100644 tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php

diff --git a/VERSIONS_HOTLINE/207656 b/VERSIONS_HOTLINE/207656
new file mode 100644
index 00000000000..e01c216b25d
--- /dev/null
+++ b/VERSIONS_HOTLINE/207656
@@ -0,0 +1 @@
+ - correctif #207656 : [Activités] correction de la getion des quotas en mode file d'attente  
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml b/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml
index 94470b899a6..2c51a2450ef 100644
--- a/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml
+++ b/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml
@@ -1,6 +1,9 @@
 <?php
+if ($error = $this->error)
+  echo($this->tagError($error));
+
 if (!$this->isPopup())
   echo $this->partial('activity/_activity_panel.phtml',
-                      ['activity' => $this->inscription->getActivity()]);
+                      ['activity' => $this->inscription?->getActivity()]);
 
 echo $this->renderForm($this->form);
diff --git a/library/Class/SessionActivity.php b/library/Class/SessionActivity.php
index bd697a3364a..43bfcfe23c4 100644
--- a/library/Class/SessionActivity.php
+++ b/library/Class/SessionActivity.php
@@ -763,6 +763,15 @@ class Class_SessionActivity extends Storm_Model_Abstract {
   }
 
 
+  public function acceptAttendeesOnlyInQueue()
+  {
+    if (!$this->getQueueAttendees())
+      return false;
+
+    return ($this->getTotalRegistered() >= $this->getEffectifTotalMax());
+  }
+
+
   public function isFullAdults() {
     return $this->_getAttendees()->isFullAdults();
   }
diff --git a/library/Class/SessionActivityAttendees.php b/library/Class/SessionActivityAttendees.php
index ddf6049ad08..d0f7df05ce4 100644
--- a/library/Class/SessionActivityAttendees.php
+++ b/library/Class/SessionActivityAttendees.php
@@ -354,6 +354,7 @@ class Class_SessionActivityAttendeesWithQueueAndQuotas extends Class_SessionActi
 
 
   public function isFull() : bool {
+    // warning -> this method check if there is unlimited quota
     return $this->isFullAdults() && $this->isFullChildren();
   }
 
diff --git a/library/Class/SessionActivityInscription.php b/library/Class/SessionActivityInscription.php
index d58729de0c6..06451f2a0dd 100644
--- a/library/Class/SessionActivityInscription.php
+++ b/library/Class/SessionActivityInscription.php
@@ -298,7 +298,7 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract
     if ( $max < $current)
       $this->checkAttribute('adults',
                             false,
-                            $this->_('Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser %d adultes. %s',
+                            $this->_('Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser %d adulte(s). %s',
                                      $max,
                                      $plural));
 
@@ -322,7 +322,7 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract
     if ( $max < $current)
       $this->checkAttribute('children',
                             false,
-                            $this->_('Le nombre maximum d\'enfants pour cette activité est atteint. Il ne doit pas dépasser %d enfants. %s',
+                            $this->_('Le nombre maximum d\'enfants pour cette activité est atteint. Il ne doit pas dépasser %d enfant(s). %s',
                                      $max,
                                      $plural));
 
@@ -338,6 +338,7 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract
       $this->setQueue(0);
 
     return $this
+      ->_checkRemainingQueue()
       ->_checkRemainingAdultsQueue()
       ->_checkRemainingChildrenQueue();
   }
@@ -389,6 +390,20 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract
   }
 
 
+  protected function _checkRemainingQueue(): self
+  {
+    if ( !$max = $this->getEffectifTotalMax())
+      return $this;
+
+    $current_with_new = $this->numberOfAdults() + $this->numberOfChildren();
+
+    if ($current_with_new > $max)
+      $this->setQueue(1);
+
+    return $this;
+  }
+
+
   protected function _checkAttributeTotal() : bool {
     $remaining = (int) ($this->isNew()
                         ? $this->getSessionActivity()->getNextTotalFor($this)
diff --git a/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php b/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php
index 357f6fe541f..3ce031345dc 100644
--- a/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php
+++ b/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php
@@ -130,7 +130,17 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity
   }
 
 
+  protected function _getStatusInQueueMessage($model){
+    return $this->_('Votre inscription à l\'activité %s du %s est enregistrée. Vous avez été placé.e sur liste d\'attente et serez notifié.e si une place se libère.',
+                    $model->getLibelleActivity(),
+                    $model->getDateDebutTexte());
+  }
+
+
   protected function _getSuccessfulSaveMessage($model) {
+    if ($model->isQueue())
+      return $this->_getStatusInQueueMessage($model);
+
     return $this->_('Modification de votre inscription à la session du %s de l\'activité %s réussie',
                     $model->getDateDebutTexte(),
                     $model->getLibelleActivity());
@@ -180,10 +190,8 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity
 
 
   protected function _getSuccessfulAddMessage($model) {
-    return ($model->hasQueue())
-      ? $this->_('Vous êtes sur la liste d\'attente pour la session du %s de l\'activité %s.',
-                    $model->getDateDebutTexte(),
-                    $model->getLibelleActivity())
+    return ($model->isQueue())
+      ? $this->_getStatusInQueueMessage($model)
       : $this->_('Vous êtes inscrit à la session du %s de l\'activité %s.',
                     $model->getDateDebutTexte(),
                     $model->getLibelleActivity());
diff --git a/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php b/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php
index b748abf037f..2648c142736 100644
--- a/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php
+++ b/library/ZendAfi/Controller/Plugin/Manager/SessionActivityInscriptionBasic.php
@@ -110,9 +110,6 @@ class ZendAfi_Controller_Plugin_Manager_SessionActivityInscriptionBasic
 
 
   protected function _doAfterAdd($model) {
-    if (!$model->isQueue())
-      $this->_notifyRegistration($this->_user);
-
     if (!$this->_view->isPopup())
       $this->_redirectToUrlOrReferer($this->_redirect_default_url);
   }
@@ -161,7 +158,8 @@ class ZendAfi_Controller_Plugin_Manager_SessionActivityInscriptionBasic
 
 
   protected function _doOnCannotAdd() {
-    return $this->_redirectToReferer();
+    $this->_view->error = $this->_add_message;
+    return false;
   }
 
 
diff --git a/library/ZendAfi/Form/SessionActivityInscription.php b/library/ZendAfi/Form/SessionActivityInscription.php
index 67ea7011c0c..9d3ccd39c4f 100644
--- a/library/ZendAfi/Form/SessionActivityInscription.php
+++ b/library/ZendAfi/Form/SessionActivityInscription.php
@@ -29,6 +29,7 @@ class ZendAfi_Form_SessionActivityInscription extends ZendAfi_Form {
 
     $this
       ->addElement('info', 'totalmax_info')
+      ->addElement('info', 'queue_info')
       ->addElement('number', 'adults',
                    ['label' => $this->_('Nombre d\'adultes'),
                     'value' => 0,
@@ -63,6 +64,10 @@ class ZendAfi_Form_SessionActivityInscription extends ZendAfi_Form {
            ->setValue($this->_('Nombre total de participants: %s/%s',
                                $session->getTotalRegistered(), $total));
 
+    if ( !$session->hasStagiaire(Class_Users::getIdentity()) && $session->acceptAttendeesOnlyInQueue())
+      $this->getElement('queue_info')
+           ->setValue($this->_('Vous serez placé.e en liste d\'attente'));
+
     return $this;
   }
 
diff --git a/library/ZendAfi/View/Helper/Template/TruncateList.php b/library/ZendAfi/View/Helper/Template/TruncateList.php
index 60b0fca92d8..bfe8bce8c32 100644
--- a/library/ZendAfi/View/Helper/Template/TruncateList.php
+++ b/library/ZendAfi/View/Helper/Template/TruncateList.php
@@ -29,6 +29,7 @@ class ZendAfi_View_Helper_Template_TruncateList
     $_min_size_for_tools = 5,
     $_page_size = 3,
     $_container_id,
+    $_module_id,
     $_widget_id,
     $_top_tools_id,
     $_bottom_tools_id;
@@ -51,12 +52,15 @@ class ZendAfi_View_Helper_Template_TruncateList
   }
 
 
-  protected function _truncateListWithTools($collection, $callback, $size) {
-    $this->_container_id = uniqid();
-    $this->_widget_id = 'truncate_list_widget_id_' . $this->_container_id;
-    $this->_top_tools_id = 'top_tools_' . $this->_container_id;
-    $this->_bottom_tools_id = 'bottom_tools_' . $this->_container_id;
+  public function setIdModule(string $id): self
+  {
+    $this->_module_id = $id;
+    return $this;
+  }
 
+
+  protected function _truncateListWithTools($collection, $callback, $size) {
+    $this->_initIds();
     $html = $collection
       ->injectInto('', fn($html, $element) => $html . $this->_tag('div',
                                  $callback($element->inJsSearch()),
@@ -82,6 +86,17 @@ class ZendAfi_View_Helper_Template_TruncateList
   }
 
 
+  protected function _initIds(): self
+  {
+    $this->_container_id = $this->_container_id ??$this->_module_id ?? uniqid();
+    $this->_widget_id = 'truncate_list_widget_id_' . $this->_container_id;
+    $this->_top_tools_id = 'top_tools_' . $this->_container_id;
+    $this->_bottom_tools_id = 'bottom_tools_' . $this->_container_id;
+
+    return $this;
+  }
+
+
   protected function _renderTools($size, $tools_id) {
     $multi_options = $this->_getTruncateOptions($size);
 
@@ -120,7 +135,8 @@ class ZendAfi_View_Helper_Template_TruncateList
 
 
   public function renderHeadScriptsOn($script_loader) {
-    if ( ! $this->_container_id)
+    $this->_initIds();
+    if (!($this->_container_id = ($this->_container_id ?? $this->_module_id)))
       return $this;
 
     $script_loader
diff --git a/library/templates/Intonation/Library/Widget/Carousel/View.php b/library/templates/Intonation/Library/Widget/Carousel/View.php
index df0be027431..001cd45d735 100644
--- a/library/templates/Intonation/Library/Widget/Carousel/View.php
+++ b/library/templates/Intonation/Library/Widget/Carousel/View.php
@@ -267,7 +267,8 @@ abstract class Intonation_Library_Widget_Carousel_View extends Zendafi_View_Help
     if (in_array($layout,
                  [Intonation_Library_Widget_Carousel_Definition::MAP,
                   Intonation_Library_Widget_Carousel_Definition::WALL,
-                  Intonation_Library_Widget_Carousel_Definition::GRID]))
+                  Intonation_Library_Widget_Carousel_Definition::GRID,
+                  Intonation_Library_Widget_Carousel_Definition::LISTING_WITH_OPTIONS]))
       $this->_layout_helper->setIdModule($this->_settings->getIdForHtml());
 
     return $this->_layout_helper;
diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php
index 58af5e5a130..90c0b21cffd 100644
--- a/tests/application/modules/AbstractControllerTestCase.php
+++ b/tests/application/modules/AbstractControllerTestCase.php
@@ -462,6 +462,12 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe
   }
 
 
+  public function assertFlashMessengerCount(int $count): void
+  {
+    $this->assertCount($count, $this->_getFlashMessengerNotifications());
+  }
+
+
   public function assertFlashMessengerContentContains(string $value, string $message = ''): void
   {
     $messages = $this->_getFlashMessengerNotifications();
diff --git a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php
new file mode 100644
index 00000000000..f9dedff42ff
--- /dev/null
+++ b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php
@@ -0,0 +1,106 @@
+<?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 SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest
+  extends Admin_AbstractControllerTestCase
+{
+  public function setUp(): void
+  {
+    parent::setUp();
+    Class_AdminVar::set('ACTIVITY_SESSION_QUOTAS', 1);
+
+    $group_trainee = $this->fixture(Class_UserGroup::class,
+                                    ['id' => 22,
+                                     'libelle' => 'Stagiaires',
+                                     'rights' => [Class_UserGroup::RIGHT_SUIVRE_ACTIVITY]]);
+
+    $this->fixture(Class_Users::class,
+                   ['id' => 1001,
+                    'nom' => 'Pistache',
+                    'prenom' => 'Amandine',
+                    'login' => 'Amd',
+                    'idabon' => '65251',
+                    'id_site' => 1,
+                    'password' => 'fx9k',
+                    'mail' => 'pist@che.io',
+                    'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
+                    'user_groups' => [$group_trainee]]);
+
+    $this->fixture(Class_Users::class,
+                   ['id' => 1002,
+                    'nom' => 'Poincaré',
+                    'prenom' => 'Raymond',
+                    'login' => 'rpoincare',
+                    'idabon' => '65252',
+                    'id_site' => 1,
+                    'password' => 'fx9k',
+                    'mail' => 'rpoincare@che.io',
+                    'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
+                    'user_groups' => [$group_trainee]]);
+
+    $this->fixture(Class_Activity::class,
+                   ['id' => 330,
+                    'libelle' => 'Petites histoire']);
+
+    $session = $this->fixture(Class_SessionActivity::class,
+                              ['id' => 320,
+                               'activity_id' => 330,
+                               'date_debut' => '2025-03-27',
+                               'date_fin' => '2025-03-29',
+                               'effectif_min' => 0,
+                               'effectif_max' => 1,
+                               'effectif_child_min' => 0,
+                               'effectif_child_max' => 1,
+                               'effectif_total_min' => 0,
+                               'effectif_total_max' => 2,
+                               'age_child_max' => 5,
+                               'effectif_inscription_max' => 1,
+                               'effectif_inscription_child_max' => 1,
+                               'duree'=> 8,
+                               'contenu' => 'Lecture',
+                               'horaires' => '9h - 12h, 13h - 18h',
+                               'date_limite_inscription'=>'2025-03-05',
+                               'queue_attendees' => false]);
+
+
+    $inscription = $this->fixture(Class_SessionActivityInscription::class,
+                                  ['id' => 617,
+                                   'stagiaire_id' => 1001,
+                                   'session_activity_id' => 320,
+                                   'adults' => 1,
+                                   'children' => 1]);
+
+    $session->setSessionActivityInscriptions([$inscription]);
+
+    $this->dispatch('/admin/session-activity-inscription/subscribe/'
+                    . 'id/320/stagiaire_id/1001');
+
+  }
+
+
+  /** @test */
+  public function responseShouldContainErrorMessageInscriptionImpossible()
+  {
+    $this->assertXPathContentContains('//p[@class="error"]',
+                                      'Inscription impossible, plus de place disponible.');
+  }
+}
diff --git a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueAndExistingSubscriptionTest.php b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueAndExistingSubscriptionTest.php
new file mode 100644
index 00000000000..8b2b22664d5
--- /dev/null
+++ b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueAndExistingSubscriptionTest.php
@@ -0,0 +1,107 @@
+<?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 SessionActivityInscriptionControllerPostExceedingQuotaWithQueueAndExistingSubscriptionTest
+  extends Admin_AbstractControllerTestCase
+{
+  public function setUp(): void
+  {
+    parent::setUp();
+
+    Class_AdminVar::set('ACTIVITY_SESSION_QUOTAS', 1);
+
+    $group_trainee = $this->fixture(Class_UserGroup::class,
+                                    ['id' => 22,
+                                     'libelle' => 'Stagiaires',
+                                     'rights' => [Class_UserGroup::RIGHT_SUIVRE_ACTIVITY]]);
+
+    $this->fixture(Class_Users::class,
+                   ['id' => 1002,
+                    'nom' => 'Poincaré',
+                    'prenom' => 'Raymond',
+                    'login' => 'rpoincare',
+                    'idabon' => '65252',
+                    'id_site' => 1,
+                    'password' => 'fx9k',
+                    'mail' => 'rpoincare@che.io',
+                    'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
+                    'user_groups' => [$group_trainee]]);
+
+    $this->fixture(Class_Users::class,
+                   ['id' => 1001,
+                    'nom' => 'Pistache',
+                    'prenom' => 'Amandine',
+                    'login' => 'Amd',
+                    'idabon' => '65251',
+                    'id_site' => 1,
+                    'password' => 'fx9k',
+                    'mail' => 'pist@che.io',
+                    'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
+                    'user_groups' => [$group_trainee]]);
+
+    $this->fixture(Class_Activity::class,
+                   ['id' => 330,
+                    'libelle' => 'Petites histoire']);
+
+    $session = $this->fixture(Class_SessionActivity::class,
+                              ['id' => 320,
+                               'activity_id' => 330,
+                               'date_debut' => '2025-03-27',
+                               'date_fin' => '2025-03-29',
+                               'effectif_min' => 0,
+                               'effectif_max' => 1,
+                               'effectif_child_min' => 0,
+                               'effectif_child_max' => 1,
+                               'effectif_total_min' => 0,
+                               'effectif_total_max' => 3,
+                               'age_child_max' => 5,
+                               'effectif_inscription_max' => 1,
+                               'effectif_inscription_child_max' => 1,
+                               'duree'=> 8,
+                               'contenu' => 'Lecture',
+                               'horaires' => '9h - 12h, 13h - 18h',
+                               'date_limite_inscription'=>'2025-03-05',
+                               'queue_attendees' => true]);
+
+    $inscription = $this->fixture(Class_SessionActivityInscription::class,
+                                  ['id' => 617,
+                                   'stagiaire_id' => 1002,
+                                   'session_activity_id' => 320,
+                                   'adults' => 1,
+                                   'children' => 1]);
+
+    $session->setSessionActivityInscriptions([$inscription]);
+
+    $this->postDispatch('/admin/session-activity-inscription/subscribe/'
+                        . 'id/320/stagiaire_id/1001',
+                        ['adults' => 1,
+                         'children' => 1]);
+  }
+
+  /** @test */
+  public function additionamSubscribingRequestShouldBePutInQueue()
+  {
+    $this->assertTrue(Class_SessionActivityInscription
+                      ::findFirstBy(['session_activity_id' => 320,
+                                     'stagiaire_id' => 1001])->isQueue());
+  }
+}
diff --git a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueTest.php b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueTest.php
new file mode 100644
index 00000000000..af95681d25a
--- /dev/null
+++ b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerPostExceedingQuotaWithQueueTest.php
@@ -0,0 +1,85 @@
+<?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 SessionActivityInscriptionControllerPostExceedingQuotaWithQueueTest
+  extends Admin_AbstractControllerTestCase
+{
+  public function setUp(): void
+  {
+    parent::setUp();
+
+    Class_AdminVar::set('ACTIVITY_SESSION_QUOTAS', 1);
+
+    $group_trainee = $this->fixture(Class_UserGroup::class,
+                                    ['id' => 22,
+                                     'libelle' => 'Stagiaires',
+                                     'rights' => [Class_UserGroup::RIGHT_SUIVRE_ACTIVITY]]);
+
+    $this->fixture(Class_Users::class,
+                   ['id' => 1001,
+                    'nom' => 'Pistache',
+                    'prenom' => 'Amandine',
+                    'login' => 'Amd',
+                    'idabon' => '65251',
+                    'id_site' => 1,
+                    'password' => 'fx9k',
+                    'mail' => 'pist@che.io',
+                    'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
+                    'user_groups' => [$group_trainee]]);
+
+    $this->fixture(Class_Activity::class,
+                   ['id' => 330,
+                    'libelle' => 'Petites histoire']);
+
+    $this->fixture(Class_SessionActivity::class,
+                   ['id' => 320,
+                    'activity_id' => 330,
+                    'date_debut' => '2025-03-27',
+                    'date_fin' => '2025-03-29',
+                    'effectif_min' => 0,
+                    'effectif_max' => 1,
+                    'effectif_child_min' => 0,
+                    'effectif_child_max' => 1,
+                    'effectif_total_min' => 0,
+                    'effectif_total_max' => 1,
+                    'age_child_max' => 5,
+                    'effectif_inscription_max' => 1,
+                    'effectif_inscription_child_max' => 1,
+                    'duree'=> 8,
+                    'contenu' => 'Lecture',
+                    'horaires' => '9h - 12h, 13h - 18h',
+                    'date_limite_inscription'=>'2025-03-05',
+                    'queue_attendees' => true]);
+
+    $this->postDispatch('/admin/session-activity-inscription/subscribe/'
+                        . 'id/320/stagiaire_id/1001',
+                        ['adults' => 1,
+                         'children' => 1]);
+  }
+
+  /** @test */
+  public function subscribingRequestShouldBePutInQueue()
+  {
+    $this->assertTrue(Class_SessionActivityInscription
+                      ::findFirstBy(['session_activity_id' => 320])->isQueue());
+  }
+}
diff --git a/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php b/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php
index 0c0c91ae8d6..e62ea6902ce 100644
--- a/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php
+++ b/tests/scenarios/Activities/AbonneControllerWithQuotasTest.php
@@ -731,7 +731,14 @@ class Activities_AbonneControllerWithQuotasRegisterSessionPostTest
 
   /** @test */
   public function shouldNotifyRegistered() {
-    $this->assertFlashMessengerContentContains('Vous êtes inscrit');
+    $this->assertFlashMessengerContentContains('Vous êtes inscrit à la session du 10 février 2015 de l\'activité Learn Java.');
+  }
+
+
+  /** @test */
+  public function flashMessengerShouldContainOneMessage()
+  {
+    $this->assertFlashMessengerCount(1);
   }
 }
 
@@ -875,13 +882,13 @@ class Activities_AbonneControllerWithQuotasRegisterSessionMaxQuotasErrosWithTota
 
   /** @test */
   public function shouldDisplayTooManyAdults() {
-    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser 3 adultes. Il reste 3 places pour les adultes');
+    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser 3 adulte(s). Il reste 3 places pour les adultes');
   }
 
 
   /** @test */
   public function shouldDisplayTooManyChildren() {
-    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'enfants pour cette activité est atteint. Il ne doit pas dépasser 4 enfants. Il reste 4 places pour les enfants.');
+    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'enfants pour cette activité est atteint. Il ne doit pas dépasser 4 enfant(s). Il reste 4 places pour les enfants.');
   }
 }
 
@@ -1069,7 +1076,7 @@ class Activities_AbonneControllerWithQuotasRegisterSessionWithNoMoreAdultsPostTe
 
   /** @test */
   public function pageShouldContainsTooManyChildrenError() {
-    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'enfants pour cette activité est atteint. Il ne doit pas dépasser 2 enfants. Il reste 1 place pour un enfant.');
+    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'enfants pour cette activité est atteint. Il ne doit pas dépasser 2 enfant(s). Il reste 1 place pour un enfant.');
   }
 
 
@@ -1107,7 +1114,7 @@ class Activities_AbonneControllerWithQuotasRegisterSessionWithNoMoreChildrenPost
 
   /** @test */
   public function pageShouldContainsTooManyAdultsError() {
-    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser 2 adultes. Il reste 1 place pour un adulte.');
+    $this->assertXPathContentContains('//ul[@class="errors"]', 'Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser 2 adulte(s). Il reste 1 place pour un adulte.');
   }
 
 
diff --git a/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueExistsTest.php b/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueExistsTest.php
index 8f7fed64b9b..318f061be9e 100644
--- a/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueExistsTest.php
+++ b/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueExistsTest.php
@@ -80,7 +80,7 @@ class AbonneInscrireSessionWithQuotasFullAndQueueExistsTest extends AbstractCont
   /** @test */
   public function registrationShouldSuccessWithQueueMessage()
   {
-    $this->assertFlashMessengerContentContains('Vous êtes sur la liste d\'attente pour la session du 09 octobre 2024 de l\'activité scythe chap 1.');
+    $this->assertFlashMessengerContentContains('Votre inscription à l\'activité scythe chap 1 du 09 octobre 2024 est enregistrée. Vous avez été placé.e sur liste d\'attente et serez notifié.e si une place se libère.');
   }
 
 
diff --git a/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueTest.php b/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueTest.php
index e7ff30e05ae..6b6b440ed70 100644
--- a/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueTest.php
+++ b/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasAndQueueTest.php
@@ -75,7 +75,7 @@ class AbonneInscrireSessionWithQuotasFullAndQueueTest extends AbstractController
   /** @test */
   public function registrationShouldSuccessWithQueueMessage()
   {
-    $this->assertFlashMessengerContentContains('Vous êtes sur la liste d\'attente pour la session du 09 octobre 2024 de l\'activité scythe chap 1.');
+    $this->assertFlashMessengerContentContains('Votre inscription à l\'activité scythe chap 1 du 09 octobre 2024 est enregistrée. Vous avez été placé.e sur liste d\'attente et serez notifié.e si une place se libère.');
   }
 
 
diff --git a/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasTest.php b/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasTest.php
index 4d0da9f6523..e92d06918fc 100644
--- a/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasTest.php
+++ b/tests/scenarios/Activities/AbonneInscrireSessionWithQuotasTest.php
@@ -74,7 +74,7 @@ class AbonneInscrireSessionWithQuotasFullTest extends AbstractControllerTestCase
   /** @test */
   public function registrationShouldFailWithFullMessage()
   {
-    $this->assertFlashMessengerContentContains('Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser 2 adultes. Il reste 1 place pour un adulte.');
+    $this->assertFlashMessengerContentContains('Le nombre maximum d\'adultes pour cette activité est atteint. Il ne doit pas dépasser 2 adulte(s). Il reste 1 place pour un adulte.');
   }
 
 
diff --git a/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php b/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php
index 8802bbb0245..0fcad6ba948 100644
--- a/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php
+++ b/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php
@@ -726,6 +726,17 @@ class ActivitiesWithQueueAbonneWithQuotasFullNotInQueueEditTest
   }
 
 
+  /** @test */
+  public function modifShouldHaveMessageInQueue() {
+    ZendAfi_Auth::getInstance()->logUser(Class_Users::find(435));
+    $this->postDispatch('/abonne/edit-session/id/159',
+                        ['adults' => 2,
+                         'children'=>3]);
+    Class_SessionActivityInscription::clearCache();
+    $this->assertFlashMessengerContentContains("Votre inscription à l'activité Learn Java du 27 mai 2021 est enregistrée. Vous avez été placé.e sur liste d'attente et serez notifié.e si une place se libère.");
+  }
+
+
   /** @test */
   public function onPostLessAdultsShouldReloadQueue() {
     $this->postDispatch('/abonne/edit-session/id/234', ['adults' => 2]);
@@ -1062,6 +1073,12 @@ class ActivitiesWithQueueAbonneWithMaxQuotasTest
   }
 
 
+  /** @test */
+  public function pageShouldNotContainsQueueInfo() {
+    $this->assertNotXPathContentContains('//div', 'Vous serez placé.e en liste d\'attente');
+  }
+
+
   /** @test */
   public function pageShouldContainsNombresAdultes15PlacesRestantes() {
     $this->assertXPathContentContains('//label[@for="adults"]',
@@ -1106,6 +1123,12 @@ class ActivitiesWithQueueAbonneWithMaxQuotasPartiallyRegistredTest
   }
 
 
+  /** @test */
+  public function pageShouldNotContainsQueueInfo() {
+    $this->assertNotXPathContentContains('//div', 'Vous serez placé.e en liste d\'attente');
+  }
+
+
   /** @test */
   public function pageShouldContainsNombresAdultes5PlacesRestantes() {
     $this->assertXPathContentContains('//label[@for="adults"]',
@@ -1150,6 +1173,12 @@ class ActivitiesWithQueueAbonneWithMaxQuotasFullRegistredTest
   }
 
 
+  /** @test */
+  public function pageShouldContainsQueueInfo() {
+    $this->assertXPathContentContains('//div', 'Vous serez placé.e en liste d\'attente');
+  }
+
+
   /** @test */
   public function pageShouldContainsNombresAdultesComplet() {
     $this->assertXPathContentContains('//label[@for="adults"]',
@@ -1192,7 +1221,10 @@ class ActivitiesWithQueueAbonneWithMaxQuotasFullAttemptRegistringTest
 
   /** @test */
   public function registrationShouldBePutInQueue() {
-    $registration = Class_SessionActivityInscription::find(568);
+    $registration = Class_SessionActivityInscription::findFirstBy(['stagiaire_id' => 435,
+                                                          'session_activity_id' => 36,
+                                                          'adults' => 10,
+                                                          'children' => 10]);
     $this->assertTrue($registration->isQueue());
   }
 }
diff --git a/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php b/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
new file mode 100644
index 00000000000..d4f22eadf00
--- /dev/null
+++ b/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
@@ -0,0 +1,117 @@
+
++
+112
+−
+0
+<?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 TemplatesActivitiesWidgetHiddenSessionActivityAsAdminTest
+  extends AbstractControllerTestCase
+{
+
+  public function setUp(): void
+  {
+    parent::setUp();
+
+    $this->_buildTemplateProfil(['id' => 3]);
+
+    $group = $this->fixture(Class_UserGroup::class,
+                            ['id' => 19,
+                             'libelle' => 'Le groupe des activités',
+                             'rights' => [Class_UserGroup::RIGHT_DIRIGER_ACTIVITY]]);
+
+    $bib = $this->fixture(Class_Bib::class, ['id' => 12,
+                                             'libelle' => 'Annecy']);
+
+    $logged = $this->fixture(Class_Users::class,
+                             ['id' => 12,
+                              'nom' => 'Rédacteur',
+                              'prenom' => 'Activités',
+                              'login' => 'ractivities',
+                              'password' => 'fx9k',
+                              'mail' => 'r@bib.com',
+                              'bib' => $bib,
+                              'user_groups' => [$group],
+                              'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_BIB]);
+
+    (new Class_Template_ProfilePatcher(null))
+      ->setProfile(Class_Profil::find(3))
+      ->addWidget(Intonation_Library_Widget_Carousel_Activity_Definition::CODE,
+                  Class_Profil::DIV_MAIN,
+                  ['rendering' => 'card-horizontal',
+                   'selected_activities' => '56-57',
+                   'layout' => 'list_with_options',
+                   'order' => 'title desc',
+                   'size' => 5]);
+
+    $this->fixture(Class_Activity::class,
+                   ['id' => 56,
+                    'libelle' => 'scythe chap 1',
+                    'visible' => true])
+         ->setSessions([$this->fixture(Class_SessionActivity::class,
+                                       ['id' => 1,
+                                        'contenu' => 'dogfighting tricks',
+                                        'date_debut' => '2024-09-05',
+                                        'date_fin' => '2024-10-30',
+                                        'date_limite_fin' => '2024-09-04',
+                                        'stagiaires' => [],
+                                        'effectif_max' => 0,
+                                        'effectif_min' => 0,
+                                        'visible' => false])])
+         ->save();
+
+    $this->fixture(Class_Activity::class,
+                   ['id' => 57,
+                    'libelle' => 'scythe chap 2'])
+         ->setSessions([$this->fixture(Class_SessionActivity::class,
+                                       ['id' => 5,
+                                        'contenu' => 'dogfighting aim',
+                                        'date_debut' => '2024-10-10',
+                                        'date_fin' => '2024-10-30',
+                                        'date_limite_fin' => '2024-10-08',
+                                        'stagiaires' => [],
+                                        'effectif_max' => 10,
+                                        'effectif_min' => 1])])
+         ->save();
+
+    $timesource = new TimeSourceForTest('2024-09-04');
+    Class_SessionActivity::setTimeSource($timesource);
+    Intonation_Library_Widget_Carousel_Activity_Definition::setTimeSource($timesource);
+
+    ZendAfi_Auth::getInstance()->logUser($logged);
+    $this->dispatch('/');
+    $this->dispatch('/');
+  }
+
+  /** @test */
+  public function truncateListToolsScriptShouldBeLoaded()
+  {
+    $this->assertXPathContentContains('//script', 'truncate_list_tools');
+  }
+
+  /** @test */
+  public function scytheChap2ShouldBeDisplayed()
+  {
+    $this->assertXPathContentContains('//main', 'scythe chap 2');
+  }
+}
-- 
GitLab


From 5be91013e098d7e83e0d05dd6dfc6f5c3d8623f4 Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Fri, 21 Feb 2025 16:19:58 +0100
Subject: [PATCH 2/3] hotline#207656 : RT fixes

---
 VERSIONS_HOTLINE/207656                            |  2 +-
 .../session-activity-inscription/subscribe.phtml   |  2 +-
 library/Class/SessionActivity.php                  |  8 +++-----
 library/Class/SessionActivityAttendees.php         |  4 +++-
 .../Plugin/Manager/AbonneSessionActivity.php       | 14 +++++++-------
 .../ZendAfi/View/Helper/Template/TruncateList.php  |  4 +++-
 ...nControllerGetExceededQuotaWithoutQueueTest.php |  1 -
 .../Activities/ActivitiesWithQueueAbonneTest.php   | 12 ++++++++----
 .../TemplatesActivitiesWidgetCachedTest.php        |  5 -----
 9 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/VERSIONS_HOTLINE/207656 b/VERSIONS_HOTLINE/207656
index e01c216b25d..8be3d103527 100644
--- a/VERSIONS_HOTLINE/207656
+++ b/VERSIONS_HOTLINE/207656
@@ -1 +1 @@
- - correctif #207656 : [Activités] correction de la getion des quotas en mode file d'attente  
\ No newline at end of file
+ - correctif #207656 : Activités : correction de la getion des quotas en mode file d'attente  
\ No newline at end of file
diff --git a/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml b/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml
index 2c51a2450ef..ab892d434fa 100644
--- a/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml
+++ b/application/modules/admin/views/scripts/session-activity-inscription/subscribe.phtml
@@ -1,6 +1,6 @@
 <?php
 if ($error = $this->error)
-  echo($this->tagError($error));
+  echo $this->tagError($error);
 
 if (!$this->isPopup())
   echo $this->partial('activity/_activity_panel.phtml',
diff --git a/library/Class/SessionActivity.php b/library/Class/SessionActivity.php
index 43bfcfe23c4..45bb8af0082 100644
--- a/library/Class/SessionActivity.php
+++ b/library/Class/SessionActivity.php
@@ -763,12 +763,10 @@ class Class_SessionActivity extends Storm_Model_Abstract {
   }
 
 
-  public function acceptAttendeesOnlyInQueue()
+  public function acceptAttendeesOnlyInQueue(): bool
   {
-    if (!$this->getQueueAttendees())
-      return false;
-
-    return ($this->getTotalRegistered() >= $this->getEffectifTotalMax());
+    return $this->getQueueAttendees()
+      && ($this->getTotalRegistered() >= $this->getEffectifTotalMax());
   }
 
 
diff --git a/library/Class/SessionActivityAttendees.php b/library/Class/SessionActivityAttendees.php
index d0f7df05ce4..d36436d63ba 100644
--- a/library/Class/SessionActivityAttendees.php
+++ b/library/Class/SessionActivityAttendees.php
@@ -353,8 +353,10 @@ class Class_SessionActivityAttendeesWithQueueAndQuotas extends Class_SessionActi
   protected bool $_session_with_quotas = true;
 
 
+  /**
+   * @warning this method check if there is unlimited quota
+   */
   public function isFull() : bool {
-    // warning -> this method check if there is unlimited quota
     return $this->isFullAdults() && $this->isFullChildren();
   }
 
diff --git a/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php b/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php
index 3ce031345dc..b7b060f81ed 100644
--- a/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php
+++ b/library/ZendAfi/Controller/Plugin/Manager/AbonneSessionActivity.php
@@ -130,7 +130,8 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity
   }
 
 
-  protected function _getStatusInQueueMessage($model){
+  protected function _getStatusInQueueMessage($model): string
+  {
     return $this->_('Votre inscription à l\'activité %s du %s est enregistrée. Vous avez été placé.e sur liste d\'attente et serez notifié.e si une place se libère.',
                     $model->getLibelleActivity(),
                     $model->getDateDebutTexte());
@@ -138,12 +139,11 @@ class ZendAfi_Controller_Plugin_Manager_AbonneSessionActivity
 
 
   protected function _getSuccessfulSaveMessage($model) {
-    if ($model->isQueue())
-      return $this->_getStatusInQueueMessage($model);
-
-    return $this->_('Modification de votre inscription à la session du %s de l\'activité %s réussie',
-                    $model->getDateDebutTexte(),
-                    $model->getLibelleActivity());
+    return $model->isQueue()
+      ? $this->_getStatusInQueueMessage($model)
+      : $this->_('Modification de votre inscription à la session du %s de l\'activité %s réussie',
+                 $model->getDateDebutTexte(),
+                 $model->getLibelleActivity());
   }
 
 
diff --git a/library/ZendAfi/View/Helper/Template/TruncateList.php b/library/ZendAfi/View/Helper/Template/TruncateList.php
index bfe8bce8c32..9230aa0d753 100644
--- a/library/ZendAfi/View/Helper/Template/TruncateList.php
+++ b/library/ZendAfi/View/Helper/Template/TruncateList.php
@@ -88,7 +88,9 @@ class ZendAfi_View_Helper_Template_TruncateList
 
   protected function _initIds(): self
   {
-    $this->_container_id = $this->_container_id ??$this->_module_id ?? uniqid();
+    if ( ! $this->_container_id )
+      $this->_container_id = $this->_module_id ?? uniqid();
+
     $this->_widget_id = 'truncate_list_widget_id_' . $this->_container_id;
     $this->_top_tools_id = 'top_tools_' . $this->_container_id;
     $this->_bottom_tools_id = 'bottom_tools_' . $this->_container_id;
diff --git a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php
index f9dedff42ff..dd4fa52c4b8 100644
--- a/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php
+++ b/tests/application/modules/admin/controllers/SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest.php
@@ -81,7 +81,6 @@ class SessionActivityInscriptionControllerGetExceededQuotaWithoutQueueTest
                                'date_limite_inscription'=>'2025-03-05',
                                'queue_attendees' => false]);
 
-
     $inscription = $this->fixture(Class_SessionActivityInscription::class,
                                   ['id' => 617,
                                    'stagiaire_id' => 1001,
diff --git a/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php b/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php
index 0fcad6ba948..d8d58bdd852 100644
--- a/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php
+++ b/tests/scenarios/Activities/ActivitiesWithQueueAbonneTest.php
@@ -727,7 +727,8 @@ class ActivitiesWithQueueAbonneWithQuotasFullNotInQueueEditTest
 
 
   /** @test */
-  public function modifShouldHaveMessageInQueue() {
+  public function modifShouldHaveMessageInQueue()
+  {
     ZendAfi_Auth::getInstance()->logUser(Class_Users::find(435));
     $this->postDispatch('/abonne/edit-session/id/159',
                         ['adults' => 2,
@@ -1074,7 +1075,8 @@ class ActivitiesWithQueueAbonneWithMaxQuotasTest
 
 
   /** @test */
-  public function pageShouldNotContainsQueueInfo() {
+  public function pageShouldNotContainsQueueInfo()
+  {
     $this->assertNotXPathContentContains('//div', 'Vous serez placé.e en liste d\'attente');
   }
 
@@ -1124,7 +1126,8 @@ class ActivitiesWithQueueAbonneWithMaxQuotasPartiallyRegistredTest
 
 
   /** @test */
-  public function pageShouldNotContainsQueueInfo() {
+  public function pageShouldNotContainsQueueInfo()
+  {
     $this->assertNotXPathContentContains('//div', 'Vous serez placé.e en liste d\'attente');
   }
 
@@ -1174,7 +1177,8 @@ class ActivitiesWithQueueAbonneWithMaxQuotasFullRegistredTest
 
 
   /** @test */
-  public function pageShouldContainsQueueInfo() {
+  public function pageShouldContainsQueueInfo()
+  {
     $this->assertXPathContentContains('//div', 'Vous serez placé.e en liste d\'attente');
   }
 
diff --git a/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php b/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
index d4f22eadf00..2eeb0308292 100644
--- a/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
+++ b/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
@@ -1,8 +1,3 @@
-
-+
-112
-−
-0
 <?php
 /**
  * Copyright (c) 2012-2024, Agence Française Informatique (AFI). All rights reserved.
-- 
GitLab


From a293505e21b72acfd2e98a6d696919db7471025f Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Mon, 24 Feb 2025 10:33:57 +0100
Subject: [PATCH 3/3] hotline#207656 : RT fixes 2

---
 library/ZendAfi/View/Helper/Template/TruncateList.php         | 4 +---
 .../Templates/TemplatesActivitiesWidgetCachedTest.php         | 1 -
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/library/ZendAfi/View/Helper/Template/TruncateList.php b/library/ZendAfi/View/Helper/Template/TruncateList.php
index 9230aa0d753..6066dc18ddd 100644
--- a/library/ZendAfi/View/Helper/Template/TruncateList.php
+++ b/library/ZendAfi/View/Helper/Template/TruncateList.php
@@ -89,7 +89,7 @@ class ZendAfi_View_Helper_Template_TruncateList
   protected function _initIds(): self
   {
     if ( ! $this->_container_id )
-      $this->_container_id = $this->_module_id ?? uniqid();
+      $this->_container_id = $this->_module_id ?: uniqid();
 
     $this->_widget_id = 'truncate_list_widget_id_' . $this->_container_id;
     $this->_top_tools_id = 'top_tools_' . $this->_container_id;
@@ -138,8 +138,6 @@ class ZendAfi_View_Helper_Template_TruncateList
 
   public function renderHeadScriptsOn($script_loader) {
     $this->_initIds();
-    if (!($this->_container_id = ($this->_container_id ?? $this->_module_id)))
-      return $this;
 
     $script_loader
       ->addSearchInputToContainer('#' . $this->_container_id,
diff --git a/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php b/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
index 2eeb0308292..630a67ecff9 100644
--- a/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
+++ b/tests/scenarios/Templates/TemplatesActivitiesWidgetCachedTest.php
@@ -95,7 +95,6 @@ class TemplatesActivitiesWidgetHiddenSessionActivityAsAdminTest
 
     ZendAfi_Auth::getInstance()->logUser($logged);
     $this->dispatch('/');
-    $this->dispatch('/');
   }
 
   /** @test */
-- 
GitLab