/** * @magentoDataFixture Mage/Newsletter/_files/queue.php * @magentoAppIsolation enabled */ public function testSendPerSubscriberProblem() { $mail = $this->getMock('Zend_Mail', array('send'), array('utf-8')); $brokenMail = $this->getMock('Zend_Mail', array('send'), array('utf-8')); $errorMsg = md5(microtime()); $brokenMail->expects($this->any())->method('send')->will($this->throwException(new Exception($errorMsg, 99))); $template = $this->getMock('Mage_Core_Model_Email_Template', array('_getMail')); $template->expects($this->any())->method('_getMail')->will($this->onConsecutiveCalls($mail, $brokenMail)); $queue = new Mage_Newsletter_Model_Queue(array('email_template' => $template)); $queue->load('Subject', 'newsletter_subject'); // fixture $problem = new Mage_Newsletter_Model_Problem(); $problem->load($queue->getId(), 'queue_id'); $this->assertEmpty($problem->getId()); $queue->sendPerSubscriber(); $problem->load($queue->getId(), 'queue_id'); $this->assertNotEmpty($problem->getId()); $this->assertEquals(99, $problem->getProblemErrorCode()); $this->assertEquals($errorMsg, $problem->getProblemErrorText()); }