Commit 74858b0e authored by Patrick Barroca's avatar Patrick Barroca 🐧

rel #46014 : fixing test failures

parent ee3e1ce6
......@@ -163,7 +163,7 @@ class Class_Newsletter extends Storm_Model_Abstract {
protected function _getMailPortail() {
$portail = Class_Profil::getLoader()->find(1);
$portail = Class_Profil::find(1);
return $portail->getMailSite();
}
......
......@@ -36,6 +36,8 @@ abstract class NewsletterMailingTestCase extends ModelTestCase {
->whenCalled('reset')->answers(null)
->beStrict());
Class_UserGroup::setMemoryCleaner(function() {});
$profil_portail = $this->fixture('Class_Profil',
['id' => 1,
'mail_site' => 'flo@afi-sa.fr']);
......@@ -103,44 +105,21 @@ abstract class NewsletterMailingTestCase extends ModelTestCase {
->setUsers([$this->rdubois,
$this->mduchamp,
$this->zork,
$this->zorkglub]);
$this->onLoaderOfModel('Class_NewsletterSubscription')
->whenCalled('clearCache')
->answers(true)
->whenCalled('countDistributionProgress')
->with(1)
->answers(0)
->whenCalled('updateSendFlagForReceivers')
->with(1,[$this->rdubois,
$this->mduchamp,
$this->zork,
$this->zorkglub])
->answers(false)
->whenCalled('updateSendFlagForReceivers')
->with(1,[])
->answers(false)
->whenCalled('resetSendFlagForNewsletter')
->with(1)
->answers(true)
$this->zorkglub])
->save();
->beStrict();
$this->onLoaderOfModel('Class_Notice')
->whenCalled('getNoticesFromPreferences')
->willDo(function() {return $this->notices;});
->whenCalled('getNoticesFromPreferences')
->answers($this->notices);
$this->mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($this->mock_transport);
$this->_prepareFixtures();
$this->animations->generateMails(20);
$this->_dispatch = Class_Newsletter_Dispatch::newFrom($this->animations);
$this->_dispatch->sendBy(20);
$this->mails = $this->mock_transport->getSentMails();
......@@ -191,6 +170,12 @@ class NewsletterMailingAnimationsSendMailTest extends NewsletterMailingTestCase
}
protected function _hashForUser($user) {
return Class_Newsletter_Template::hashForUser($this->animations->getId(),
$user->getMail());
}
/** @test */
public function batchSendParamsShouldBeAsExpected() {
$this->assertEquals('"'.$_SERVER['HTTP_HOST'].'" "'.$_SERVER['SERVER_NAME'].'" "'.BASE_URL.'" "1"',
......@@ -216,11 +201,10 @@ class NewsletterMailingAnimationsSendMailTest extends NewsletterMailingTestCase
}
/** @test */
public function bodyTextShouldContainsUnsubscribeLinks() {
$this->assertContains('/newsletter/unsubscribe/newsletter/1/user/2/hash/'
. Class_Newsletter::find(1)->hashForUser(Class_Users::find(2)),
. $this->_hashForUser(Class_Users::find(2)),
$this->mails[1]->getBodyText(true));
}
......@@ -228,7 +212,8 @@ class NewsletterMailingAnimationsSendMailTest extends NewsletterMailingTestCase
/** @test */
public function bodyHTMLShouldContainsUnsubscribeLinks() {
$this->assertContains('/unsubscribe/newsletter/1/user/2/hash/'.Class_Newsletter::find(1)->hashForUser(Class_Users::find(2)),
$this->assertContains('/newsletter/unsubscribe/newsletter/1/user/2/hash/'
. $this->_hashForUser(Class_Users::find(2)),
quoted_printable_decode($this->mails[1]->getBodyHTML(true)));
}
......
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