Newer
Older
$this->postDispatch('/',
['CAB' => '0007',
'PWD' => 'toto' ]);
}
/** @test */
public function responseShouldContainsError() {
$this->assertContains('error', $this->_response->getBody());
}
class AuthControllerPostSuccessfulFromLecturaClientTest extends AuthControllerLecturaTestCase {
$this->fixture('Class_Users', ['id' => 5 ,
'login' => '0007',
'idabon' => '0007',
'password' => 'toto']);
$this->_auth->whenCalled('authenticateLoginPassword')
->with('0007', 'toto')
->answers(true);
$this->postDispatch('/',
['CAB' => '0007',
'PWD' => 'toto' ]);
/** @test */
public function controllerShouldBeAuth() {
$this->assertEquals('auth',$this->_request->getControllerName());
}
/** @test */
public function actionShouldBeLogin() {
$this->assertEquals('login',$this->_request->getActionName());
}
public function responseShouldContainsSuccess() {
$this->assertContains('success', $this->_response->getBody());
}

efalcy
committed
class AuthControllerPostSuccessfulFromMusicMeCASClientTest extends AuthControllerPostSimpleSuccessfulTestCase {
public function setUp() {
parent::setUp();
RessourcesNumeriquesFixtures::activateMusicMe();
$this->postDispatch('/opac/auth/login',
['username' => 'foo',
'password' => 'bar',
'service' => 'http://musicme.com']);
}
/** @test */
public function responseShouldRedirectToMusicMeCasClientWithTicketAndBibId() {
$ticket='ST-'.md5(Zend_Session::getId(). '2');
$this->assertRedirectTo('http://musicmeurl/?iduser=foo&ticket='.$ticket.'&MediaLibraryID=888&service=http%3A%2F%2Fmusicmeurl%2F%3Fiduser%3Dfoo%26ticket%3D'.$ticket.'%26MediaLibraryID%3D888');
}
/** @test */
public function userFooMusicMeShouldBeLogged() {
$this->assertEquals('foo', Class_Users::getIdentity()->getLogin());
}

efalcy
committed
}
class AuthControllerFromCASClientUserConnectedTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->logUser(Class_Users::newInstanceWithId('22',['login'=> 'john']));
$this->dispatch('/auth/login?service=http://numilog.com/actionredirected');
}
/** @test */
public function responseShouldRedirectToCasClientServiceWithTicket() {
$this->assertRedirectTo('http://numilog.com/actionredirected?ticket=ST-'.md5(Zend_Session::getId().'22'));
}
/** @test */
public function userJohnShouldBeLogged() {
$this->assertEquals('john', Class_Users::getIdentity()->getLogin());
}
}
class AuthControllerPostSimpleFailureTest extends AuthControllerPostSimpleTestCase {
public function setup() {
parent::setup();
$_SERVER['HTTP_REFERER'] = '/opac';
/** @test */
public function withAuthenticationFailureResponseShouldBeRedirect() {
$this->postDispatch('/opac/auth/login',
['username' => 'foo', 'password' => 'bar']);
$this->assertRedirectTo('/opac');
}
class AuthControllerLoginActionRenderTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/auth/login',true);
}
/** @test */
public function authLoginShouldContainForm() {
$this->assertXPath('//form//fieldset[contains(@id, "fieldset-login_form")]');
}
/** @test */
public function authLoginTableShouldContainCaption() {
$this->assertXPath('//form//table/caption/details/summary');
}
class AuthControllerLoginActionWithDefaultPreferencesRenderTest extends AuthControllerNobodyLoggedTestCase {
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
public function setUp() {
parent::setUp();
$cfg_accueil = array('modules' => array(4 => array('division' => '4',
'id_module' => 4,
'type_module' => 'LOGIN',
'preferences' => array())));
Class_Profil::getCurrentProfil()
->setBrowser('opac')
->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil));
$this->dispatch('/opac/auth/login',true);
}
/** @test */
public function labelUserNameShouldContainIdentifiant() {
$this->assertXPathContentContains('//label','Identifiant');
}
/** @test */
public function inputPlaceholderUsernameShouldContainVotreIdentifiant() {
$this->assertXPath('//input[contains(@placeholder, "")]');
}
/** @test */
public function labelPasswordShouldContainMotDePasse() {
$this->assertXPathContentContains('//label','Mot de passe');
}
/** @test */
public function inputPlaceholderPasswordShouldContainVotreMotDePasse() {
$this->assertXPath('//input[contains(@placeholder, "")]');
}
/** @test */
public function linkConnectionShouldHaveOnclickAttributeWithSubmit() {
$this->assertXPath('//a[contains(@onclick, "submit")]');
}
class AuthControllerLostPasswordUnknownPostTest extends AbstractControllerTestCase{
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
public function setUp() {
parent::setUp();
}
/** @test */
public function withUnknowUserShouldDisplayError() {
$this->postDispatch('/opac/auth/lostpass',['username' => 'unknown']);
$this->assertXPathContentContains('//div', 'Identifiant inconnu',$this->_response->getBody());
}
/** @test */
public function withEmptyUserShouldDisplayError() {
$this->postDispatch('/opac/auth/lostpass',['username' => '']);
$this->assertXPathContentContains('//div', 'Veuillez saisir votre identifiant.',$this->_response->getBody());
}
}
class AuthControllerLostPasswordNoMailPostTest extends AbstractControllerTestCase{
public function setUp() {
parent::setUp();
$user = $this->fixture('Class_Users',
['id' => 1,
'pseudo' => 'luddite',
'login' => 'luddite',
'password' => 'notech',
'nom' => 'Lu',
'prenom' => 'Dites']);
$this->postDispatch('/opac/auth/lostpass' , ['username' => 'luddite']);
}
/** @test */
public function withoutEmailShouldReturnErrorMessage() {
$this->assertXPathContentContains('//div', "Votre mail n'est pas renseigné dans votre compte lecteur. Merci de vous adresser à la bibliothèque pour récupérer votre mot de passe ou bien le remplacer par un nouveau.");
}
}
class AuthControllerLostPasswordTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/auth/lostpass', true);
}
/** @test */
public function formActionShouldBeLostPass() {
$this->assertXPath('//form[@name="form_lostpass"][contains(@action, "/auth/lostpass")]');
}
/** @test */
public function formShouldContainsInputForUsername() {
$this->assertXPath('//form/input[@type="text"][@name="username"]');
}
/** @test */
public function pageShouldBeHTML5Valid() {
$this->assertHTML5();
}

