-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implemented issue #13383: Add a method to extract/change/replace en…
…tities in HTML mail with the CID elements replaced.
- Loading branch information
Showing
5 changed files
with
98 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,8 @@ class ezcMailExtended extends ezcMail | |
*/ | ||
class ezcMailToolsTest extends ezcTestCase | ||
{ | ||
/** | ||
* Tests if ezcMailTools::composeEmailAddress works as it should | ||
* @todo test if no 'email' is given. | ||
*/ | ||
// Tests if ezcMailTools::composeEmailAddress works as it should | ||
// @todo test if no 'email' is given. | ||
public function testComposeEmailAddress() | ||
{ | ||
$address = new ezcMailAddress( '[email protected]', 'John Doe' ); | ||
|
@@ -33,10 +31,8 @@ public function testComposeEmailAddress() | |
$this->assertEquals( '[email protected]', ezcMailTools::composeEmailAddress( $address ) ); | ||
} | ||
|
||
/** | ||
* Tests if ezcMailTools::composeEmailAddresses works as it should | ||
* @todo test if no 'email' is given. | ||
*/ | ||
// Tests if ezcMailTools::composeEmailAddresses works as it should | ||
// @todo test if no 'email' is given. | ||
public function testComposeEmailAddresses() | ||
{ | ||
$addresses = array( new ezcMailAddress( '[email protected]', 'John Doe' ), | ||
|
@@ -288,11 +284,9 @@ public function testValidateEmailAddressIncorrectMX() | |
} | ||
} | ||
|
||
/** | ||
* Tests if generateContentId works as it should. | ||
* Somewhat hard to test since it is supposed to return a unique string. | ||
* We simply test if two calls return different strings. | ||
*/ | ||
// Tests if generateContentId works as it should. | ||
// Somewhat hard to test since it is supposed to return a unique string. | ||
// We simply test if two calls return different strings. | ||
public function testGenerateContentId() | ||
{ | ||
if ( ezcMailTools::generateContentID() === ezcMailTools::generateContentID() ) | ||
|
@@ -301,11 +295,9 @@ public function testGenerateContentId() | |
} | ||
} | ||
|
||
/** | ||
* Tests if generateMessageId works as it should. | ||
* Somewhat hard to test since it is supposed to return a unique string. | ||
* We simply test if two calls return different strings. | ||
*/ | ||
// Tests if generateMessageId works as it should. | ||
// Somewhat hard to test since it is supposed to return a unique string. | ||
// We simply test if two calls return different strings. | ||
public function testGenerateMessageId() | ||
{ | ||
if ( ezcMailTools::generateMessageID( "doe.com" ) === ezcMailTools::generateMessageID( "doe.com") ) | ||
|
@@ -314,9 +306,6 @@ public function testGenerateMessageId() | |
} | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testEndline() | ||
{ | ||
// defaul is \n\r as specified in RFC2045 | ||
|
@@ -434,6 +423,33 @@ public function testGuessContentType() | |
} | ||
} | ||
|
||
public function testResolveCids() | ||
{ | ||
$parser = new ezcMailParser(); | ||
$set = new ezcMailFileSet( array( dirname( __FILE__ ) | ||
. '/parser/data/various/test-html-inline-images' ) ); | ||
$mail = $parser->parseMail( $set ); | ||
|
||
$relatedParts = $mail[0]->body->getParts(); | ||
$alternativeParts = $relatedParts[0]->getParts(); | ||
$html = $alternativeParts[1]->getMainPart(); | ||
|
||
$convertArray = array( | ||
'consoletools-table.png@1421450' => 'foo', | ||
'consoletools-table.png@1421452' => 'bar' | ||
); | ||
|
||
$htmlBody = ezcMailTools::replaceContentIdRefs( $html->text, $convertArray ); | ||
$expected = <<<EOFE | ||
<html> | ||
Here is the HTML version of your mail | ||
with an image: <img src='foo'/> | ||
with an image: <img src='cid:consoletools-table.png@1421451'/> | ||
</html> | ||
EOFE; | ||
self::assertSame( $expected, $htmlBody ); | ||
} | ||
|
||
public static function suite() | ||
{ | ||
return new PHPUnit_Framework_TestSuite( "ezcMailToolsTest" ); | ||
|