diff --git a/VERSIONS_WIP/49273 b/VERSIONS_WIP/49273 new file mode 100644 index 0000000000000000000000000000000000000000..081d24bac5eb3e95e4c5f808634fc0e193d6c25c --- /dev/null +++ b/VERSIONS_WIP/49273 @@ -0,0 +1 @@ + - ticket #49273 : 21/55 Inscription à une formation : envoi d'un mail \ No newline at end of file diff --git a/application/modules/admin/controllers/SystemeController.php b/application/modules/admin/controllers/SystemeController.php index 45f2a2b185b0031c68d476b56da9ba9e9e33dfba..490cf70fea3c6f1acca5cdd9ebcdbfdbfe190b6d 100644 --- a/application/modules/admin/controllers/SystemeController.php +++ b/application/modules/admin/controllers/SystemeController.php @@ -291,7 +291,7 @@ class Admin_SystemeController extends Zend_Controller_Action { $mail ->setFrom($this->_request->getPost('sender')) ->addTo($this->_request->getPost('recipient')) - ->setSubject('[AFI-OPAC2.0] test envoi mails') + ->setSubject('[Bokeh] test envoi mails') ->setBodyText('Envoyé depuis '.BASE_URL) ->send(); diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index c606244a503efe71e518301bcb8ca888f5d37de2..e7714285214cbb8cb21c869fcdc5e45b63c1e340 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -67,36 +67,38 @@ class AbonneController extends ZendAfi_Controller_Action { public function inscrireSessionAction() { - if (($session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) && - !$session->isInscriptionClosed()) { - $session->addStagiaire($this->_user); + $this->_redirect('/formations'); - if (!$session->save()) - $this->_helper->notify(implode('<br/>', $session->getErrors())); - else - $this->_helper->notify(sprintf('Vous êtes inscrit à la session du %s de la formation %s', - $this->view->humanDate($session->getDateDebut(), 'd MMMM YYYY'), - $session->getLibelleFormation())); - } else { - $this->_helper->notify('L\'inscription à cette session est fermée'); - } + if ((!$session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) + || $session->isInscriptionClosed()) + return $this->_helper->notify($this->_('L\'inscription à cette session est fermée')); - $this->_redirect('/formations'); + $session->addStagiaire($this->_user); + if (!$session->save()) + return $this->_helper->notify(implode('<br/>', $session->getErrors())); + + (new Class_Formation_RegistrationMail($session, $this->_user))->send(); + + $this->_helper->notify($this->_('Vous êtes inscrit à la session du %s de la formation %s', + $this->view->humanDate($session->getDateDebut(), 'd MMMM YYYY'), + $session->getLibelleFormation())); } public function desinscrireSessionAction() { if (!$session = Class_SessionFormation::getLoader()->find((int)$this->_getParam('id'))) { - $this->_helper->notify('Session non trouvée'); + $this->_helper->notify($this->_('Session non trouvée')); $this->_redirect('/formations'); return; } $this->_user->removeSessionFormation($session); if ($this->_user->save()) { - $this->_helper->notify(sprintf('Vous n\'êtes plus inscrit à la session du %s de la formation %s', + $this->_helper->notify($this->_('Vous n\'êtes plus inscrit à la session du %s de la formation %s', $this->view->humanDate($session->getDateDebut(), 'd MMMM YYYY'), $session->getLibelleFormation())); + + (new Class_Formation_UnregistrationMail($session, $this->_user))->send(); }; $this->_redirect('/formations'); @@ -106,15 +108,15 @@ class AbonneController extends ZendAfi_Controller_Action { public function subscribeNewsletterAction() { $this->_stayOnPage(); if (!$newsletter = Class_Newsletter::find((int)$this->_getParam('id'))) { - $this->_helper->notify('Newsletter non trouvée'); + $this->_helper->notify($this->_('Newsletter non trouvée')); return; } $this->_user->addNewsletter($newsletter); if ($this->_user->save()) { - $this->_helper->notify(sprintf('Vous êtes inscrit à la liste de diffusion: %s', - $newsletter->getTitre())); + $this->_helper->notify($this->_('Vous êtes inscrit à la liste de diffusion: %s', + $newsletter->getTitre())); }; } @@ -122,7 +124,7 @@ class AbonneController extends ZendAfi_Controller_Action { public function unsubscribeNewsletterAction() { $this->_stayOnPage(); if (!$newsletter = Class_Newsletter::find((int)$this->_getParam('id'))) { - $this->_helper->notify('Newsletter non trouvée'); + $this->_helper->notify($this->_('Newsletter non trouvée')); return; } @@ -130,8 +132,8 @@ class AbonneController extends ZendAfi_Controller_Action { $this->_user->unsubscribeNewsletter($newsletter); if ($this->_user->save()) { - $this->_helper->notify(sprintf('Vous êtes désinscrit de la liste de diffusion: %s', - $newsletter->getTitre())); + $this->_helper->notify($this->_('Vous êtes désinscrit de la liste de diffusion: %s', + $newsletter->getTitre())); }; } diff --git a/library/Class/Formation/AbstractMail.php b/library/Class/Formation/AbstractMail.php new file mode 100644 index 0000000000000000000000000000000000000000..cdd0a2c1d9937219ec34a210dd14dc5165785506 --- /dev/null +++ b/library/Class/Formation/AbstractMail.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright (c) 2012-2014, 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 + */ + + +abstract class Class_Formation_AbstractMail { + use Trait_Translator; + + protected + $_training_session, + $_subscriber; + + public function __construct($session, $user) { + $this->_training_session = $session; + $this->_subscriber = $user; + } + + + public function send() { + return $this + ->_sendMailToSubscriber() + ->_sendMailToTeachers(); + } + + + protected function _getSessionUrl() { + return Class_Url::absolute(['controller' => 'formations', + 'action' => 'detail-session', + 'id' => $this->_training_session->getId()], + null, + true); + } + + + protected function _getEditUserUrl() { + return Class_Url::absolute(['module' => 'admin', + 'controller' => 'users', + 'action' => 'edit', + 'id' => $this->_subscriber->getId()], + null, + true); + } + + + protected function _getSubscriberMailInfo() { + return ($this->_subscriber->hasMail() + ? $this->_subscriber->getMail() + : $this->_('non renseigné')); + } + + + protected function _sendMail($recipients, $subject, $body) { + if (!$recipients = array_filter($recipients)) + return $this; + $mail = new ZendAfi_Mail('utf8'); + + foreach($recipients as $recipient) + $mail->addTo($recipient); + + $mail + ->setFrom('no-reply@' . Class_AdminVar::get('NOM_DOMAINE')) + ->setSubject($subject) + ->setBodyHtml($body) + ->send(); + + return $this; + } + + + protected function _sendMailToSubscriber() { + return $this->_sendMail([$this->_subscriber->getMail()], + $this->_getSubscriberSubject(), + $this->_getSubscriberBody()); + } + + + protected function _sendMailToTeachers() { + $recipients = (new Storm_Model_Collection($this->_training_session->getIntervenants())) + ->collect('mail') + ->getArrayCopy(); + + return $this->_sendMail($recipients, + $this->_getTeachersSubject(), + $this->_getTeachersBody()); + } + + + abstract protected function _getSubscriberSubject(); + + + abstract protected function _getSubscriberBody(); + + + abstract protected function _getTeachersSubject(); + + + abstract protected function _getTeachersBody(); + +} +?> \ No newline at end of file diff --git a/library/Class/Formation/RegistrationMail.php b/library/Class/Formation/RegistrationMail.php new file mode 100644 index 0000000000000000000000000000000000000000..da3b55618eafbb35c9b730209fa2032f9ee22ebc --- /dev/null +++ b/library/Class/Formation/RegistrationMail.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright (c) 2012-2014, 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 Class_Formation_RegistrationMail extends Class_Formation_AbstractMail { + protected function _getSubscriberSubject() { + return $this->_('Confirmation d\'inscription à la formation "%s"', + $this->_training_session->getLibelleFormation()); + } + + + protected function _getSubscriberBody() { + return $this->_('Bonjour,<br><br>nous vous confirmons votre inscription à la formation <a href="%s">"%s"</a>', + $this->_getSessionUrl(), + $this->_training_session->getLibelleFormation()); + } + + + protected function _getTeachersSubject() { + return $this->_('Nouvelle inscription à la formation "%s"', + $this->_training_session->getLibelleFormation()); + } + + + protected function _getTeachersBody() { + return $this->_('L\'usager <a href="%s">%s (courriel: %s)</a> vient de s\'inscrire à la formation <a href="%s">%s</a>', + $this->_getEditUserUrl(), + $this->_subscriber->getNomComplet(), + $this->_getSubscriberMailInfo(), + $this->_getSessionUrl(), + $this->_training_session->getLibelleFormation()); + } + +} +?> \ No newline at end of file diff --git a/library/Class/Formation/UnregistrationMail.php b/library/Class/Formation/UnregistrationMail.php new file mode 100644 index 0000000000000000000000000000000000000000..ea4bb5ed944020339a5efd4fb96760f8750dde1d --- /dev/null +++ b/library/Class/Formation/UnregistrationMail.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright (c) 2012-2014, 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 Class_Formation_UnregistrationMail extends Class_Formation_AbstractMail { + protected function _getSubscriberSubject() { + return $this->_('Confirmation de désinscription à la formation "%s"', + $this->_training_session->getLibelleFormation()); + } + + + protected function _getSubscriberBody() { + return $this->_('Bonjour,<br><br>nous vous confirmons que vous n\'êtes plus inscrit à la formation <a href="%s">"%s"</a>', + $this->_getSessionUrl(), + $this->_training_session->getLibelleFormation()); + } + + + protected function _getTeachersSubject() { + return $this->_('Désinscription de la formation "%s"', + $this->_training_session->getLibelleFormation()); + } + + + protected function _getTeachersBody() { + return $this->_('L\'usager <a href="%s">%s (courriel: %s)</a> s\'est désinscrit de la formation <a href="%s">%s</a>', + $this->_getEditUserUrl(), + $this->_subscriber->getNomComplet(), + $this->_getSubscriberMailInfo(), + $this->_getSessionUrl(), + $this->_training_session->getLibelleFormation()); + } +} +?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/SystemeControllerTest.php b/tests/application/modules/admin/controllers/SystemeControllerTest.php index 817a09fe348f60c9326c6df722bbe4f72299cb56..54f50c5a7db317decefec2618e8acff403edfd76 100644 --- a/tests/application/modules/admin/controllers/SystemeControllerTest.php +++ b/tests/application/modules/admin/controllers/SystemeControllerTest.php @@ -96,7 +96,7 @@ class SystemeControllerPostMailActionTest extends Admin_AbstractControllerTestCa /** @test */ public function subjectShouldBeTestMailDepuisOPAC() { - $this->assertEquals('[AFI-OPAC2.0] test envoi mails', $this->_mail->getSubject()); + $this->assertEquals('[Bokeh] test envoi mails', $this->_mail->getSubject()); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php index f2cbed496641ce3ea6f9442fa93f260c616e2cb6..de283d41216d91642241ae53a4261cd7b3047dc0 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFormationsTest.php @@ -18,55 +18,54 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once 'AbstractControllerTestCase.php'; - abstract class AbstractAbonneControllerFormationsTestCase extends AbstractControllerTestCase { - protected $_amadou; - protected $_learn_java; - protected $_learn_python; - protected $_learn_smalltalk; - protected $_session_smalltalk_janvier; - protected $_session_smalltalk_juillet; - protected $_session_java_mars; - protected $_session_java_fevrier; - protected $_session_java_septembre; - protected $_session_python_juillet; - protected $_gallice_cafe; - protected $_bib_romains; - protected $_bonlieu; - - protected function _loginHook($account) { - $account->ROLE = "abonne_sigb"; - $account->ROLE_LEVEL = 2; - $account->ID_USER = '435'; - $account->PSEUDO = "Amadou"; - } + protected + $_storm_default_to_volatile = true, + $_amadou, + $_learn_java, + $_learn_python, + $_learn_smalltalk, + $_session_smalltalk_janvier, + $_session_smalltalk_juillet, + $_session_java_mars, + $_session_java_fevrier, + $_session_java_septembre, + $_session_python_juillet, + $_gallice_cafe, + $_bib_romains, + $_bonlieu, + $_mail_transport; + 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'); + Class_AdminVar::set('FORMATIONS', '1'); + Class_AdminVar::set('NOM_DOMAINE', 'bokeh.fr'); + + $this->_mail_transport = new MockMailTransport(); + Zend_Mail::setDefaultTransport($this->_mail_transport); $this->_amadou = $this->fixture('Class_Users', ['id' => 435, + 'nom' => 'Dou', + 'prenom' => 'Ama', 'login' => 'Amadou', 'password' => 'pwd', - 'id_abon' => 435]); + 'mail' => 'amadou@afi-sa.fr', + 'bib' => $this->fixture('Class_Bib', + ['id' => 1, + 'libelle' => 'annecy']), + 'idabon' => 435]); $this->_amadou ->beAbonneSIGB() - ->setUserGroups([$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()]); + ->setUserGroups([$this->fixture('Class_UserGroup',['id' => 23])->addRightSuivreFormation()]) + ->assertSave(); ZendAfi_Auth::getInstance()->logUser($this->_amadou); @@ -167,13 +166,15 @@ abstract class AbstractAbonneControllerFormationsTestCase extends AbstractContro 'login' => 'jpp', 'password' => 'pwd', 'nom' => 'Pirant', - 'prenom' => 'Jean-Paul']), + 'prenom' => 'Jean-Paul', + 'mail' => 'jp@bokeh.fr']), $this->fixture('Class_users', ['id' => 77, 'login' => 'cc', 'password' => 'pwd', 'nom' => 'Cerisier', - 'prenom' => 'Christophe']) + 'prenom' => 'Christophe', + 'mail' => 'cc@bokeh.fr']) ]]); $this->_learn_python = $this->fixture('Class_Formation', @@ -506,19 +507,46 @@ class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends Abst class AbonneControllerFormationsAmadouInscritSessionMarsJavaClosedTest extends AbstractAbonneControllerFormationsTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/inscrire-session/id/32'); + } + + /** @test */ public function inscrireSessionShouldNotCallSave() { - $this->dispatch('/opac/abonne/inscrire-session/id/32'); $this->assertNotContains($this->_amadou, Class_SessionFormationInscription::findAllBy(['session_formation_id'=>32])); } + + + /** @test */ + public function responseShouldRedirectToFormations() { + $this->assertRedirectTo('/formations'); + } + + + /** @test */ + public function notificationShouldContainsSessionClosed() { + $this->assertFlashMessengerContentContains('cette session est fermée'); + } } -class AbonneControllerFormationsAmadouInscritSessionFeebruaryJavaOpenTest extends AbstractAbonneControllerFormationsTestCase { +class AbonneControllerFormationsAmadouInscritSessionFebruaryJavaOpenTest extends AbstractAbonneControllerFormationsTestCase { + protected + $_mails; + public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/inscrire-session/id/31'); + + $this->_session_java_fevrier + ->setIntervenants($this->_session_python_juillet + ->getIntervenants())->save(); + + $this->dispatch('/opac/abonne/inscrire-session/id/31', true); + + $this->_mails = $this->_mail_transport->getSentMails(); } @@ -546,6 +574,124 @@ class AbonneControllerFormationsAmadouInscritSessionFeebruaryJavaOpenTest extend $this->assertCount(1, Class_SessionFormationInscription::findAllBy(['stagiaire_id' => 435, 'session_formation_id' => 31])); } + + + /** @test */ + public function twoMailsShouldHaveBeenSent() { + $this->assertCount(2, $this->_mails); + } + + + /** @test */ + public function firstMailRecipientShouldBeAmadouAtAfi() { + $this->assertEquals(['amadou@afi-sa.fr'], $this->_mails[0]->getRecipients()); + } + + + /** @test */ + public function firtMailFromShouldBeNoReplyAtBokeh() { + $this->assertEquals('no-reply@bokeh.fr', $this->_mails[0]->getFrom()); + } + + + /** @test */ + public function firstMailSubjectShouldBeRegistrationConfirmation() { + $this->assertEquals('Confirmation d\'inscription à la formation "Learn Java"', + $this->_mails[0]->getSubject()); + } + + + /** @test */ + public function firstMailBodyShouldBeWeConfirm() { + $this->assertContains('nous vous confirmons', + $this->_mails[0]->getBodyHtml(true)); + } + + + /** @test */ + public function firstMailBodyShouldContainsUrlToDetailSession() { + $this->assertContains('http://localhost' . BASE_URL . '/formations/detail-session/id/31"', + $this->_mails[0]->getBodyHtml(true)); + } + + + /** @test */ + public function secondMailRecipientsShouldContainsTeachersJpAndCC() { + $this->assertEquals(['jp@bokeh.fr', 'cc@bokeh.fr'], + $this->_mails[1]->getRecipients()); + } + + + /** @test */ + public function secondMailFromShouldBeNoReplyAtBokeh() { + $this->assertEquals('no-reply@bokeh.fr', $this->_mails[1]->getFrom()); + } + + + /** @test */ + public function secondMailSubjectShouldBeNewRegistration() { + $this->assertEquals('Nouvelle inscription à la formation "Learn Java"', + $this->_mails[1]->getSubject()); + } + + + /** @test */ + public function secondMailContentShouldBeUserHaveJustRegistered() { + $this->assertEquals('L\'usager <a href="http://localhost' . BASE_URL .'/admin/users/edit/id/435">Ama Dou (courriel: amadou@afi-sa.fr)</a> vient de s\'inscrire à la formation <a href="http://localhost' . BASE_URL . '/formations/detail-session/id/31">Learn Java</a>', + quoted_printable_decode($this->_mails[1]->getBodyHtml(true))); + } +} + + + + +class AbonneControllerFormationsAmadouWithoutMailInscritSessionFebruaryJavaOpenTest extends AbstractAbonneControllerFormationsTestCase { + protected + $_mails; + + public function setUp() { + parent::setUp(); + + $this->_session_java_fevrier + ->addIntervenant($this->fixture('Class_Users', + ['id' =>78, + 'login' => 'pat', + 'password' => 'bator', + 'nom' => 'Bator', + 'prenom' => 'Pat', + 'mail' => 'pat@bat.org'])) + ->addIntervenant($this->fixture('Class_Users', + ['id' =>79, + 'login' => 'captain', + 'password' => 'flam', + 'nom' => 'flam', + 'prenom' => 'captaim']))->save(); + + $this->_amadou->setMail('')->save(); + + $this->dispatch('/opac/abonne/inscrire-session/id/31', true); + + $this->_mails = $this->_mail_transport->getSentMails(); + } + + + /** @test */ + public function oneMailShouldHaveBeenSent() { + $this->assertCount(1, $this->_mails); + } + + + /** @test */ + public function mailRecipientShouldEqualsPatAtBatDotOr() { + $this->assertEquals(['pat@bat.org'], $this->_mails[0]->getRecipients()); + } + + + /** @test */ + public function mailShouldContainsCourrielNotProvided() { + $this->assertContains('(courriel: non renseigné)', + quoted_printable_decode($this->_mails[0]->getBodyHtml(true))); + } } @@ -647,9 +793,13 @@ class AbonneControllerFormationsInscritSessionWithoutRightSuivreFormationTest ex class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends AbstractAbonneControllerFormationsTestCase { + protected $_mails; + public function setUp() { parent::setUp(); - $this->dispatch('/opac/abonne/desinscrire-session/id/121'); + $this->dispatch('/opac/abonne/desinscrire-session/id/121', true); + + $this->_mails = $this->_mail_transport->getSentMails(); } /** @test */ @@ -670,6 +820,47 @@ class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest extends $this->assertEquals(121, $inscription->getSessionFormationId()); $this->assertEquals(435, $inscription->getStagiaireId()); } + + + /** @test */ + public function flashMessengerShouldContainsUnregisterNotification() { + $this->assertFlashMessengerContentContains('Vous n\'êtes plus inscrit'); + } + + + /** @test */ + public function firstMailRecipientShouldBeAmadouAtAfi() { + $this->assertEquals(['amadou@afi-sa.fr'], $this->_mails[0]->getRecipients()); + } + + + /** @test */ + public function firstMailSubjectShouldContainsUnregistrationConfirmation() { + $this->assertEquals('Confirmation de désinscription à la formation "Learn Python"', + $this->_mails[0]->getSubject()); + } + + + /** @test */ + public function firstMailBodyShouldContainsUnregistrationConfirmation() { + $this->assertContains('vous n\'êtes plus inscrit à la formation', + quoted_printable_decode($this->_mails[0]->getBodyHtml(true))); + } + + + + /** @test */ + public function secondMailSubjectShouldBeUnregistration() { + $this->assertEquals('Désinscription de la formation "Learn Python"', + $this->_mails[1]->getSubject()); + } + + + /** @test */ + public function secondMailContentShouldBeUserHaveUnregistered() { + $this->assertEquals('L\'usager <a href="http://localhost' . BASE_URL .'/admin/users/edit/id/435">Ama Dou (courriel: amadou@afi-sa.fr)</a> s\'est désinscrit de la formation <a href="http://localhost' . BASE_URL . '/formations/detail-session/id/121">Learn Python</a>', + quoted_printable_decode($this->_mails[1]->getBodyHtml(true))); + } }