llaffont
committed
class AuthControllerNobodyLoggedAndRegistrationAllowedRegisterTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::newInstanceWithId('INTERDIRE_ENREG_UTIL', ['valeur' => 0]);
$this->dispatch('auth/register', true);
}

llaffont
committed
/** @test */
public function H1ShouldContainsDemandDInscription() {
$this->assertXPathContentContains('//h1', 'Demande d\'inscription');
}

llaffont
committed
/** @test */
public function ParagraphRegisterHelpShouldContainsMailDeConfirmation() {
$this->assertXPathContentContains('//p', 'mail de confirmation');
}
/** @test */
public function inputMailShouldBePresent() {
$this->assertXPath('//input[@name="mail"][@type="email"]');
}
/** @test */
public function inputConfirmMailShouldBePresent() {
$this->assertXPath('//input[@name="mail2"][@type="email"]');
}

llaffont
committed
/** @test */
public function inputLoginShouldBePresent() {
$this->assertXPath('//input[@name="login"]');
}

llaffont
committed
/** @test */
public function inputMdpShouldBePresent() {
$this->assertXPath('//input[@name="mdp"]');
}

llaffont
committed
/** @test */
public function inputMdp2ShouldBePresent() {
$this->assertXPath('//input[@name="mdp2"]');
}

llaffont
committed
/** @test */
public function inputCaptchaShouldBePresent() {
$this->assertXPath('//input[@name="captcha[input]"]');
}

