Commit 2fefa23f authored by Patrick Barroca's avatar Patrick Barroca

dev #46014 : fix test failures

parent c37651f3
......@@ -320,13 +320,14 @@ class Class_Newsletter extends Storm_Model_Abstract {
public function subscribeUser($user) {
$is_recipient = $this->hasRecipient($user,false);
if ( $is_recipient
&& Class_Newsletter_Blacklist::isBlackListed($user->getMail(),$this->getId())) {
$is_recipient = $this->hasRecipient($user, false);
$is_blacklisted = Class_Newsletter_Blacklist::isBlackListed($user->getMail(), $this->getId());
if ($is_blacklisted) {
Class_Newsletter_Blacklist::deleteBy(['newsletter_id' => $this->getId(),
'mail' => $user->getMail()]);
return $this;
'mail' => $user->getMail()]);
}
if (!$is_recipient)
return $this->subscribeToDedicatedGroup($user);
......
......@@ -558,6 +558,7 @@ class AbonneControllerNewslettersValidationsTest extends AbonneControllerWithTwo
class AbonneControllerNewslettersMultipleUnSubscriptionTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$_SERVER['HTTP_REFERER'] = '/opac/index';
......@@ -570,26 +571,25 @@ class AbonneControllerNewslettersMultipleUnSubscriptionTest extends AbstractCont
ZendAfi_Auth::getInstance()
->logUser($user);
ZendAfi_Auth::getInstance()->logUser($user);
(new NewsletterFixtures())->createUsersAndNewsletter($this);
Class_Users::find(156)->addNewsletter(Class_Newsletter::find(1));
$this->dispatch('/opac/abonne/unsubscribe-newsletter/id/1',true);
}
/** @test */
public function tomatoMailShouldBeBlacklisted() {
$this->assertCount(1,Class_Newsletter_Blacklist::findAllBy(['mail' => Class_Users::find(156)->getMail(),
'newsletter_id' => 1]));
$this->assertCount(1, Class_Newsletter_Blacklist::findAllBy(['mail' => Class_Users::find(156)->getMail(),
'newsletter_id' => 1]));
}
/** @test */
public function tomatoShouldStillRegistered() {
$this->assertTrue(Class_Newsletter::find(1)->hasRecipient(Class_Users::find(156),false));
$this->assertTrue(Class_Newsletter::find(1)->hasRecipient(Class_Users::find(156), false));
}
......@@ -598,9 +598,6 @@ class AbonneControllerNewslettersMultipleUnSubscriptionTest extends AbstractCont
$this->assertFalse(Class_Newsletter::find(1)->hasRecipient(Class_Users::find(23)));
}
}
......@@ -615,15 +612,14 @@ class AbonneControllerNewslettersMultipleSubscriptionTest extends AbstractContro
['id' => 156,
'login' => 'tomato',
'password' => 'pwd',
'mail' => 'pat@pat.info']);
'mail' => 'pat@pat.info']);
ZendAfi_Auth::getInstance()
->logUser($user);
ZendAfi_Auth::getInstance()->logUser($user);
(new NewsletterFixtures())->createUsersAndNewsletter($this);
Class_Newsletter_Blacklist::unsubscribeByMail($user->getMail(),1);
Class_Newsletter_Blacklist::unsubscribeByMail($user->getMail(), 1);
$this->dispatch('/opac/abonne/subscribe-newsletter/id/1',true);
}
......@@ -633,15 +629,17 @@ class AbonneControllerNewslettersMultipleSubscriptionTest extends AbstractContro
$this->assertTrue(Class_Newsletter::find(1)->hasRecipient(Class_Users::find(156)));
}
/** @test */
public function tomatoMailShouldNotBeBlacklisted() {
$this->assertCount(0,Class_Newsletter_Blacklist::findAllBy(['mail' => Class_Users::find(156)->getMail(),
'newsletter_id' => 1]));
$this->assertCount(0,
Class_Newsletter_Blacklist::findAllBy(['mail' => Class_Users::find(156)->getMail(),
'newsletter_id' => 1]));
}
/** @test **/
public function patShouldBeRecipient() {
$this->assertTrue(Class_Newsletter::find(1)->hasRecipient(Class_Users::find(23)));
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment