cakephp2-php8/lib/Cake/tests/Case/Network/CakeEmailTest.php
2011-04-12 22:15:45 -04:00

150 lines
4 KiB
PHP

<?php
/**
* CakeEmailTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake.tests.cases.libs
* @since CakePHP(tm) v 2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'CakeEmail');
/**
* CakeEmailTest class
*
* @package cake.tests.cases.libs
*/
class CakeEmailTest extends CakeTestCase {
/**
* setUp
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->CakeEmail = new CakeEmail();
}
/**
* testFrom method
*
* @return void
*/
public function testFrom() {
$this->assertIdentical($this->CakeEmail->getFrom(), array());
$this->CakeEmail->setFrom('cake@cakephp.org');
$expected = array('cake@cakephp.org' => 'cake@cakephp.org');
$this->assertIdentical($this->CakeEmail->getFrom(), $expected);
$this->CakeEmail->setFrom(array('cake@cakephp.org'));
$this->assertIdentical($this->CakeEmail->getFrom(), $expected);
$this->CakeEmail->setFrom('cake@cakephp.org', 'CakePHP');
$expected = array('cake@cakephp.org' => 'CakePHP');
$this->assertIdentical($this->CakeEmail->getFrom(), $expected);
$this->CakeEmail->setFrom(array('cake@cakephp.org' => 'CakePHP'));
$this->assertIdentical($this->CakeEmail->getFrom(), $expected);
}
/**
* testTo method
*
* @return void
*/
public function testTo() {
$this->assertIdentical($this->CakeEmail->getTo(), array());
$this->CakeEmail->setTo('cake@cakephp.org');
$expected = array('cake@cakephp.org' => 'cake@cakephp.org');
$this->assertIdentical($this->CakeEmail->getTo(), $expected);
$this->CakeEmail->setTo('cake@cakephp.org', 'CakePHP');
$expected = array('cake@cakephp.org' => 'CakePHP');
$this->assertIdentical($this->CakeEmail->getTo(), $expected);
$list = array(
'cake@cakephp.org' => 'Cake PHP',
'cake-php@googlegroups.com' => 'Cake Groups',
'root@cakephp.org'
);
$this->CakeEmail->setTo($list);
$expected = array(
'cake@cakephp.org' => 'Cake PHP',
'cake-php@googlegroups.com' => 'Cake Groups',
'root@cakephp.org' => 'root@cakephp.org'
);
$this->assertIdentical($this->CakeEmail->getTo(), $expected);
$this->CakeEmail->addTo('jrbasso@cakephp.org');
$this->CakeEmail->addTo('mark_story@cakephp.org', 'Mark Story');
$this->CakeEmail->addTo(array('phpnut@cakephp.org' => 'PhpNut', 'jose_zap@cakephp.org'));
$expected = array(
'cake@cakephp.org' => 'Cake PHP',
'cake-php@googlegroups.com' => 'Cake Groups',
'root@cakephp.org' => 'root@cakephp.org',
'jrbasso@cakephp.org' => 'jrbasso@cakephp.org',
'mark_story@cakephp.org' => 'Mark Story',
'phpnut@cakephp.org' => 'PhpNut',
'jose_zap@cakephp.org' => 'jose_zap@cakephp.org'
);
$this->assertIdentical($this->CakeEmail->getTo(), $expected);
}
/**
* testSubject method
*
* @return void
*/
public function testSubject() {
$this->CakeEmail->setSubject('You have a new message.');
$this->assertIdentical($this->CakeEmail->getSubject(), 'You have a new message.');
$this->CakeEmail->setSubject(1);
$this->assertIdentical($this->CakeEmail->getSubject(), '1');
$this->CakeEmail->setSubject(array('something'));
$this->assertIdentical($this->CakeEmail->getSubject(), 'Array');
}
/**
* testHeaders method
*
* @return void
*/
public function testHeaders() {
}
/**
* testSend method
*
* @return void
*/
public function testSend() {
}
/**
* testReset method
*
* @return void
*/
public function testReset() {
$this->CakeEmail->setTo('cake@cakephp.org');
$this->assertIdentical($this->CakeEmail->getTo(), array('cake@cakephp.org' => 'cake@cakephp.org'));
$this->CakeEmail->reset();
$this->assertIdentical($this->CakeEmail->getTo(), array());
}
}