llaffont
committed
}
class AuthControllerNobodyLoggedRegisterPostRightDatasTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
Class_Users::beVolatile();
Class_UsersNonValid::beVolatile();
ZendAfi_Form_Element_Captcha::beValid();
$this->mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($this->mock_transport);
Class_Profil::getCurrentProfil()
->setMailSite('chef@afi.fr')
->setModulePreference('auth',
'register',
'register_confirm',
'Coucou, merci pour ton inscription');
Class_AdminVar::newInstanceWithId('REGISTER_OK', ['valeur' => '']);
Class_AdminVar::newInstanceWithId('INTERDIRE_ENREG_UTIL', ['valeur' => 0]);
$this->postDispatch('auth/register',
['login' => 'mario',
'mail' => 'mario@afi-sa.fr',
'mail2' => 'mario@afi-sa.fr',
'mdp' => 'secret',
'mdp2' => 'secret',
'captcha[id]' => '1234',
'captcha[input]' => '1234']);
}
protected function getSentMail() {
return $this->mock_transport->sent_mail;
}
protected function getSentMailRecipients() {
return $this->getSentMail()->getRecipients();
}
protected function getSentMailFrom() {
return $this->getSentMail()->getFrom();
}
protected function getSentMailContent() {
return quoted_printable_decode($this->getSentMail()->getBodyText()->getContent());
}
/** @test */
public function recipientShouldBeMario() {
$this->assertContains('mario@afi-sa.fr', $this->getSentMailRecipients());
}
/** @test */
public function recipientsShouldContainsChefAtAfiDotFr() {
$this->assertContains('chef@afi.fr', $this->getSentMailRecipients());
}
/** @test */
public function contentShouldBeAsExpected() {
$this->assertContains('Vous avez fait une demande d\'inscription', $this->getSentMailContent());
}
/** @test */
public function confirmationShouldBeAsExpected() {
$this->assertXPathContentContains('//div',
'Coucou, merci pour ton inscription');
}
/** @test */
public function withoutProfilMailSenderShouldBeAdmin() {
$this->assertContains('chef@afi.fr', $this->getSentMailFrom());
}
/** @test */
public function newUsersNonValidShouldBeCreated() {
$user = Class_UsersNonValid::findFirstBy(['login' => 'mario']);
$this->assertEquals(['id' => 1,
'id_user' => 1,
'login' => 'mario',
'password' => 'secret',
'mail' => 'mario@afi-sa.fr',
'cle' => md5('mario@afi-sa.fr')],
$user->getRawAttributes());
}
class AuthControllerNobodyLoggedRegisterPostWrongDataTest extends AuthControllerNobodyLoggedTestCase {
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
public function setUp() {
parent::setUp();
$this->fixture('Class_Users',
['id' => 2,
'login' => 'alexa',
'password' => 'secret',
'mail' => 'alex.arnaud@biblibre.com']);
$this->fixture('Class_UsersNonValid',
['id' => 3,
'login' => 'laurent',
'password' => 'secret_aussi',
'mail' => 'lolo@biblibre.com']);
Class_AdminVar::newInstanceWithId('INTERDIRE_ENREG_UTIL', ['valeur' => 0]);
}
public function fields() {
return [
['login',],
['mail'],
['mail2'],
['mdp'],
['mdp2'],
];
}
/**
* @dataProvider fields
* @test
*/
public function errorForEmptyFieldShouldBeVisible($field) {
$this->postDispatch('auth/register',
['login' => '',
'mail' => '',
'mail2' => '',
'mdp' => '',
'mdp2' => '',
'captcha[id]' => '93248',
'captcha[input]' => '']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="'.$field.'"]]//li',
'Une valeur est requise');
}
/** @test */
public function withMailsNotWellFormedShouldDisplayErrorInvalidMail() {
$this->postDispatch('auth/register',
['mail' => 'blib',
'mail2' => 'blib']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="mail"]]//li',
"'blib' n'est pas un email valide de la forme 'compte@hote.ext'");
/** @test */
public function withDifferentMailsShouldDisplayErrorMailAreNotTheSame() {
$this->postDispatch('auth/register',
['mail' => 'grand-schtroumpf@champi.gnon',
'mail2' => 'schtroumpfette@champi.gnon']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="mail2"]]//li',
"Les champs 'E-mail' sont différents");
}
/** @test */
public function withDifferentPasswordsShouldDisplayErrorPasswordsAreNotTheSame() {
$this->postDispatch('auth/register',
['mdp' => 'secret',
'mdp2' => 'sicrette']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="mdp2"]]//li',
"Les champs 'Mot de passe' sont différents");
}
/** @test */
public function existingMailsShouldDisplayErrorMailAlreadyExists() {
$this->postDispatch('auth/register',
['mail' => 'alex.arnaud@biblibre.com',
'mail2' => 'alex.arnaud@biblibre.com']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="mail"]]//li',
"L'e-mail 'alex.arnaud@biblibre.com' existe déjà.");
}
/** @test */
public function existingMailInUsersNonValidShouldDisplayErrorMailAlreadyExists() {
$this->postDispatch('auth/register',
['mail' => 'lolo@biblibre.com',
'mail2' => 'lolo@biblibre.com']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="mail"]]//li',
"L'e-mail 'lolo@biblibre.com' existe déjà.");
}
/** @test */
public function existingLoginShouldDisplayErrorLoginAlreadyExists() {
$this->postDispatch('auth/register',
['login' => 'alexa']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="login"]]//li',
"L'identifiant 'alexa' existe déjà.");
}
/** @test */
public function existingLoginInUsersNonValidShouldDisplayErrorLoginAlreadyExists() {
$this->postDispatch('auth/register',
['login' => 'laurent']);
$this->assertXPathContentContains('//ul[@class="errors"][preceding-sibling::input[@name="login"]]//li',
"L'identifiant 'laurent' existe déjà.");
}
}
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
class PortailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_IntBib::beVolatile();
$cfg_accueil = ['modules' => [4 => ['division' => '4',
'id_module' => 4,
'type_module' => 'LOGIN',
'preferences' => [
'identifiant' => 'Numéro de carte',
'mot_de_passe'=> 'Année de naissance',
'identifiant_exemple' => 'jj-mm-aaaa',
'mot_de_passe_exemple' => '1983',
'titre_connecte' => 'Vous êtes connecté(e)',
'lien_connexion' => 'please, log me',
'lien_mot_de_passe_oublie' => 'me rappelle plus',
'profil_redirect' => 0]]],
'options' => []];
Class_Profil::getCurrentProfil()
->setBrowser('opac')
->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil));
ZendAfi_Auth::getInstance()->logUser(
$this->fixture('Class_Users',
['id' => 5,
'login' => 'Pioup',
'idabon' => 48,
'password' => 'one ok password',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'id_site' => 1,
'fiche_sigb' => []]));
$this->dispatch('/opac/');
}
/** @test */
public function redirectProfilForLoginShouldBeProfil2(){
$this->assertXPath('//a[contains(@href,"abonne/fiche/id_profil/2")]');
}
/** @test */
public function redirectProfilForLoginShouldNotBeProfil0(){
$this->assertNotXPath('//a[contains(@href,"abonne/fiche/id_profil/0")]');
}
/** @test */
public function redirectProfilForLogoutShouldBeProfilParent(){
$this->bootstrap();
$this->dispatch('opac/auth/logout');
$this->assertRedirectTo('/');
}
/** @test */
public function redirectProfilForLogoutShouldNotBeProfil0(){
$this->assertNotXPath('//a[contains(@href,"auth/logout/id_profil/")]');
}
}
class AuthControllerAbonneSIGBNotValidLoggedTest extends PortailWithOneLoginModuleTestCase {
public function setUp() {
parent::setUp();
ZendAfi_Auth::getInstance()->logUser(
Class_Users::newInstanceWithId(5,
['login' => 'tomato',
'idabon' => 48,
'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB,
'id_site' => 1,
'date_fin' => '2014-01-01',
'fiche_sigb' => []]));
$this->dispatch('/opac/');
}
/** @test */
public function shouldDisplayExpiredSubscription() {
$this->assertXPathContentContains('//div[@class="boite login"]//p[@class="user_notifications"]', 'Abonnement expiré - Merci de contacter la médiathèque');
}
class AuthControllerNobodyLoggedAndRegisterNewsletterWithNoNewsletterTest extends AuthControllerNobodyLoggedTestCase {
$this->dispatch('/opac/auth/newsletter-register', true);
}
/** @test */
public function shouldRedirectToIndex() {
$this->assertRedirectTo('/');
}
}
class AuthControllerNobodyLoggedAndRegisterNewsletterWithWrongNewsletterTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
Class_Newsletter::beVolatile();
$this->dispatch('/opac/auth/newsletter-register/id/1', true);
}
/** @test */
public function shouldRedirectToIndex() {
$this->assertRedirectTo('/');
}
}
class AuthControllerNewsletterRegisterKickSpamBotsTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Newsletter',
['id' => 5,
'titre' => 'Daily News']);
$this->postDispatch('/opac/auth/newsletter-register/id/5', [
'email' => 'imnotabot@factory.bot',
'emailCheck' => 'imnotabot@factory.bot']);
}
/** @test */
public function shouldRedirectToIndex() {
$this->assertRedirectTo('/');
}
}
class AuthControllerNobodyLoggedAndRegisterNewsletterTest extends AuthControllerNobodyLoggedTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Newsletter',
['id' => 5,
'titre' => 'Daily News']);
$this->dispatch('/opac/auth/newsletter-register/id/5', true);
}
/** @test */
public function titleShouldBeAsExpected() {
$this->assertXPathContentContains('//div[@class="titre"]//h1', 'Inscription à la lettre d\'information: Daily News');
}
/** @test */
public function registerFormShouldBePresent() {
$this->assertXPath('//form[@id="newsletter_register"]');
}
/** @test */
public function mailInputShouldBePresent() {
$this->assertXPath('//form//input[@name="email"][@type="email"]');
}
/** @test */
public function negativeCaptchaShouldBePresent() {
$this->assertXPath('//form//input[@name="emailCheck"][@data-spambots="negative-captcha"]');
}
/** @test */
public function submitButtonShouldBePresent() {
$this->assertXPath('//form//input[@type="submit"][@value="Valider"]');
}
}
class AuthControllerPostRegisterNewsletterDailyNewsTest extends AuthControllerNobodyLoggedTestCase {
$this->mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($this->mock_transport);
Class_Profil::getCurrentProfil()
->setMailSite('tom@afi.fr');
Class_Users::beVolatile();
Class_UsersNonValid::beVolatile();
$this->fixture('Class_Newsletter', ['id' => 5, 'titre' => 'Daily News']);
$this->postDispatch('/opac/auth/newsletter-register/id/5', ['email' => 'iwanttobespamed@abo.com',
'emailCheck' => '']);
}
protected function getSentMail() {
return $this->mock_transport->sent_mail;
}
protected function getSentMailRecipients() {
return $this->getSentMail()->getRecipients();
}
protected function getSentMailFrom() {
return $this->getSentMail()->getFrom();
}
protected function getSentMailContent() {
return quoted_printable_decode($this->getSentMail()->getBodyText()->getContent());
}
/** @test */
public function nonValidUserShouldBeCreatedWithExpectedEmail() {
$this->assertEquals('iwanttobespamed@abo.com', Class_UsersNonValid::find(1)->getMail());
}
/** @test */
public function recipientShouldBeIwanttobespamed() {
$this->assertContains('iwanttobespamed@abo.com', $this->getSentMailRecipients());
}
/** @test */
public function contentShouldBeAsExpected() {
$this->assertContains('Vous avez fait une demande d\'inscription à la lettre d\'information: Daily News', $this->getSentMailContent());
}
/** @test */
public function validationUrlShouldBeAsExpected() {
$this->assertContains('/auth/newsletter-active-user/c/d7660b4a8df1ccb01fd50ddc6e7d3426/id/5', $this->getSentMailContent(), $this->getSentMailContent());
}
/** @test */
public function senderShouldBeAsExpected() {
$this->assertContains('tom@afi.fr', $this->getSentMailFrom());
}
/** @test */
public function confirmationShouldBeAsExpected() {
$this->assertXPathContentContains('//p',"Une demande de confirmation d'inscription vous a été envoyée à l'adresse mail renseignée.");
}
/** @test */
public function mailShouldContainsAccountMessage() {
$this->assertContains("Un compte vous a été créé automatiquement.", $this->getSentMailContent());
}
/** @test */
public function mailShouldContainsAccountLogin() {
$this->assertContains('Votre identifiant: iwanttobespamed@abo.com', $this->getSentMailContent());
}
/** @test */
public function mailShouldContainsAccountPassword() {
$this->assertContains('Votre mot de passe: ', $this->getSentMailContent());
}
/** @test */
public function unssubscribUrlShouldBeAsExpected() {
$this->assertContains('/auth/newsletter-unsubscribe/id/5', $this->getSentMailContent());
}
}
class AuthControllerPostRegisterNewsletterDailyNewsWithNonUniqueMailTest extends AuthControllerNobodyLoggedTestCase {
$this->fixture('Class_Users',
['id' => 1,
'login' => 'Tom',
'password' => 'pwd',
'mail' => 'imalreadyused@mail.com']);
$this->fixture('Class_Newsletter',
['id' => 5,
'titre' => 'Daily News']);
$this->postDispatch('/opac/auth/newsletter-register/id/5', [
'email' => 'imalreadyused@mail.com',
'emailCheck' => '']);
}
/** @test */
public function shouldReturnNonUniqueMailMessage() {
$this->assertXPathContentContains('//span[@class="error"]',
"Un utilisateur a déjà renseigné cet email. Merci de vous identifier avec le compte qui utilise cet email.");
}
/** @test */
public function linkToLoginShouldBePresent() {
$this->assertXPathContentContains('//a[contains(@href, "auth/ajax-login")]', 'J\'ai déjà un compte');
}

