/** * @magentoDataFixture Mage/Adminhtml/controllers/_files/newsletter_sample.php * @magentoAppIsolation disabled */ public function testSaveActionQueueTemplateAndVerifySuccessMessage() { $postForQueue = array('sender_email' => '*****@*****.**', 'sender_name' => 'john doe', 'subject' => 'test subject', 'text' => 'newsletter text'); $this->getRequest()->setPost($postForQueue); $this->_model->loadByCode('some_unique_code'); $this->getRequest()->setParam('template_id', $this->_model->getId()); $this->dispatch('backend/admin/newsletter_queue/save'); /** * Check that errors was generated and set to session */ $this->assertEmpty(Mage::getSingleton('Mage_Backend_Model_Session')->getMessages(false)->getErrors()); /** * Check that success message is set */ $successMessages = Mage::getSingleton('Mage_Backend_Model_Session')->getMessages(false)->getItemsByType(Mage_Core_Model_Message::SUCCESS); $this->assertCount(1, $successMessages, 'Success message was not set'); $this->assertEquals('The newsletter queue has been saved.', current($successMessages)->getCode()); }
/** * @magentoAppIsolation enabled * @magentoDataFixture Mage/Adminhtml/controllers/_files/newsletter_sample.php */ public function testDeleteActionTemplateAndVerifySuccessMessage() { $this->_model->loadByCode('some_unique_code'); $this->getRequest()->setParam('id', $this->_model->getId()); $this->dispatch('backend/admin/newsletter_template/delete'); /** * Check that errors was generated and set to session */ $this->assertEmpty(Mage::getSingleton('Mage_Backend_Model_Session')->getMessages(false)->getErrors()); /** * Check that success message is set */ $successMessages = Mage::getSingleton('Mage_Backend_Model_Session')->getMessages(false)->getItemsByType(Mage_Core_Model_Message::SUCCESS); $this->assertCount(1, $successMessages, 'Success message was not set'); $this->assertEquals('The newsletter template has been deleted.', current($successMessages)->getCode()); }
/** * Check usage of template code in other templates * * @param Mage_Newsletter_Model_Template $template * @return boolean */ public function checkCodeUsage(Mage_Newsletter_Model_Template $template) { if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) { $bind = array('template_id' => $template->getId(), 'template_code' => $template->getTemplateCode(), 'template_actual' => 1); $select = $this->_getReadAdapter()->select()->from($this->getMainTable(), new Zend_Db_Expr('COUNT(template_id)'))->where('template_id != :template_id')->where('template_code = :template_code')->where('template_actual = :template_actual'); $countOfCodes = $this->_getReadAdapter()->fetchOne($select, $bind); return $countOfCodes > 0; } else { return false; } }
/** * Check usage of template code in other templates * * @param Mage_Newsletter_Model_Template $template * @return boolean */ public function checkCodeUsage(Mage_Newsletter_Model_Template $template) { if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) { $select = $this->_read->select()->from($this->_templateTable, new Zend_Db_Expr('COUNT(template_id)'))->where('template_id!=?', $template->getId())->where('template_code=?', $template->getTemplateCode())->where('template_actual=?', 1); $countOfCodes = $this->_read->fetchOne($select); return $countOfCodes > 0; } else { return false; } }
* NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Newsletter * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require __DIR__ . '/template.php'; require __DIR__ . '/subscribers.php'; $template = new Mage_Newsletter_Model_Template(); $template->load('fixture_tpl', 'template_code'); $templateId = $template->getId(); $currentStore = Mage::app()->getStore()->getId(); $otherStore = Mage::app()->getStore('fixturestore')->getId(); $queue = new Mage_Newsletter_Model_Queue(); $queue->setTemplateId($templateId)->setNewsletterText('{{skin url="images/logo.gif"}}')->setNewsletterSubject('Subject')->setNewsletterSenderName('CustomerSupport')->setNewsletterSenderEmail('*****@*****.**')->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_NEVER)->setQueueStartAtByString(0)->setStores(array($currentStore, $otherStore))->save();