Skip to content

Commit

Permalink
email component osFix removal due to new assertTextEquals
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark authored and markstory committed Feb 17, 2012
1 parent 6412797 commit 2afece4
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php
Expand Up @@ -175,16 +175,6 @@ public function tearDown() {
ClassRegistry::flush();
}

/**
* osFix method
*
* @param string $string
* @return string
*/
function __osFix($string) {
return str_replace(array("\r\n", "\r"), "\n", $string);
}

/**
* testSendFormats method
*
Expand Down Expand Up @@ -222,12 +212,12 @@ public function testSendFormats() {
$this->Controller->EmailTest->sendAs = 'text';
$expect = str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $message);
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEquals(DebugCompTransport::$lastEmail, $this->__osFix($expect));
$this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);

$this->Controller->EmailTest->sendAs = 'html';
$expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $message);
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEquals(DebugCompTransport::$lastEmail, $this->__osFix($expect));
$this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);
}

/**
Expand Down Expand Up @@ -293,12 +283,12 @@ public function testTemplates() {
$this->Controller->EmailTest->sendAs = 'text';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEquals(DebugCompTransport::$lastEmail, $this->__osFix($expect));
$this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);

$this->Controller->EmailTest->sendAs = 'html';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . "\n" . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEquals(DebugCompTransport::$lastEmail, $this->__osFix($expect));
$this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);

$this->Controller->EmailTest->sendAs = 'both';
$expect = str_replace('{CONTENTTYPE}', 'multipart/mixed; boundary="{boundary}"', $header);
Expand All @@ -320,8 +310,8 @@ public function testTemplates() {
$expect = '<pre>' . $expect . '</pre>';

$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEquals(
$this->__osFix($expect),
$this->assertTextEquals(
$expect,
preg_replace('/[a-z0-9]{32}/i', '{boundary}', DebugCompTransport::$lastEmail)
);

Expand All @@ -344,7 +334,7 @@ public function testTemplates() {
$this->Controller->EmailTest->sendAs = 'html';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . '</pre>';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin'));
$this->assertEquals(DebugCompTransport::$lastEmail, $this->__osFix($expect));
$this->assertTextEquals(DebugCompTransport::$lastEmail, $expect);
}

/**
Expand Down Expand Up @@ -455,18 +445,18 @@ public function testMessageRetrievalWithoutTemplate() {

$this->Controller->EmailTest->sendAs = 'both';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEquals($this->Controller->EmailTest->textMessage, $this->__osFix($text));
$this->assertEquals($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));
$this->assertTextEquals($this->Controller->EmailTest->textMessage, $text);
$this->assertTextEquals($this->Controller->EmailTest->htmlMessage, $html);

$this->Controller->EmailTest->sendAs = 'text';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEquals($this->Controller->EmailTest->textMessage, $this->__osFix($text));
$this->assertTextEquals($this->Controller->EmailTest->textMessage, $text);
$this->assertNull($this->Controller->EmailTest->htmlMessage);

$this->Controller->EmailTest->sendAs = 'html';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertNull($this->Controller->EmailTest->textMessage);
$this->assertEquals($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));
$this->assertTextEquals($this->Controller->EmailTest->htmlMessage, $html);
}

/**
Expand Down Expand Up @@ -515,18 +505,18 @@ public function testMessageRetrievalWithTemplate() {

$this->Controller->EmailTest->sendAs = 'both';
$this->assertTrue($this->Controller->EmailTest->send());
$this->assertEquals($this->Controller->EmailTest->textMessage, $this->__osFix($text));
$this->assertEquals($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));
$this->assertTextEquals($this->Controller->EmailTest->textMessage, $text);
$this->assertTextEquals($this->Controller->EmailTest->htmlMessage, $html);

$this->Controller->EmailTest->sendAs = 'text';
$this->assertTrue($this->Controller->EmailTest->send());
$this->assertEquals($this->Controller->EmailTest->textMessage, $this->__osFix($text));
$this->assertTextEquals($this->Controller->EmailTest->textMessage, $text);
$this->assertNull($this->Controller->EmailTest->htmlMessage);

$this->Controller->EmailTest->sendAs = 'html';
$this->assertTrue($this->Controller->EmailTest->send());
$this->assertNull($this->Controller->EmailTest->textMessage);
$this->assertEquals($this->Controller->EmailTest->htmlMessage, $this->__osFix($html));
$this->assertTextEquals($this->Controller->EmailTest->htmlMessage, $html);
}

/**
Expand Down

0 comments on commit 2afece4

Please sign in to comment.