diff --git a/library/Class/SessionFormation.php b/library/Class/SessionFormation.php index ccae6f4bd76af0afe0464ef403831c1137c760d6..f893cb76a642b0239047c8b761d239c7d27dcb0a 100644 --- a/library/Class/SessionFormation.php +++ b/library/Class/SessionFormation.php @@ -78,13 +78,7 @@ class Class_SessionFormation extends Storm_Model_Abstract { if(!$this->hasDateLimiteInscription()) return true; - return !$this->isDateSubscriable(); - } - - - - public function isDateSubscriable() { - return !$this->isDateSubscriptionExhausted(); + return $this->isDateSubscriptionExhausted(); } @@ -142,7 +136,7 @@ class Class_SessionFormation extends Storm_Model_Abstract { $date = parent::_get('date_limite_inscription'); if ('0000-00-00' == $date) $date = null; - return $date; + return $date ? $date : null; } @@ -200,8 +194,6 @@ class Class_SessionFormation extends Storm_Model_Abstract { public function isSubscriableFor($user) { - xdebug_break(); - if(!$user) return false; diff --git a/library/ZendAfi/View/Helper/RenderSession.php b/library/ZendAfi/View/Helper/RenderSession.php index 8b8874536f880bb21ba547472b3b84ad62d03735..917659db8695456e9ecbc177ebb36953c5e25fb9 100644 --- a/library/ZendAfi/View/Helper/RenderSession.php +++ b/library/ZendAfi/View/Helper/RenderSession.php @@ -70,7 +70,7 @@ class Render_Session_Dl extends Render_Session { $this->view->tag('dd', ($session->isFull() ? $this->view->_('Complet ') : '' ). - ($session->isDateSubscriable() + (!$session->isDateSubscriptionExhausted() ? '' : $this->view->_('Date de limite d\'inscription dépassée'))). @@ -147,13 +147,14 @@ class Render_Session_Table extends Render_Session { $html = $session->isAnnule() ? $this->errorSpan($this->view->_('Annulée')) : ''; - $html.= $session->hasDateLimiteInscription() - ? ($this->errorSpan( - (($session->isDateSubscriptionExhausted() - ? $this->view->_('Date de limite d\'inscription dépassée: ') - : ''). - $session->getDateLimiteInscriptionHumanRead()))) - : ''; + $html.= $this->errorSpan( + $session->isDateSubscriptionExhausted() + ? $this->view->_('Date de limite d\'inscription dépassée: '). + $session->getDateLimiteInscriptionHumanRead() + : ($session->hasDateLimiteInscription() + ? $this->view->_('Date de limite d\'inscription: '). + $session->getDateLimiteInscriptionHumanRead() + :'')); $html.= $session->isFull() ? $this->errorSpan($this->view->_('Complet: maximum de personnes inscrites')) @@ -162,26 +163,4 @@ class Render_Session_Table extends Render_Session { return $html; } } - - -/* - -<tr class="session_<?php echo $this->session->getId()?> <?php echo $this->item_class ?>"> -<?php -echo sprintf("<td>%s %s</td>", - $this->renderDateRange($this->session->getDateDebut(), $this->session->getDateFin()), - $this->session->isAnnule() ? '(Annulé)' : ''); -echo sprintf("<td>%s </td>", $this->session->getLibelleLieu()); -echo sprintf("<td>%s</td>", - $this->tagAnchor(array('action' => 'detail-session', - 'id' => $this->session->getId()), - $this->_('Détails de la session'))); -echo sprintf("<td>%s</td>", - $this->tagSessionFormationInscription($this->session)); -?> -</tr> - - - - */ ?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php index d2a87db6d07cd88952075d14e0807a6c2934f58f..c4f6787ded25f36a4c3d74896251192dcbe75b4c 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php @@ -129,9 +129,9 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro 'effectif_min' => 2, 'effectif_max' => 5, 'lieu' => $this->_gallice_cafe, - 'date_debut' => '2014-03-1', + 'date_debut' => '2014-03-01', 'stagiaires' => [], - 'date_limit_inscription' => '2014-03-1']); + 'date_limite_inscription' => '2014-03-01']); $this->_session_java_septembre = $this->fixture('Class_SessionFormation', ['id' => 30, @@ -272,28 +272,6 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati } - /** @test */ - function sessionShouldBeFull() { - $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', - 'Complet', $this->_response->getBody()); - } - - - /** @test */ - function sessionShouldBeCanceld() { - $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', - 'Annul'); - } - - - /** @test */ - function sessionShouldBeDisplaySubscribeTimeExhaust() { - $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', - 'Date '); - } - - - /** @test */ function session_fevrier_17_ShouldHaveLinkForDetailSessionFormation() { $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/detail-session/id/31")]', @@ -303,26 +281,23 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ function session_mars_27_ShouldBeDisplayedUnderLearnJavaInFirstPosition() { - $this->assertXPathContentContains('//tbody//tr', '01 mars 2014'); + $this->assertXPathContentContains('//tbody//tr', '1 mars 2014'); } /** @test */ function session_septembre_java_ShouldBeAnnule() { - $this->assertXPathContentContains('//tr//td[contains(text(), "Annul")]//span', '01 septembre 2014'); + $this->assertXPathContentContains('//tr/td/span[@class="error"]', 'Annul'); } - /** @test */ function session_python_juillet_ShouldHaveLinkForDesinscrire() { $this->assertXPathContentContains('//tr//a[contains(@href, "abonne/desinscrire-session/id/121")]', - "Se désinscrire", - $this->_response->getBody()); + "Se désinscrire"); } - /** @test */ function boiteTitleShouldBeFormations() { $this->assertXPathContentContains('//h1', 'Formations'); @@ -397,7 +372,6 @@ Class AbonneControllerFormationsFicheAbonneWithoutSufficientRigthsTest extends A - class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); @@ -425,6 +399,7 @@ class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends Abst } + class AbonneControllerFormationsAmadouInscritSessionMarsJavaClosedTest extends AbstractAbonneControllerFormationsTestCase { /** @test */ public function inscrireSessionShouldNotCallSave() { @@ -434,6 +409,7 @@ class AbonneControllerFormationsAmadouInscritSessionMarsJavaClosedTest extends A } + class AbonneControllerFormationsAmadouInscritSessionFeebruaryJavaOpenTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); @@ -509,7 +485,6 @@ class AbonneControllerFormationsSessionJavaFevrierFullListTest extends AbonneCon - class AbonneControllerFormationsSessionJavaFevrierFullAndInscritListTest extends AbonneControllerFormationsSessionJavaFevrierFullTestCase { /** @test */ public function pageShouldHaveLinkToDesinscrire() { @@ -542,7 +517,6 @@ class AbonneControllerFormationsAmadouInscritSessionJavaFevrierFullTest extends - class AbonneControllerFormationsInscritSessionWithoutRightSuivreFormationTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); @@ -595,7 +569,6 @@ class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends - class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); @@ -628,12 +601,10 @@ class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneCon function ddShouldContainsGoogleMap() { $this->assertXPath('//dd//img[@src="http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=15&size=300x300¢er=45.902179%2C6.128715&markers=45.902179%2C6.128715"]'); } - } - class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); @@ -708,7 +679,6 @@ class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractA - class AbonneControllerFormationsSessionJuilletPythonDetailRetourFicheTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); @@ -724,7 +694,6 @@ class AbonneControllerFormationsSessionJuilletPythonDetailRetourFicheTest extend - class AbonneControllerFormationsWrongIdsTest extends AbstractAbonneControllerFormationsTestCase { /** @test */ public function onDetailSessionShouldRedirectToFormations() { @@ -746,4 +715,99 @@ class AbonneControllerFormationsWrongIdsTest extends AbstractAbonneControllerFor $this->assertRedirectTo('/abonne/formations'); } -} \ No newline at end of file +} + + + +Class AbonneControllerFormationsInformationsTest extends AbstractControllerTestCase { + + public function setup() { + parent::setup(); + + $test_time = new TimeSourceForTest('2014-05-09 14:00:00'); + + Class_Formation::setTimeSource($test_time); + Class_SessionFormation::setTimeSource($test_time); + + + $current_user = $this->fixture('Class_Users', + ['id' => 1, + 'login' => 'log', + 'password' => 'pwd']); + $current_user + ->beAbonneSIGB() + ->setUserGroups([$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()]); + + ZendAfi_Auth::getInstance()->logUser($current_user); + + $session_full = $this->fixture('Class_SessionFormation', + ['id' => 1, + 'formation_id' => 1, + 'date_debut' => '2014-07-10', + 'date_limite_inscription' => '2014-07-01', + 'effectif_min' => 1, + 'effectif_max' => 1, + 'stagiaires' => [$current_user]]); + + $session_canceled = $this->fixture('Class_SessionFormation', + ['id' => 1, + 'formation_id' => 1, + 'date_debut' => '2014-07-10', + 'effectif_min' => 1, + 'effectif_max' => 10, + 'stagiaires' => []]); + $session_canceled->beAnnule(); + + $session_subscription_exhausted = $this->fixture('Class_SessionFormation', + ['id' => 1, + 'formation_id' => 1, + 'date_debut' => '2014-07-10', + 'date_limite_inscription' => '2014-01-10', + 'effectif_min' => 1, + 'effectif_max' => 10, + 'stagiaires' => []]); + + $formation = $this->fixture('Class_Formation', + ['id' => 1, + 'libelle' => 'Farming cerths', + 'sessions' => [$session_full, + $session_canceled, + $session_subscription_exhausted]]); + + + $current_user->setSessionFormationInscriptions([$this->fixture('Class_SessionFormationInscription', + ['id' => 1, + 'stagiaire' => $current_user, + 'session_formation' => $formation])]); + $this->dispatch('/opac/abonne/formations', true); + } + + + /** @test */ + function sessionShouldBeFull() { + $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', + 'Complet', $this->_response->getBody()); + } + + + /** @test */ + function sessionShouldBeCanceld() { + $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', + 'Annul'); + } + + + /** @test */ + function sessionShouldBeDisplaySubscribeTimeExhaust() { + $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', + 'Date de limite d\'inscription dépassée:', $this->_response->getBody()); + } + + + /** @test */ + function sessionShouldDisplaySubscribeTime() { + $this->assertXPathContentContains('//tbody//tr/td/span[@class="error"]', + 'Date de limite d\'inscription:', $this->_response->getBody()); + } +} +?> \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/FormationsWidgetTest.php b/tests/library/ZendAfi/View/Helper/Accueil/FormationsWidgetTest.php index ea641b2080eb8346fb84a63b501edfa8e62d0ad7..010090bc0c038bcd58e17508b268f7cbc60a9b1a 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/FormationsWidgetTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/FormationsWidgetTest.php @@ -57,13 +57,16 @@ class ZendAfi_View_Helper_Accueil_FormationsWidgetWithLoggedSIGBUserTest extends public function setup() { parent::setup(); + + $time_source = new TimeSourceForTest('2014-05-06 14:00:00'); Class_Formation::beVolatile(); Class_SessionFormation::beVolatile(); Class_Users::beVolatile(); Class_SessionFormationInscription::beVolatile(); - Class_Formation::setTimeSource(new TimeSourceForTest('2014-05-06 14:00:00')); + Class_Formation::setTimeSource($time_source); + Class_SessionFormation::setTimeSource($time_source); $sigb_user = $this->fixture('Class_Users', ['id' => 1, 'login' => 'uR', @@ -183,7 +186,7 @@ class ZendAfi_View_Helper_Accueil_FormationsWidgetWithNoLoggedUserTest extends V /** @test */ public function subscriptionShouldNotBeAvailable() { - $this->assertXPathContentContains($this->_html, '//div[@class="actions"]', "Vous devez vous connecter pour pouvoir vous inscrire"); + $this->assertNotXPathContentContains($this->_html, '//div[@class="actions"]/a', "S'inscrire"); } } ?> \ No newline at end of file