From b9286e5e44073af6c07ed883ae3a6f4da5c58b7e Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Tue, 6 May 2014 12:42:06 +0200 Subject: [PATCH] dev #13296 pimp tests/controllers/AbonneControllerFormationsTest --- .../opac/controllers/AbonneController.php | 6 +- .../opac/views/scripts/abonne/_session.phtml | 4 +- library/Class/Formation.php | 7 +- library/Class/SessionFormation.php | 2 +- .../ZendAfi/View/Helper/Abonne/Formations.php | 2 +- .../Helper/TagSessionFormationInscription.php | 8 +- .../AbonneControllerFormationsTest.php | 388 +++++++++--------- 7 files changed, 209 insertions(+), 208 deletions(-) diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 57fc24cd93c..2c3a331e83d 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -55,7 +55,7 @@ class AbonneController extends ZendAfi_Controller_Action { } - public function inscriresessionAction() { + public function inscrireSessionAction() { if (($session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) && !$session->isInscriptionClosed()) { $session->addStagiaire($this->_user); @@ -74,7 +74,7 @@ class AbonneController extends ZendAfi_Controller_Action { } - public function desinscriresessionAction() { + public function desinscrireSessionAction() { if (!$session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) { $this->_helper->notify('Session non trouvée'); $this->_redirect('/abonne/formations'); @@ -128,7 +128,7 @@ class AbonneController extends ZendAfi_Controller_Action { - public function detailsessionAction() { + public function detailSessionAction() { if (!$session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) $this->_redirect('/abonne/formations'); $this->view->retour_action = $this->_getParam('retour', 'formations'); diff --git a/application/modules/opac/views/scripts/abonne/_session.phtml b/application/modules/opac/views/scripts/abonne/_session.phtml index bfef4a64dd8..be5f4ee4198 100644 --- a/application/modules/opac/views/scripts/abonne/_session.phtml +++ b/application/modules/opac/views/scripts/abonne/_session.phtml @@ -5,10 +5,10 @@ echo sprintf("<td>%s %s</td>", $this->session->isAnnule() ? '(Annulé)' : ''); echo sprintf("<td>%s </td>", $this->session->getLibelleLieu()); echo sprintf("<td>%s</td>", - $this->tagAnchor(array('action' => 'detail_session', + $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 +</tr> diff --git a/library/Class/Formation.php b/library/Class/Formation.php index 0cd65dcbb18..444b9ecb2ec 100644 --- a/library/Class/Formation.php +++ b/library/Class/Formation.php @@ -21,6 +21,7 @@ class Class_Formation extends Storm_Model_Abstract { use Trait_Translator; + use Trait_TimeSource; protected $_table_name = 'formations'; protected $_has_many = ['sessions' => ['model' => 'Class_SessionFormation', @@ -38,10 +39,10 @@ class Class_Formation extends Storm_Model_Abstract { public static function indexByYear($formations) { - $formations_by_year = array(); + $formations_by_year = []; foreach($formations as $formation) { if (!array_key_exists($formation->getAnnee(), $formations_by_year)) - $formations_by_year[$formation->getAnnee()] = array(); + $formations_by_year[$formation->getAnnee()] = []; if ($formation->hasSessions()) $formations_by_year[$formation->getAnnee()][] = $formation; } @@ -55,7 +56,7 @@ class Class_Formation extends Storm_Model_Abstract { public function getAnnee() { if ($this->hasSessions()) return array_first($this->getSessions())->getAnnee(); - return date('Y'); + return self::getTimeSource()->date('Y'); } diff --git a/library/Class/SessionFormation.php b/library/Class/SessionFormation.php index 339159e8a81..b608593ff80 100644 --- a/library/Class/SessionFormation.php +++ b/library/Class/SessionFormation.php @@ -74,7 +74,7 @@ class Class_SessionFormation extends Storm_Model_Abstract { * @return bool */ public function isInscriptionClosed() { - if (strtotime($this->getDateDebut()) <self::getTimeSource()->dateYmd()) + if (strtotime($this->getDateDebut()) < strtotime(self::getTimeSource()->dateYmd())) return true; if ($this->isAnnule()) diff --git a/library/ZendAfi/View/Helper/Abonne/Formations.php b/library/ZendAfi/View/Helper/Abonne/Formations.php index 03bf4107cf7..894df175ff3 100644 --- a/library/ZendAfi/View/Helper/Abonne/Formations.php +++ b/library/ZendAfi/View/Helper/Abonne/Formations.php @@ -38,7 +38,7 @@ class ZendAfi_View_Helper_Abonne_Formations extends ZendAfi_View_Helper_Abonne_A foreach ($user->getSessionFormations() as $session) { $html .= sprintf('<li><a href="%s">%s, %s</li>', $this->view->url(['controller' => 'abonne', - 'action' => 'detail_session', + 'action' => 'detail-session', 'id' => $session->getId(), 'retour' => 'fiche'], null, diff --git a/library/ZendAfi/View/Helper/TagSessionFormationInscription.php b/library/ZendAfi/View/Helper/TagSessionFormationInscription.php index 901a2f3480e..f9555b41504 100644 --- a/library/ZendAfi/View/Helper/TagSessionFormationInscription.php +++ b/library/ZendAfi/View/Helper/TagSessionFormationInscription.php @@ -39,8 +39,8 @@ class ZendAfi_View_Helper_TagSessionFormationInscription extends Zend_View_Helpe if ($is_inscrit) - $content = $this->view->tagAnchor(array('action' => 'desinscrire_session', - 'id' => $session->getId()), + $content = $this->view->tagAnchor(['action' => 'desinscrire-session', + 'id' => $session->getId()], $this->view->_("Se désinscrire")); if ($session->isFull()) @@ -50,8 +50,8 @@ class ZendAfi_View_Helper_TagSessionFormationInscription extends Zend_View_Helpe if ($is_inscrit) return $content; - $link_inscription = $this->view->tagAnchor(array('action' => 'inscrire_session', - 'id' => $session->getId()), + $link_inscription = $this->view->tagAnchor(['action' => 'inscrire-session', + 'id' => $session->getId()], $this->view->_("S'inscrire")); if (!$session->hasDateLimiteInscription()) diff --git a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php index 6fc0b622617..fd2d7536f5d 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php @@ -45,145 +45,147 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro public function setUp() { parent::setUp(); + $test_time = new TimeSourceForTest('2014-05-01 14:00:00'); + + Class_Users::beVolatile(); + Class_SessionFormation::beVolatile(); + Class_SessionFormationInscription::beVolatile(); + Class_Formation::beVolatile(); + + Class_Formation::setTimeSource($test_time); + Class_SessionFormation::setTimeSource($test_time); + Class_AdminVar::getLoader() ->newInstanceWithId('FORMATIONS') ->setValeur('1'); - $this->_gallice_cafe = Class_Lieu::getLoader() - ->newInstanceWithId(98) - ->setLibelle('Gallice'); - - $this->_bib_romains = Class_Lieu::getLoader() - ->newInstanceWithId(99) - ->setLibelle('Bibliothèque des romains'); - - $this->_bonlieu = Class_Lieu::getLoader() - ->newInstanceWithId(100) - ->setLibelle('Bonlieu') - ->setAdresse("1, rue Jean-Jaures\nBP 294") - ->setCodePostal(74007) - ->setVille('Annecy') - ->setLatitude('45.902179') - ->setLongitude('6.128715'); - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') - ->whenCalled('save')->answers(true); - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_SessionFormation') - ->whenCalled('save')->answers(true); - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Formation') - ->whenCalled('save')->answers(true) - ->whenCalled('findAll')->answers(array( - $this->_learn_smalltalk = Class_Formation::getLoader() - ->newInstanceWithId(1) - ->setLibelle('Learn Smalltalk') - ->setSessions(array( - $this->_session_smalltalk_janvier = Class_SessionFormation::getLoader() - ->newInstanceWithId(11) - ->setFormationId(1) - ->setEffectifMin(1) - ->setEffectifMax(10) - ->setStagiaires(array()) - ->setLieu($this->_gallice_cafe) - ->setDateDebut('2009-01-17'), - - - $this->_session_smalltalk_juillet = Class_SessionFormation::getLoader() - ->newInstanceWithId(12) - ->setFormationId(1) - ->setEffectifMin(1) - ->setEffectifMax(10) - ->setStagiaires(array()) - ->setLieu($this->_gallice_cafe) - ->setDateDebut('2023-07-12') - )), - - $this->_learn_java = Class_Formation::getLoader() - ->newInstanceWithId(3) - ->setLibelle('Learn Java') - ->setDescription('If you want to') - ->setSessions(array( $this->_session_java_mars = Class_SessionFormation::getLoader() - ->newInstanceWithId(32) - ->setFormationId(3) - ->setDateDebut('2022-03-27') //Pour toi, cher développeur de 2022 :) - ->setStagiaires(array()) - ->setDateLimiteInscription('2009-02-15'), - - $this->_session_java_fevrier = Class_SessionFormation::getLoader() - ->newInstanceWithId(31) - ->setFormationId(3) - ->setEffectifMin(2) - ->setEffectifMax(5) - ->setStagiaires(array()) - ->setLieu($this->_bonlieu) - ->setDateDebut('2022-02-17') - ->setDateFin('2022-02-19') - ->setDateLimiteInscription('2022-02-15'), - - - $this->_session_java_septembre = Class_SessionFormation::getLoader() - ->newInstanceWithId(30) - ->setFormationId(3) - ->setDateDebut('2022-09-27') - ->setStagiaires(array()) - ->setDateLimiteInscription('2022-02-15') - ->beAnnule() - )), - - $this->_learn_python = Class_Formation::getLoader() - ->newInstanceWithId(12) - ->setLibelle('Learn Python') - ->setSessions(array( $this->_session_python_juillet = Class_SessionFormation::getLoader() - ->newInstanceWithId(121) - ->setFormationId(12) - ->setDateDebut('2023-07-21') - ->setContenu('Introduction a la syntaxe') - ->setObjectif('Ecrire un premier programme') - ->setEffectifMin(5) - ->setEffectifMax(22) - ->setDuree(8) - ->setHoraires('8h-12h, 14h-18h') - ->setLieu($this->_bib_romains) - ->setIntervenants( array(Class_Users::getLoader() - ->newInstanceWithId(76) - ->setLogin('jpp') - ->setPrenom('Jean-Paul') - ->setNom('Pirant'), - - Class_Users::getLoader() - ->newInstanceWithId(77) - ->setLogin('cc') - ->setPrenom('Christophe') - ->setNom('Cerisier')) ) )) - )); - - $this->_amadou = Class_Users::getLoader() - ->newInstanceWithId('435') - ->setLogin('Amadou') - ->setPassword('123') - ->setRole('abonne_sigb') - ->setIdabon('435') - ->setSessionFormations(array($this->_session_python_juillet)) - ->setUserGroups(array(Class_UserGroup::getLoader() - ->newInstanceWithId(23) - ->addRightSuivreFormation())); - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_SessionFormationInscription') - ->whenCalled('save')->answers(true) - ->whenCalled('delete')->answers(true) - - ->whenCalled('findAllBy') - ->with(array('role' => 'stagiaire', - 'model' => $this->_amadou)) - ->answers(array($inscription_amadou_python = Class_SessionFormationInscription::getLoader() - ->newInstanceWithId(1) - ->setStagiaire($this->_amadou) - ->setSessionFormation($this->_session_python_juillet))) - ->whenCalled('findAllBy') - ->with(array('role' => 'session_formation', - 'model' => $this->_session_python_juillet)) - ->answers(array($inscription_amadou_python)); + $this->_amadou = $this->fixture('Class_Users', + ['id' => 435, + 'login' => 'Amadou', + 'password' => 'pwd', + 'id_abon' => 435]); + $this->_amadou + ->beAbonneSIGB() + ->setUserGroups([$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()]); + + ZendAfi_Auth::getInstance()->logUser($this->_amadou); + + $this->_gallice_cafe = $this->fixture('Class_Lieu', + ['id' => 98, + 'libelle' => 'Galice']); + + + $this->_bib_romains = $this->fixture('Class_Lieu', + ['id' => '99', + 'libelle' => 'Bibliothèque des romains']); + + + $this->_bonlieu = $this->fixture('Class_Lieu', + ['id' => 100, + 'libelle' => 'Bonlieu', + 'adresse' => "1, rue Jean-Jaures\nBP 294", + 'code_postal' => 74007, + 'ville' => 'Annecy', + 'latitude' => '45.902179', + 'longitude' => '6.128715']); + + $this->_session_smalltalk_janvier = $this->fixture('Class_SessionFormation', + ['id' => 11, + 'formation_id' => 1, + 'effectif_min' => 1, + 'effectif_max' => 10, + 'lieu' => $this->_gallice_cafe, + 'date_debut' => '2014-01-10']); + + $this->_session_smalltalk_juillet = $this->fixture('Class_SessionFormation', + ['id' => 12, + 'formation_id' => 1, + 'effectif_min' => 1, + 'effectif_max' => 10, + 'lieu' => $this->_gallice_cafe, + 'stagiaires' => [], + 'date_debut' => '2014-07-10']); + + $this->_learn_smalltalk = $this->fixture('Class_Formation', + ['id' => 1, + 'libelle' => 'Learn Smalltalk', + 'sessions' => [$this->_session_smalltalk_janvier, + $this->_session_smalltalk_juillet]]); + + $this->_session_java_fevrier = $this->fixture('Class_SessionFormation', + ['id' => 31, + 'formation_id' => 3, + 'effectif_min' => 2, + 'effectif_max' => 5, + 'lieu' => $this->_bonlieu, + 'date_debut' => '2015-02-10', + 'date_fin' => '2015-02-20', + 'stagiaires' => [], + 'date_limite_inscription' => '2015-01-20']); + + $this->_session_java_mars = $this->fixture('Class_SessionFormation', + ['id' => 32, + 'formation_id' => 3, + 'effectif_min' => 2, + 'effectif_max' => 5, + 'lieu' => $this->_gallice_cafe, + 'date_debut' => '2014-03-1', + 'stagiaires' => [], + 'date_limit_inscription' => '2014-03-1']); + + $this->_session_java_septembre = $this->fixture('Class_SessionFormation', + ['id' => 30, + 'formation_id' => 3, + 'date_debut' => '2014-09-1', + 'stagiaires' => [], + 'date_limit_inscription' => '2014-08-15']); + $this->_session_java_septembre->beAnnule(); + + $this->_learn_java = $this->fixture('Class_Formation', + ['id' => 3, + 'libelle' => 'Learn Java', + 'description' => 'whaaat ?', + 'sessions' => [$this->_session_java_mars, + $this->_session_java_septembre, + $this->_session_java_fevrier]]); + + $this->_session_python_juillet = $this->fixture('Class_SessionFormation', + ['id' => 121, + 'formation_id' => 12, + 'date_debut' => '2014-07-10', + 'contenu' => 'Introduction a la syntaxe', + 'objectif' => 'Ecrire un premier programme', + 'effectif_min' => 1, + 'effectif_max' => 150, + 'duree' => 36, + 'horaires' => '8h-12h, 14h-18h', + 'lieu' => $this->_bib_romains, + 'stagiaires' => [$this->_amadou], + 'intervenants' => [$this->fixture('Class_Users', + ['id' =>76, + 'login' => 'jpp', + 'password' => 'pwd', + 'nom' => 'Pirant', + 'prenom' => 'Jean-Paul']), + $this->fixture('Class_users', + ['id' => 77, + 'login' => 'cc', + 'password' => 'pwd', + 'nom' => 'Cerisier', + 'prenom' => 'Christophe']) + ]]); + + $this->_learn_python = $this->fixture('Class_Formation', + ['id' => 12, + 'libelle' => 'Learn Python', + 'sessions' => [$this->_session_python_juillet]]); + + $inscription_amadou_python = $this->fixture('Class_SessionFormationInscription', + ['id' => 1, + 'stagiaire' => $this->_amadou, + 'session_formation' => $this->_session_python_juillet]); + + $this->_amadou->setSessionFormationInscriptions([$inscription_amadou_python]); } } @@ -210,7 +212,7 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ function aDivForDescriptionShouldContainsIfYouWantTo() { - $this->assertXPathContentContains('//div', 'If you want to'); + $this->assertXPathContentContains('//div', 'whaaat ?'); } @@ -222,19 +224,19 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ function session_java_mars_ShouldNotHaveLinkForInscrireAsInscriptionClosed() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire_session/id/32")]'); + $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/32")]', $this->response->getBody()); } /** @test */ function session_java_septembre_ShouldNotHaveLinkForInscrireAsSessionAnnule() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire_session/id/30")]'); + $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/30")]'); } /** @test */ function session_janvier_smalltalk_ShouldNotHaveLinkForInscrireAsFinished() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire_session/id/11")]'); + $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/11")]'); } @@ -247,53 +249,54 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ function session_fevrier_17_ShouldBeDisplayedUnderLearnJavaInSecondPosition() { - $this->assertXPathContentContains('//tbody//tr[2]//td', '17 février 2022 au 19 février 2022', $this->_response->getBody()); + $this->assertXPathContentContains('//tbody//tr//td', '10 février 2015 au 20 février 2015'); } /** @test */ function session_fevrier_17_lieuBonlieuShouldBeDisplayed() { - $this->assertXPathContentContains('//tbody//tr[2]//td', 'Bonlieu'); + $this->assertXPathContentContains('//tbody//tr//td', 'Bonlieu'); } /** @test */ function session_fevrier_17_ShouldHaveLinkForInscrire() { - $this->assertXPathContentContains('//tbody//tr[2]//a[contains(@href, "abonne/inscrire_session/id/31")]', - "S'inscrire"); + $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/inscrire-session/id/31")]', + "S'inscrire", + $this->response->getBody()); } /** @test */ function session_fevrier_17_ShouldDisplayDateLimite15Fevrier() { - $this->assertXPathContentContains('//tbody//tr[2]', - "Limite: 15 février 2022"); + $this->assertXPathContentContains('//tbody//tr', + "Limite: 20 janvier 2015"); } /** @test */ function session_fevrier_17_ShouldHaveLinkForDetailSessionFormation() { - $this->assertXPathContentContains('//tbody//tr[2]//a[contains(@href, "abonne/detail_session/id/31")]', + $this->assertXPathContentContains('//tbody//tr//a[contains(@href, "abonne/detail-session/id/31")]', 'Détails de la session'); } /** @test */ function session_mars_27_ShouldBeDisplayedUnderLearnJavaInFirstPosition() { - $this->assertXPathContentContains('//tbody//tr[1]', '27 mars 2022'); + $this->assertXPathContentContains('//tbody//tr', '01 mars 2014'); } /** @test */ function session_septembre_java_ShouldBeAnnule() { - $this->assertXPathContentContains('//tr//td[contains(text(), "Annul")]//span', '27 septembre 2022'); + $this->assertXPathContentContains('//tr//td[contains(text(), "Annul")]//span', '01 septembre 2014'); } /** @test */ function session_python_juillet_ShouldHaveLinkForDesinscrire() { - $this->assertXPathContentContains('//tr//a[contains(@href, "abonne/desinscrire_session/id/121")]', + $this->assertXPathContentContains('//tr//a[contains(@href, "abonne/desinscrire-session/id/121")]', "Se désinscrire"); } @@ -318,8 +321,7 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati /** @test */ public function barreNavShouldContainsAccueilThatLinksToProfilFourtyTwo() { $this->assertXPathContentContains('//div[@class="barre_nav"]//a[contains(@href, "index/index?id_profil=42")]', - 'Accueil', - $this->_response->getBody()); + 'Accueil'); } } @@ -340,13 +342,13 @@ class AbonneControllerFormationsFicheAbonneTest extends AbstractAbonneController /** @test */ public function pageShouldContainsVousEtesInscritFormationPython() { - $this->assertXPathContentContains('//ul//li', 'Learn Python, 21 juillet 2023'); + $this->assertXPathContentContains('//ul//li', 'Learn Python, 10 juillet 2014'); } /** @test */ public function pageShouldContainsLinkToDetailSessionPyhton() { - $this->assertXPath('//li//a[contains(@href, "abonne/detail_session/id/121/retour/fiche")]'); + $this->assertXPath('//li//a[contains(@href, "abonne/detail-session/id/121/retour/fiche")]'); } } @@ -385,13 +387,13 @@ class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends Abst /** @test */ function linkForInscrireShouldNotExists() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire_session")]'); + $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session")]'); } /** @test */ function linkForDesinscrireShouldNotExists() { - $this->assertNotXPath('//a[contains(@href, "abonne/desinscrire_session")]'); + $this->assertNotXPath('//a[contains(@href, "abonne/desinscrire-session")]'); } @@ -405,30 +407,29 @@ class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends Abst class AbonneControllerFormationsAmadouInscritSessionMarsJavaClosedTest extends AbstractAbonneControllerFormationsTestCase { /** @test */ public function inscrireSessionShouldNotCallSave() { - $this->dispatch('/opac/abonne/inscrire_session/id/32'); - $this->assertFalse(Class_SessionFormationInscription::getLoader()->methodHasBeenCalled('save')); + $this->dispatch('/opac/abonne/inscrire-session/id/32'); + $this->assertNotContains($this->_amadou, Class_SessionFormationInscription::findAllBy(['session_formation_id'=>32])); } } -class AbonneControllerFormationsAmadouInscritSessionMarsJavaOpenTest extends AbstractAbonneControllerFormationsTestCase { +class AbonneControllerFormationsAmadouInscritSessionFeebruaryJavaOpenTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); - $this->_session_java_mars->setDateLimiteInscription('2022-03-05'); - $this->dispatch('/opac/abonne/inscrire_session/id/32'); + $this->dispatch('/opac/abonne/inscrire-session/id/31'); } /** @test */ public function sessionJavaMarsShouldBeValid() { - $this->assertTrue($this->_session_java_mars->isValid(), - implode(',', $this->_session_java_mars->getErrors())); + $this->assertTrue($this->_session_java_fevrier->isValid(), + implode(',', $this->_session_java_fevrier->getErrors())); } /** @test */ - function amadouShouldBeInsessionMarsJavaStagiaires() { - $this->assertContains($this->_amadou, $this->_session_java_mars->getStagiaires()); + function amadouShouldBeInsessionSeptembreJavaStagiaires() { + $this->assertContains($this->_amadou, $this->_session_java_fevrier->getStagiaires()); } @@ -440,9 +441,8 @@ class AbonneControllerFormationsAmadouInscritSessionMarsJavaOpenTest extends Abs /** @test */ function aNewInscriptionShouldHaveBeenCreated() { - $inscription = Class_SessionFormationInscription::getLoader()->getFirstAttributeForLastCallOn('save'); - $this->assertEquals(32, $inscription->getSessionFormationId()); - $this->assertEquals(435, $inscription->getStagiaireId()); + $this->assertCount(1, Class_SessionFormationInscription::findAllBy(['stagiaire_id' => 435, + 'session_formation_id' => 31])); } } @@ -476,13 +476,13 @@ class AbonneControllerFormationsSessionJavaFevrierFullListTest extends AbonneCon /** @test */ function session_fevrier_17_ShouldNotHaveLinkForInscrire() { - $this->assertNotXPath('//a[contains(@href, "abonne/inscrire_session/id/31")]'); + $this->assertNotXPath('//a[contains(@href, "abonne/inscrire-session/id/31")]'); } /** @test */ public function sessionShouldDisplayFull() { - $this->assertXPathContentContains('//tbody//tr[2]//span', 'Effectif maximum atteint'); + $this->assertXPathContentContains('//tbody//tr//span', 'Effectif maximum atteint'); } } @@ -495,7 +495,7 @@ class AbonneControllerFormationsSessionJavaFevrierFullAndInscritListTest extends $this->_session_java_fevrier->addStagiaire($this->_amadou); $this->_amadou->setSessionFormations(array($this->_session_java_fevrier)); $this->dispatch('/opac/abonne/formations'); - $this->assertXPath('//a[contains(@href, "abonne/desinscrire_session/id/31")]', $this->_response->getBody()); + $this->assertXPath('//a[contains(@href, "abonne/desinscrire-session/id/31")]'); } } @@ -504,18 +504,18 @@ class AbonneControllerFormationsSessionJavaFevrierFullAndInscritListTest extends class AbonneControllerFormationsAmadouInscritSessionJavaFevrierFullTest extends AbonneControllerFormationsSessionJavaFevrierFullTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/inscrire_session/id/31'); + $this->dispatch('/opac/abonne/inscrire-session/id/31'); } /** @test */ - public function sessionShouldNotHaveBeenSaved() { - $this->assertFalse(Class_SessionFormation::getLoader()->methodHasBeenCalled('save')); + public function sessionShouldNotContainsAmadou() { + $this->assertNotContains('Amadou', Class_SessionFormation::find(31)->getStagiaires()); } /** @test */ public function userShouldNotHaveBeenSaved() { - $this->assertFalse(Class_Users::getLoader()->methodHasBeenCalled('save')); + $this->assertEmpty(Class_Users::findAllBy(['session_formations' => 31])); } } @@ -525,14 +525,15 @@ class AbonneControllerFormationsAmadouInscritSessionJavaFevrierFullTest extends class AbonneControllerFormationsInscritSessionWithoutRightSuivreFormationTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); - $this->_amadou->setUserGroups(array()); - $this->dispatch('/opac/abonne/inscrire_session/id/32'); + $this->_amadou->setUserGroups([]); + $this->dispatch('/opac/abonne/inscrire-session/id/32'); } + /** @test */ - public function noInscriptionShouldBeSaved() { - $this->assertFalse(Class_SessionFormationInscription::getLoader()->methodHasBeenCalled('save')); + public function sessionShouldNotContainsAmadou() { + $this->assertNotContains('Amadou', Class_SessionFormation::find(31)->getStagiaires()); } @@ -548,7 +549,7 @@ class AbonneControllerFormationsInscritSessionWithoutRightSuivreFormationTest ex class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/desinscrire_session/id/121'); + $this->dispatch('/opac/abonne/desinscrire-session/id/121'); } /** @test */ @@ -565,7 +566,7 @@ class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends /** @test */ function inscriptionObjectShouldHaveBeenDeleted() { - $inscription = Class_SessionFormationInscription::getLoader()->getFirstAttributeForLastCallOn('delete'); + $inscription = Class_SessionFormationInscription::find(1); $this->assertEquals(121, $inscription->getSessionFormationId()); $this->assertEquals(435, $inscription->getStagiaireId()); } @@ -577,13 +578,13 @@ class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/detail_session/id/31'); + $this->dispatch('/opac/abonne/detail-session/id/31', true); } /** @test */ public function pageShouldContainsLinkToInscrire() { - $this->assertXPathContentContains('//a[contains(@href, "abonne/inscrire_session/id/31")]', + $this->assertXPathContentContains('//a[contains(@href, "abonne/inscrire-session/id/31")]', 'S\'inscrire'); } @@ -604,8 +605,7 @@ class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneCon /** @test */ 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"]', - $this->_response->getBody()); + $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"]'); } } @@ -616,18 +616,18 @@ class AbonneControllerFormationsSessionFevrierJavaTest extends AbstractAbonneCon class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/detail_session/id/121'); + $this->dispatch('/opac/abonne/detail-session/id/121'); } /** @test */ public function actionShouldBeDetailSession() { - $this->assertAction('detail_session'); + $this->assertAction('detail-session'); } /** @test */ public function titleShouldBeFormationLearnPython_SessionDu21Juillet2023() { - $this->assertXPathContentContains('//h1[contains(text(), "Learn Python")]//span', '21 juillet 2023'); + $this->assertXPathContentContains('//h1[contains(text(), "Learn Python")]//span', '10 juillet 2014'); } @@ -639,7 +639,7 @@ class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractA /** @test */ public function pageShouldContainsLinkToDesinscrire() { - $this->assertXPathContentContains('//a[contains(@href, "abonne/desinscrire_session/id/121")]', + $this->assertXPathContentContains('//a[contains(@href, "abonne/desinscrire-session/id/121")]', 'Se désinscrire'); } @@ -652,12 +652,12 @@ class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractA /** @test */ public function ddShouldContainsNombreDeParticipants() { - $this->assertXPathContentContains('//dl/dd', 'minimum: 5, maximum: 22, actuel: 1'); + $this->assertXPathContentContains('//dl/dd', 'minimum: 1, maximum: 150, actuel: 1'); } /** @test */ public function ddShouldContainsDuree() { - $this->assertXPathContentContains('//dl/dd', '8 h'); + $this->assertXPathContentContains('//dl/dd', '36 h'); } @@ -691,7 +691,7 @@ class AbonneControllerFormationsSessionJuilletPythonDetailTest extends AbstractA class AbonneControllerFormationsSessionJuilletPythonDetailRetourFicheTest extends AbstractAbonneControllerFormationsTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/detail_session/id/121/retour/fiche'); + $this->dispatch('/opac/abonne/detail-session/id/121/retour/fiche'); } /** @test */ @@ -707,21 +707,21 @@ class AbonneControllerFormationsSessionJuilletPythonDetailRetourFicheTest extend class AbonneControllerFormationsWrongIdsTest extends AbstractAbonneControllerFormationsTestCase { /** @test */ public function onDetailSessionShouldRedirectToFormations() { - $this->dispatch('/opac/abonne/detail_session/id/9999'); + $this->dispatch('/opac/abonne/detail-session/id/9999'); $this->assertRedirectTo('/abonne/formations'); } /** @test */ public function onInscrireSessionShouldRedirectToFormations() { - $this->dispatch('/opac/abonne/inscrire_session/id/9999'); + $this->dispatch('/opac/abonne/inscrire-session/id/9999'); $this->assertRedirectTo('/abonne/formations'); } /** @test */ public function ondesinscrireSessionShouldRedirectToFormations() { - $this->dispatch('/opac/abonne/desinscrire_session/id/9999'); + $this->dispatch('/opac/abonne/desinscrire-session/id/9999'); $this->assertRedirectTo('/abonne/formations'); } -- GitLab