Source for file Data.php
Documentation is available at Data.php
* Magentron EmailImages Extension
* @package Magentron_EmailImages
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* Test isEnabled() for enabled
$enabled =
Mage::helper('emailimages')->isEnabled();
$this->assertTrue($enabled);
* Test isEnabled() for disabled
$enabled =
Mage::helper('emailimages')->isEnabled();
$this->assertFalse($enabled);
* Test getCacheTime() for valid config value
$value =
Mage::helper('emailimages')->getCacheTime();
$this->assertEquals($this->expected('cache_time')->getValid(), $value);
* Test getCacheTime() for invalid config value
$value =
Mage::helper('emailimages')->getCacheTime();
* Test getRegularExpression() for valid config value
$value =
Mage::helper('emailimages')->getRegularExpression();
$this->assertEquals($this->expected('regexp')->value, $value);
* Test getRegularExpression() for invalid config value
$value =
Mage::helper('emailimages')->getRegularExpressionIndex();
* Test getRegularExpressionIndex() for valid config value
$value =
Mage::helper('emailimages')->getRegularExpressionIndex();
$this->assertEquals($this->expected('regexp')->index, $value);
* Test getRegularExpressionIndex() for invalid config value
$value =
Mage::helper('emailimages')->getRegularExpressionIndex();
foreach ( array('HTML', 'Html', 'html', 'text') as $type )
foreach ( array(null, 'test-', 'test-') as $context )
$context .=
$type .
'-' .
md5($context .
$type);
$mail->setFrom( Mage::getStoreConfig('trans_email/ident_general/email'))
->addTo(Mage::getStoreConfig('trans_email/ident_support/email'))
->setSubject('Test subject');
$mail->setBodyHtml('<html><body>This is HTML with images.</body></html>');
$mail->setBodyHtml('<html><body><img src="http://does.not.exits/does-not-exist.jpg" /></body></html>');
$mail->setBodyHtml('<html><body><img src="' .
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) .
'frontend/default/default/images/logo.gif" /></body></html>');
$mail->setBodyText('This is a test email.');
Mage::helper('emailimages')->addImages($mail, $context);
if ( Mage::getStoreConfig('system/emailimages/enable') )
$this->assertEquals(1, $mail->getPartCount(), 'HTML email should have 1 attachment');
$this->assertEquals(0, $mail->getPartCount(), 'HTML email should have no attachment if EmailImages has been disabled');
$this->assertEquals(0, $mail->getPartCount(), ucfirst($type) .
' email should have no attachments');
* Test addImages() with cache turned on
* Test addImages() with the EmailImages extension disabled
Mage::helper('emailimages')->addImages(new Zend_Mail());
* Test addImages() with exception thrown
Mage::helper('emailimages')->addImages(new Zend_Mail(), 'test');
Mage::helper('emailimages')->cleanCache();
* @param string $typeCode
* @see addImagesCache(), addImagesDisabled(), addImagesException(),
if ( Mage::getStoreConfig('system/emailimages/enable') )
if ( Mage::getStoreConfig('test/emailimages/use_cache') )
elseif ( Mage::getStoreConfig('test/emailimages/throw_exception') )
// when the extension has been enabled, we want to test an exception
throw
new Exception('dummy exception to get 100% code coverage on addImages()');
// when the extension has been disabled, getType() should not be called
$this->fail('canUse() should not be called when the EmailImages extension has been disabled');
$mock =
$this->getModelMock('core/cache', array('canUse'));
$mock->expects($this->any())
->will($this->returnCallback(array($this, 'Mage_Core_Model_Cache_canUse')));
$this->replaceByMock('model', 'core/cache', $mock);
Documentation generated on Fri, 09 Oct 2015 03:37:08 +0200 by phpDocumentor 1.4.4