Correct a few more misleading assert orders.

This commit is contained in:
euromark 2014-09-24 14:34:24 +02:00
parent fce16189d5
commit 9c8ab826bf

View file

@ -168,21 +168,21 @@ class CakeEmailTest extends CakeTestCase {
* @return void
*/
public function testFrom() {
$this->assertSame($this->CakeEmail->from(), array());
$this->assertSame(array(), $this->CakeEmail->from());
$this->CakeEmail->from('cake@cakephp.org');
$expected = array('cake@cakephp.org' => 'cake@cakephp.org');
$this->assertSame($this->CakeEmail->from(), $expected);
$this->assertSame($expected, $this->CakeEmail->from());
$this->CakeEmail->from(array('cake@cakephp.org'));
$this->assertSame($this->CakeEmail->from(), $expected);
$this->assertSame($expected, $this->CakeEmail->from());
$this->CakeEmail->from('cake@cakephp.org', 'CakePHP');
$expected = array('cake@cakephp.org' => 'CakePHP');
$this->assertSame($this->CakeEmail->from(), $expected);
$this->assertSame($expected, $this->CakeEmail->from());
$result = $this->CakeEmail->from(array('cake@cakephp.org' => 'CakePHP'));
$this->assertSame($this->CakeEmail->from(), $expected);
$this->assertSame($expected, $this->CakeEmail->from());
$this->assertSame($this->CakeEmail, $result);
$this->setExpectedException('SocketException');
@ -215,20 +215,20 @@ class CakeEmailTest extends CakeTestCase {
*/
public function testSender() {
$this->CakeEmail->reset();
$this->assertSame($this->CakeEmail->sender(), array());
$this->assertSame(array(), $this->CakeEmail->sender());
$this->CakeEmail->sender('cake@cakephp.org', 'Name');
$expected = array('cake@cakephp.org' => 'Name');
$this->assertSame($this->CakeEmail->sender(), $expected);
$this->assertSame($expected, $this->CakeEmail->sender());
$headers = $this->CakeEmail->getHeaders(array('from' => true, 'sender' => true));
$this->assertFalse($headers['From']);
$this->assertSame($headers['Sender'], 'Name <cake@cakephp.org>');
$this->assertSame('Name <cake@cakephp.org>', $headers['Sender']);
$this->CakeEmail->from('cake@cakephp.org', 'CakePHP');
$headers = $this->CakeEmail->getHeaders(array('from' => true, 'sender' => true));
$this->assertSame($headers['From'], 'CakePHP <cake@cakephp.org>');
$this->assertSame($headers['Sender'], '');
$this->assertSame('CakePHP <cake@cakephp.org>', $headers['From']);
$this->assertSame('', $headers['Sender']);
}
/**
@ -237,16 +237,16 @@ class CakeEmailTest extends CakeTestCase {
* @return void
*/
public function testTo() {
$this->assertSame($this->CakeEmail->to(), array());
$this->assertSame(array(), $this->CakeEmail->to());
$result = $this->CakeEmail->to('cake@cakephp.org');
$expected = array('cake@cakephp.org' => 'cake@cakephp.org');
$this->assertSame($this->CakeEmail->to(), $expected);
$this->assertSame($expected, $this->CakeEmail->to());
$this->assertSame($this->CakeEmail, $result);
$this->CakeEmail->to('cake@cakephp.org', 'CakePHP');
$expected = array('cake@cakephp.org' => 'CakePHP');
$this->assertSame($this->CakeEmail->to(), $expected);
$this->assertSame($expected, $this->CakeEmail->to());
$list = array(
'root@localhost' => 'root',
@ -263,7 +263,7 @@ class CakeEmailTest extends CakeTestCase {
'cake-php@googlegroups.com' => 'Cake Groups',
'root@cakephp.org' => 'root@cakephp.org'
);
$this->assertSame($this->CakeEmail->to(), $expected);
$this->assertSame($expected, $this->CakeEmail->to());
$this->CakeEmail->addTo('jrbasso@cakephp.org');
$this->CakeEmail->addTo('mark_story@cakephp.org', 'Mark Story');
@ -281,7 +281,7 @@ class CakeEmailTest extends CakeTestCase {
'phpnut@cakephp.org' => 'PhpNut',
'jose_zap@cakephp.org' => 'jose_zap@cakephp.org'
);
$this->assertSame($this->CakeEmail->to(), $expected);
$this->assertSame($expected, $this->CakeEmail->to());
$this->assertSame($this->CakeEmail, $result);
}
@ -501,10 +501,10 @@ class CakeEmailTest extends CakeTestCase {
$result = $this->CakeEmail->messageId('<my-email@localhost>');
$this->assertSame($this->CakeEmail, $result);
$result = $this->CakeEmail->getHeaders();
$this->assertSame($result['Message-ID'], '<my-email@localhost>');
$this->assertSame('<my-email@localhost>', $result['Message-ID']);
$result = $this->CakeEmail->messageId();
$this->assertSame($result, '<my-email@localhost>');
$this->assertSame('<my-email@localhost>', $result);
}
/**
@ -560,16 +560,16 @@ class CakeEmailTest extends CakeTestCase {
*/
public function testSubject() {
$this->CakeEmail->subject('You have a new message.');
$this->assertSame($this->CakeEmail->subject(), 'You have a new message.');
$this->assertSame('You have a new message.', $this->CakeEmail->subject());
$this->CakeEmail->subject('You have a new message, I think.');
$this->assertSame($this->CakeEmail->subject(), 'You have a new message, I think.');
$this->CakeEmail->subject(1);
$this->assertSame($this->CakeEmail->subject(), '1');
$this->assertSame('1', $this->CakeEmail->subject());
$this->CakeEmail->subject('هذه رسالة بعنوان طويل مرسل للمستلم');
$expected = '=?UTF-8?B?2YfYsNmHINix2LPYp9mE2Kkg2KjYudmG2YjYp9mGINi32YjZitmEINmF2LE=?=' . "\r\n" . ' =?UTF-8?B?2LPZhCDZhNmE2YXYs9iq2YTZhQ==?=';
$this->assertSame($this->CakeEmail->subject(), $expected);
$this->assertSame($expected, $this->CakeEmail->subject());
}
/**
@ -584,13 +584,13 @@ class CakeEmailTest extends CakeTestCase {
$this->CakeEmail->headerCharset = 'ISO-2022-JP';
$this->CakeEmail->subject('日本語のSubjectにも対応するよ');
$expected = '=?ISO-2022-JP?B?GyRCRnxLXDhsJE4bKEJTdWJqZWN0GyRCJEskYkJQMX4kOSRrJGgbKEI=?=';
$this->assertSame($this->CakeEmail->subject(), $expected);
$this->assertSame($expected, $this->CakeEmail->subject());
$this->CakeEmail->subject('長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう');
$expected = "=?ISO-2022-JP?B?GyRCRDkkJEQ5JCREOSQkGyhCU3ViamVjdBskQiROPmw5ZyRPGyhCZm9s?=\r\n" .
" =?ISO-2022-JP?B?ZGluZxskQiQ5JGskTiQsQDUkNyQkJHMkQCQxJEkkJCRDJD8kJCRJGyhC?=\r\n" .
" =?ISO-2022-JP?B?GyRCJCYkSiRrJHMkQCRtJCYhKRsoQg==?=";
$this->assertSame($this->CakeEmail->subject(), $expected);
$this->assertSame($expected, $this->CakeEmail->subject());
}
/**
@ -609,7 +609,7 @@ class CakeEmailTest extends CakeTestCase {
'Content-Type' => 'text/plain; charset=UTF-8',
'Content-Transfer-Encoding' => '8bit'
);
$this->assertSame($this->CakeEmail->getHeaders(), $expected);
$this->assertSame($expected, $this->CakeEmail->getHeaders());
$this->CakeEmail->addHeaders(array('X-Something' => 'very nice', 'X-Other' => 'cool'));
$expected = array(
@ -621,10 +621,10 @@ class CakeEmailTest extends CakeTestCase {
'Content-Type' => 'text/plain; charset=UTF-8',
'Content-Transfer-Encoding' => '8bit'
);
$this->assertSame($this->CakeEmail->getHeaders(), $expected);
$this->assertSame($expected, $this->CakeEmail->getHeaders());
$this->CakeEmail->from('cake@cakephp.org');
$this->assertSame($this->CakeEmail->getHeaders(), $expected);
$this->assertSame($expected, $this->CakeEmail->getHeaders());
$expected = array(
'From' => 'cake@cakephp.org',
@ -636,11 +636,11 @@ class CakeEmailTest extends CakeTestCase {
'Content-Type' => 'text/plain; charset=UTF-8',
'Content-Transfer-Encoding' => '8bit'
);
$this->assertSame($this->CakeEmail->getHeaders(array('from' => true)), $expected);
$this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true)));
$this->CakeEmail->from('cake@cakephp.org', 'CakePHP');
$expected['From'] = 'CakePHP <cake@cakephp.org>';
$this->assertSame($this->CakeEmail->getHeaders(array('from' => true)), $expected);
$this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true)));
$this->CakeEmail->to(array('cake@cakephp.org', 'php@cakephp.org' => 'CakePHP'));
$expected = array(
@ -654,7 +654,7 @@ class CakeEmailTest extends CakeTestCase {
'Content-Type' => 'text/plain; charset=UTF-8',
'Content-Transfer-Encoding' => '8bit'
);
$this->assertSame($this->CakeEmail->getHeaders(array('from' => true, 'to' => true)), $expected);
$this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true, 'to' => true)));
$this->CakeEmail->charset = 'ISO-2022-JP';
$expected = array(
@ -668,7 +668,7 @@ class CakeEmailTest extends CakeTestCase {
'Content-Type' => 'text/plain; charset=ISO-2022-JP',
'Content-Transfer-Encoding' => '7bit'
);
$this->assertSame($this->CakeEmail->getHeaders(array('from' => true, 'to' => true)), $expected);
$this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true, 'to' => true)));
$result = $this->CakeEmail->setHeaders(array());
$this->assertInstanceOf('CakeEmail', $result);
@ -719,19 +719,19 @@ class CakeEmailTest extends CakeTestCase {
public function testTemplate() {
$this->CakeEmail->template('template', 'layout');
$expected = array('template' => 'template', 'layout' => 'layout');
$this->assertSame($this->CakeEmail->template(), $expected);
$this->assertSame($expected, $this->CakeEmail->template());
$this->CakeEmail->template('new_template');
$expected = array('template' => 'new_template', 'layout' => 'layout');
$this->assertSame($this->CakeEmail->template(), $expected);
$this->assertSame($expected, $this->CakeEmail->template());
$this->CakeEmail->template('template', null);
$expected = array('template' => 'template', 'layout' => null);
$this->assertSame($this->CakeEmail->template(), $expected);
$this->assertSame($expected, $this->CakeEmail->template());
$this->CakeEmail->template(null, null);
$expected = array('template' => null, 'layout' => null);
$this->assertSame($this->CakeEmail->template(), $expected);
$this->assertSame($expected, $this->CakeEmail->template());
}
/**
@ -740,7 +740,7 @@ class CakeEmailTest extends CakeTestCase {
* @return void
*/
public function testTheme() {
$this->assertSame(null, $this->CakeEmail->theme());
$this->assertNull($this->CakeEmail->theme());
$this->CakeEmail->theme('default');
$expected = 'default';
@ -753,16 +753,16 @@ class CakeEmailTest extends CakeTestCase {
* @return void
*/
public function testViewVars() {
$this->assertSame($this->CakeEmail->viewVars(), array());
$this->assertSame(array(), $this->CakeEmail->viewVars());
$this->CakeEmail->viewVars(array('value' => 12345));
$this->assertSame($this->CakeEmail->viewVars(), array('value' => 12345));
$this->assertSame(array('value' => 12345), $this->CakeEmail->viewVars());
$this->CakeEmail->viewVars(array('name' => 'CakePHP'));
$this->assertSame($this->CakeEmail->viewVars(), array('value' => 12345, 'name' => 'CakePHP'));
$this->assertSame(array('value' => 12345, 'name' => 'CakePHP'), $this->CakeEmail->viewVars());
$this->CakeEmail->viewVars(array('value' => 4567));
$this->assertSame($this->CakeEmail->viewVars(), array('value' => 4567, 'name' => 'CakePHP'));
$this->assertSame(array('value' => 4567, 'name' => 'CakePHP'), $this->CakeEmail->viewVars());
}
/**
@ -778,10 +778,10 @@ class CakeEmailTest extends CakeTestCase {
'mimetype' => 'application/octet-stream'
)
);
$this->assertSame($this->CakeEmail->attachments(), $expected);
$this->assertSame($expected, $this->CakeEmail->attachments());
$this->CakeEmail->attachments(array());
$this->assertSame($this->CakeEmail->attachments(), array());
$this->assertSame(array(), $this->CakeEmail->attachments());
$this->CakeEmail->attachments(array(
array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain')
@ -795,7 +795,7 @@ class CakeEmailTest extends CakeTestCase {
'other.txt' => array('file' => CAKE . 'bootstrap.php', 'mimetype' => 'application/octet-stream'),
'license' => array('file' => CAKE . 'LICENSE.txt', 'mimetype' => 'application/octet-stream')
);
$this->assertSame($this->CakeEmail->attachments(), $expected);
$this->assertSame($expected, $this->CakeEmail->attachments());
$this->setExpectedException('SocketException');
$this->CakeEmail->attachments(array(array('nofile' => CAKE . 'basics.php', 'mimetype' => 'text/plain')));
@ -809,7 +809,7 @@ class CakeEmailTest extends CakeTestCase {
public function testTransport() {
$result = $this->CakeEmail->transport('Debug');
$this->assertSame($this->CakeEmail, $result);
$this->assertSame($this->CakeEmail->transport(), 'Debug');
$this->assertSame('Debug', $this->CakeEmail->transport());
$result = $this->CakeEmail->transportClass();
$this->assertInstanceOf('DebugTransport', $result);
@ -840,11 +840,11 @@ class CakeEmailTest extends CakeTestCase {
$config = array('test' => 'ok', 'test2' => true);
$this->CakeEmail->config($config);
$this->assertSame($transportClass->config(), $config);
$this->assertSame($this->CakeEmail->config(), $config);
$this->assertSame($config, $transportClass->config());
$this->assertSame($config, $this->CakeEmail->config());
$this->CakeEmail->config(array());
$this->assertSame($transportClass->config(), $config);
$this->assertSame($config, $transportClass->config());
$config = array('test' => 'test@example.com');
$this->CakeEmail->config($config);
@ -959,7 +959,7 @@ class CakeEmailTest extends CakeTestCase {
$result = $this->CakeEmail->send("Other body");
$expected = "Other body\r\n\r\n";
$this->assertSame($result['message'], $expected);
$this->assertSame($expected, $result['message']);
$this->assertTrue((bool)strpos($result['headers'], 'Message-ID: '));
$this->assertTrue((bool)strpos($result['headers'], 'To: '));
@ -971,7 +971,7 @@ class CakeEmailTest extends CakeTestCase {
$this->CakeEmail->config(array('empty'));
$result = $this->CakeEmail->send(array('Sending content', 'As array'));
$expected = "Sending content\r\nAs array\r\n\r\n\r\n";
$this->assertSame($result['message'], $expected);
$this->assertSame($expected, $result['message']);
}
/**