Ghislain Loas
committed
class AuthControllerPostRegisterNewsletterDailyNewsWithBadMailTest extends AuthControllerNobodyLoggedTestCase {
Class_Users::beVolatile();
Class_UsersNonValid::beVolatile();
$this->fixture('Class_Newsletter', ['id' => 5, 'titre' => 'Daily News']);
$this->postDispatch('/opac/auth/newsletter-register/id/5', ['email' => 'bad_mail!',
'emailCheck' => '']);
}
/** @test */
public function shouldDisplayValidationError() {
$this->assertXPathContentContains('//ul[@class="errors"]/li', 'n\'est pas un email valide');
}
class AuthControllerNewsletterActiveUserWithWrongParamsTest extends AuthControllerNoBodyLoggedTestCase {
public function setUp() {
parent::setUp();
}
/** @test */
public function noParamsShouldRedirectToIndex() {
$this->dispatch('opac/auth/newsletter-active-user', true);
$this->assertRedirectTo('/');
}
/** @test */
public function noKeySshouldRedirectToIndex() {
$this->dispatch('opac/auth/newsletter-active-user/id/5', true);
$this->assertRedirectTo('/');
}
/** @test */
public function noNewsletterShouldRedirectToIndex() {
$this->dispatch('opac/auth/newsletter-active-user/c/4897sd8fsdf', true);
$this->assertRedirectTo('/');
}
/** @test */
public function wrongNewsletterShouldRedirectedToIndex() {
Class_Newsletter::beVolatile();
$this->dispatch('opac/auth/newsletter-active-user/c/4897sd8fsdf/id/1', true);
$this->assertRedirectTo('/');
}
/** @test */
public function wrongKeyShouldDisplayExpectedMessage() {
$this->fixture('Class_Newsletter',
['id' => 1,
'titre' => 'News of the month']);
$this->dispatch('opac/auth/newsletter-active-user/c/4897sd8fsdf/id/1', true);
$this->assertXPathContentContains('//p', 'Inscription à la newsletter invalide.');
}
}
class AuthControllerNewsletterActiveUserTest extends AuthControllerNoBodyLoggedTestCase {
$this->fixture('Class_Newsletter',[
'id' => 1,
'titre' => 'News of the month']);
$this->fixture('Class_UsersNonValid', [
'id' => 1,
'login' => 'future@i.am',
'mail' => 'future@i.am',
'password' => 'random',
'cle' => '12345678']);
$this->fixture('Class_UsersNonValid', [
'id' => 2,
'login' => 'future@i.am',
'mail' => 'future@i.am',
'password' => 'random',
'cle' => '12345678']);
$this->dispatch('opac/auth/newsletter-active-user/c/12345678/id/1', true);
}
/** @test */
public function userFutureShouldExist() {
$this->assertEquals('future@i.am', Class_Users::findFirstBy(['login' => 'future@i.am'])->getMail());
}
/** @test */
public function newsletterShouldHaveFutureAsSubscriber() {
$this->assertEquals('future@i.am', Class_NewsletterSubscription::find(1)->getUser()->getMail());
}
/** @test */
public function successMessageShouldBeAsExpected() {
$this->assertXPathContentContains('//p', "Vous avez bien été abonné à la newsletter: News of the month avec l'adresse suivante: future@i.am");
}
/** @test */
public function allNonValidUsersShouldBeDeleted() {
$this->assertEmpty(Class_UsersNonValid::findAll());
}
class AuthControllerTomLoggedRegisterNewsletterTestCase extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_NewsletterSubscription::beVolatile();
$this->fixture('Class_Newsletter',
['id' => 5,
'titre' => 'Daily News']);
ZendAfi_Auth::getInstance()
->logUser($this->fixture('Class_Users',
['id' => 156,