From d78e213cf48f20ec75e1109d4e6fe8c6ca548e89 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 10 Jun 2013 22:00:33 -0400 Subject: [PATCH] Fix failing tests in Network package. --- lib/Cake/Network/Email/Email.php | 3 +- .../Test/TestApp/View/Emails/html/html.ctp | 15 +++++++++ .../Test/TestCase/Network/Email/EmailTest.php | 32 +++++++++---------- lib/Cake/Test/TestCase/Network/SocketTest.php | 6 ++-- 4 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 lib/Cake/Test/TestApp/View/Emails/html/html.ctp diff --git a/lib/Cake/Network/Email/Email.php b/lib/Cake/Network/Email/Email.php index ad456eb7c3d..3863d3d3ed8 100644 --- a/lib/Cake/Network/Email/Email.php +++ b/lib/Cake/Network/Email/Email.php @@ -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)) { diff --git a/lib/Cake/Test/TestApp/View/Emails/html/html.ctp b/lib/Cake/Test/TestApp/View/Emails/html/html.ctp new file mode 100644 index 00000000000..55bbc8db6b3 --- /dev/null +++ b/lib/Cake/Test/TestApp/View/Emails/html/html.ctp @@ -0,0 +1,15 @@ + +

HTML Ipsum Presents

Pellentesque habitant morbi tristique 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. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.

Header Level 2

  1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  2. Aliquam tincidunt mauris eu risus.

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.

Header Level 3

+

+#header h1 a {
+	display: block;
+	width: 300px;
+	height: 80px;
+}
+ + +
The tag is across multiple lines -
+

Some more Bold test.

diff --git a/lib/Cake/Test/TestCase/Network/Email/EmailTest.php b/lib/Cake/Test/TestCase/Network/Email/EmailTest.php index c3bd47a520d..529c3703310 100644 --- a/lib/Cake/Test/TestCase/Network/Email/EmailTest.php +++ b/lib/Cake/Test/TestCase/Network/Email/EmailTest.php @@ -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 = '' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . ""; + $message = '' . str_repeat('x', Email::LINE_LENGTH_MUST) . ""; $this->CakeEmail->reset(); $this->CakeEmail->transport('Debug'); @@ -1929,7 +1927,7 @@ public function testWrapLongLine() { $this->CakeEmail->subject('Wordwrap Test'); $this->CakeEmail->config(array('empty')); $result = $this->CakeEmail->send($message); - $expected = "' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - 26) . "\r\n" . + $expected = "' . str_repeat('x', Email::LINE_LENGTH_MUST - 26) . "\r\n" . str_repeat('x', 26) . "\r\n\r\n\r\n"; $this->assertEquals($expected, $result['message']); $this->assertLineLengths($result['message']); @@ -1937,24 +1935,24 @@ public function testWrapLongLine() { $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() { 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 = 'fooCakeEmail->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'); } } diff --git a/lib/Cake/Test/TestCase/Network/SocketTest.php b/lib/Cake/Test/TestCase/Network/SocketTest.php index 50580601f53..cb536794269 100644 --- a/lib/Cake/Test/TestCase/Network/SocketTest.php +++ b/lib/Cake/Test/TestCase/Network/SocketTest.php @@ -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) {