Skip to content
Permalink
Browse files

Fix failing tests in Network package.

  • Loading branch information...
markstory committed Jun 11, 2013
1 parent 77a8e47 commit d78e213cf48f20ec75e1109d4e6fe8c6ca548e89
@@ -20,6 +20,7 @@
use Cake\Error;
use Cake\Log\Log;
use Cake\Network\Http\FormData\Part;
use Cake\Utility\File;
use Cake\Utility\Hash;
use Cake\Utility\String;
use Cake\Utility\Validation;
@@ -1251,7 +1252,7 @@ protected function _wrap($message, $wrapLength = Email::LINE_LENGTH_MUST) {
$message = str_replace(array("\r\n", "\r"), "\n", $message);
$lines = explode("\n", $message);
$formatted = array();
$cut = ($wrapLength == CakeEmail::LINE_LENGTH_MUST) ? true : false;
$cut = ($wrapLength == Email::LINE_LENGTH_MUST) ? true : false;
foreach ($lines as $line) {
if (empty($line)) {
@@ -0,0 +1,15 @@
<?php
use Cake\Network\Email\Email;
?>
<h1>HTML Ipsum Presents</h1><p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2><ol><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote><h3>Header Level 3</h3><ul><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ul>
<pre><code>
#header h1 a {
display: block;
width: 300px;
height: 80px;
}</code></pre>
<table>
<th align="right" valign="top"
style="font-weight: bold">The tag is across multiple lines - <?php echo str_repeat('x', Email::LINE_LENGTH_MUST); ?></th>
</table>
<p>Some more <?php echo str_repeat('x', Email::LINE_LENGTH_MUST); ?> <b>Bold</b> test.</p>
@@ -42,7 +42,7 @@ public function formatAddress($address) {
* Wrap to protected method
*
*/
public function wrap($text, $length = CakeEmail::LINE_LENGTH_MUST) {
public function wrap($text, $length = Email::LINE_LENGTH_MUST) {
return parent::_wrap($text, $length);
}
@@ -1037,27 +1037,25 @@ public function testSendWithLog() {
* @return void
*/
public function testSendWithLogAndScope() {
CakeLog::config('email', array(
Configure::write('Log.email', array(
'engine' => 'FileLog',
'path' => TMP,
'types' => array('cake_test_emails'),
'file' => 'cake_test_emails',
'scopes' => array('email')
));
CakeLog::drop('default');
Log::reset();
$this->CakeEmail->transport('Debug');
$this->CakeEmail->to('me@cakephp.org');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->subject('My title');
$this->CakeEmail->config(array('log' => array('level' => 'cake_test_emails', 'scope' => 'email')));
$this->CakeEmail->config(array('log' => array('scope' => 'email')));
$result = $this->CakeEmail->send("Logging This");
App::uses('File', 'Utility');
$File = new File(TMP . 'cake_test_emails.log');
$log = $File->read();
$this->assertTrue(strpos($log, $result['headers']) !== false);
$this->assertTrue(strpos($log, $result['message']) !== false);
$File->delete();
CakeLog::drop('email');
}
/**
@@ -1920,7 +1918,7 @@ protected function _getEmailByNewStyleCharset($charset, $headerCharset) {
}
public function testWrapLongLine() {
$message = '<a href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "</a>";
$message = '<a href="http://cakephp.org">' . str_repeat('x', Email::LINE_LENGTH_MUST) . "</a>";
$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
@@ -1929,32 +1927,32 @@ public function testWrapLongLine() {
$this->CakeEmail->subject('Wordwrap Test');
$this->CakeEmail->config(array('empty'));
$result = $this->CakeEmail->send($message);
$expected = "<a\r\n" . 'href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - 26) . "\r\n" .
$expected = "<a\r\n" . 'href="http://cakephp.org">' . str_repeat('x', Email::LINE_LENGTH_MUST - 26) . "\r\n" .
str_repeat('x', 26) . "\r\n</a>\r\n\r\n";
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);
$str1 = "a ";
$str2 = " b";
$length = strlen($str1) + strlen($str2);
$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length - 1) . $str2;
$message = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length - 1) . $str2;
$result = $this->CakeEmail->send($message);
$expected = "{$message}\r\n\r\n";
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);
$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length) . $str2;
$message = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length) . $str2;
$result = $this->CakeEmail->send($message);
$expected = "{$message}\r\n\r\n";
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);
$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length + 1) . $str2;
$message = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length + 1) . $str2;
$result = $this->CakeEmail->send($message);
$expected = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length + 1) . sprintf("\r\n%s\r\n\r\n", trim($str2));
$expected = $str1 . str_repeat('x', Email::LINE_LENGTH_MUST - $length + 1) . sprintf("\r\n%s\r\n\r\n", trim($str2));
$this->assertEquals($expected, $result['message']);
$this->assertLineLengths($result['message']);
}
@@ -1967,7 +1965,7 @@ public function testWrapWithTagsAcrossLines() {
</table>
HTML;
$length = strlen($str);
$message = $str . str_repeat('x', CakeEmail::LINE_LENGTH_MUST + 1);
$message = $str . str_repeat('x', Email::LINE_LENGTH_MUST + 1);
$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
@@ -1986,7 +1984,7 @@ public function testWrapWithTagsAcrossLines() {
public function testWrapIncludeLessThanSign() {
$str = 'foo<bar';
$length = strlen($str);
$message = $str . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $length + 1);
$message = $str . str_repeat('x', Email::LINE_LENGTH_MUST - $length + 1);
$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
@@ -2028,8 +2026,8 @@ public function testWrapForJapaneseEncoding() {
public function assertLineLengths($message) {
$lines = explode("\r\n", $message);
foreach ($lines as $line) {
$this->assertTrue(strlen($line) <= CakeEmail::LINE_LENGTH_MUST,
'Line length exceeds the max. limit of CakeEmail::LINE_LENGTH_MUST');
$this->assertTrue(strlen($line) <= Email::LINE_LENGTH_MUST,
'Line length exceeds the max. limit of Email::LINE_LENGTH_MUST');
}
}
@@ -136,7 +136,7 @@ public function testInvalidConnection($data) {
*/
public function testSocketHost() {
try {
$this->Socket = new CakeSocket();
$this->Socket = new Socket();
$this->Socket->connect();
$this->assertEquals('127.0.0.1', $this->Socket->address());
$this->assertEquals(gethostbyaddr('127.0.0.1'), $this->Socket->host());
@@ -180,7 +180,7 @@ public function testSocketReading() {
$this->assertEquals(null, $this->Socket->read(26));
$config = array('host' => 'google.com', 'port' => 80, 'timeout' => 1);
$this->Socket = new CakeSocket($config);
$this->Socket = new Socket($config);
$this->assertTrue($this->Socket->connect());
$this->assertEquals(null, $this->Socket->read(26));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
@@ -201,7 +201,7 @@ public function testTimeOutConnection() {
$this->assertTrue($this->Socket->connect());
$config = array('host' => '127.0.0.1', 'timeout' => 0.00001);
$this->Socket = new CakeSocket($config);
$this->Socket = new Socket($config);
$this->assertFalse($this->Socket->read(1024 * 1024));
$this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError());
} catch (Error\SocketException $e) {

0 comments on commit d78e213

Please sign in to comment.
You can’t perform that action at this time.