git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2720 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
137 lines
4.1 KiB
PHP
137 lines
4.1 KiB
PHP
<?php
|
|
/** DomFramework - Tests
|
|
@package domframework
|
|
@author Dominique Fournier <dominique@fournier38.fr> */
|
|
|
|
/** Test the mail.php file */
|
|
class test_mail extends PHPUnit_Framework_TestCase
|
|
{
|
|
public function test_setBodyText1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$mail->setBodyText ("TEST");
|
|
$res = $mail->getMail ();
|
|
$this->assertRegExp ("#TEST\n$#", $res);
|
|
}
|
|
|
|
public function test_setBodyHTML1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$mail->setBodyHTML ("TEST");
|
|
$res = $mail->getMail ();
|
|
$this->assertRegExp ("#^\r\nTEST\n$#m", $res);
|
|
}
|
|
|
|
public function test_setGetBodyText1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$mail->setBodyText ("TEST");
|
|
$res = $mail->getBodyText ();
|
|
$this->assertSame ("TEST\n", $res);
|
|
}
|
|
|
|
public function test_setGetBodyHtml1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$mail->setBodyHtml ("TEST");
|
|
$res = $mail->getBodyHtml ();
|
|
$this->assertSame ("TEST\n", $res);
|
|
}
|
|
|
|
public function test_setFrom1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$mail->setFrom ("test@example.com", "Test Exa1mple Com");
|
|
$res = $mail->getFrom ();
|
|
$this->assertSame ("Test Exa1mple Com <test@example.com>\r\n", $res);
|
|
}
|
|
|
|
public function test_addTo1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$mail->addTo ("test@example.com", "Test Exa1mple Com");
|
|
$res = $mail->getTo ();
|
|
$this->assertSame ("Test Exa1mple Com <test@example.com>\r\n", $res);
|
|
}
|
|
|
|
public function test_addTo2 ()
|
|
{
|
|
$mail = new mail ();
|
|
$mail->addTo ("test@example.com", "Test Exa1mple Com");
|
|
$res = $mail->getMail ();
|
|
$this->assertRegexp ("#^To: Test Exa1mple Com <test@example.com>\r$#m", $res);
|
|
}
|
|
|
|
public function test_setDateTimestamp1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$time = time ();
|
|
$mail->setDateTimestamp ($time);
|
|
$res = $mail->getDateTimestamp ();
|
|
$this->assertSame ($res, $time);
|
|
}
|
|
|
|
public function test_setDateTimestamp2 ()
|
|
{
|
|
$mail = new mail ();
|
|
$time = time ();
|
|
$mail->setDateTimestamp ($time);
|
|
$res = $mail->getMail ();
|
|
$this->assertRegexp ("#^Date: ".preg_quote (date ("r", $time))."\r$#m", $res);
|
|
}
|
|
|
|
public function test_convertPeopleToArray1 ()
|
|
{
|
|
$mail = new mail ();
|
|
$res = $mail->convertPeopleToArray ("toto toto <toto@toto.com>");
|
|
$this->assertSame ($res, array (array ("name"=>"toto toto",
|
|
"mail"=>"toto@toto.com")));
|
|
}
|
|
|
|
public function test_convertPeopleToArray2 ()
|
|
{
|
|
$mail = new mail ();
|
|
$res = $mail->convertPeopleToArray ("<toto@toto.com>");
|
|
$this->assertSame ($res, array (array ("name"=>"",
|
|
"mail"=>"toto@toto.com")));
|
|
}
|
|
|
|
public function test_convertPeopleToArray3 ()
|
|
{
|
|
$mail = new mail ();
|
|
$res = $mail->convertPeopleToArray ("toto@toto.com,titi@titi.com");
|
|
$this->assertSame ($res, array (array ("name" => "",
|
|
"mail" => "toto@toto.com"),
|
|
array ("name" => "",
|
|
"mail" => "titi@titi.com")));
|
|
}
|
|
|
|
public function test_convertPeopleToArray4 ()
|
|
{
|
|
$mail = new mail ();
|
|
$res = $mail->convertPeopleToArray ("toto@toto.com");
|
|
$this->assertSame ($res, array (array ("name"=>"",
|
|
"mail"=>"toto@toto.com")));
|
|
}
|
|
|
|
public function test_convertPeopleToArray5 ()
|
|
{
|
|
$mail = new mail ();
|
|
$res = $mail->convertPeopleToArray (" <toto@toto.com> , <titi@titi.com>");
|
|
$this->assertSame ($res, array (array ("name" => "",
|
|
"mail" => "toto@toto.com"),
|
|
array ("name" => "",
|
|
"mail" => "titi@titi.com")));
|
|
}
|
|
|
|
public function test_convertPeopleToArray6 ()
|
|
{
|
|
$mail = new mail ();
|
|
$res = $mail->convertPeopleToArray ("ToTo <toto@toto.com> , <titi@titi.com>");
|
|
$this->assertSame ($res, array (array ("name" => "ToTo",
|
|
"mail" => "toto@toto.com"),
|
|
array ("name" => "",
|
|
"mail" => "titi@titi.com")));
|
|
}
|
|
}
|