[26] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * PHPUnit test case for Email |
---|
[42] | 4 | * |
---|
| 5 | * The method skeletons below need to be filled in with |
---|
| 6 | * real data so that the tests will run correctly. Replace |
---|
| 7 | * all EXPECTED_VAL and PARAM strings with real data. |
---|
| 8 | * |
---|
[26] | 9 | * Created with PHPUnit_Skeleton on 2005-12-01 |
---|
| 10 | */ |
---|
| 11 | require_once 'PHPUnit.php'; |
---|
| 12 | class EmailTest extends PHPUnit_TestCase { |
---|
| 13 | |
---|
| 14 | var $Email; |
---|
| 15 | |
---|
| 16 | function EmailTest($name) |
---|
| 17 | { |
---|
| 18 | $this->PHPUnit_TestCase($name); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | function setUp() |
---|
| 22 | { |
---|
| 23 | require dirname(__FILE__) . '/_config.inc.php'; |
---|
| 24 | require_once '../lib/Email.inc.php'; |
---|
| 25 | $this->Email =& new Email(); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | function tearDown() |
---|
| 29 | { |
---|
| 30 | unset($this->Email); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | // function testsetparam() |
---|
| 34 | // { |
---|
| 35 | // $result = $this->Email->setparam(PARAM); |
---|
| 36 | // $expected = EXPECTED_VAL; |
---|
| 37 | // $this->assertEquals($expected, $result); |
---|
| 38 | // } |
---|
[42] | 39 | // |
---|
[26] | 40 | // function testgetparam() |
---|
| 41 | // { |
---|
| 42 | // $result = $this->Email->getparam(PARAM); |
---|
| 43 | // $expected = EXPECTED_VAL; |
---|
| 44 | // $this->assertEquals($expected, $result); |
---|
| 45 | // } |
---|
[42] | 46 | // |
---|
[26] | 47 | // function testsettemplate() |
---|
| 48 | // { |
---|
| 49 | // $result = $this->Email->settemplate(PARAM); |
---|
| 50 | // $expected = EXPECTED_VAL; |
---|
| 51 | // $this->assertEquals($expected, $result); |
---|
| 52 | // } |
---|
[42] | 53 | // |
---|
[26] | 54 | // function testsetstring() |
---|
| 55 | // { |
---|
| 56 | // $result = $this->Email->setstring(PARAM); |
---|
| 57 | // $expected = EXPECTED_VAL; |
---|
| 58 | // $this->assertEquals($expected, $result); |
---|
| 59 | // } |
---|
[42] | 60 | // |
---|
[26] | 61 | // function testreplace() |
---|
| 62 | // { |
---|
| 63 | // $result = $this->Email->replace(PARAM); |
---|
| 64 | // $expected = EXPECTED_VAL; |
---|
| 65 | // $this->assertEquals($expected, $result); |
---|
| 66 | // } |
---|
[42] | 67 | // |
---|
[26] | 68 | // function testsend() |
---|
| 69 | // { |
---|
| 70 | // $result = $this->Email->send(PARAM); |
---|
| 71 | // $expected = EXPECTED_VAL; |
---|
| 72 | // $this->assertEquals($expected, $result); |
---|
| 73 | // } |
---|
| 74 | |
---|
| 75 | function testvalidemail() |
---|
| 76 | { |
---|
| 77 | $testpool = file('_email_test_addresses.txt'); |
---|
[42] | 78 | |
---|
[26] | 79 | $gc = 0; |
---|
| 80 | $bc = 0; |
---|
| 81 | $good = array(); |
---|
| 82 | $bad = array(); |
---|
| 83 | if (is_array($testpool) && !empty($testpool)) { |
---|
| 84 | foreach ($testpool as $a) { |
---|
| 85 | if ($this->Email->validEmail($a)) { |
---|
| 86 | $good[] = trim($a); |
---|
| 87 | $gc++; |
---|
| 88 | } else { |
---|
| 89 | $bad[] = trim($a); |
---|
| 90 | $bc++; |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | $this->assertEquals(41, $gc, 'Unexpected good count.'); |
---|
| 95 | $this->assertEquals(47, $bc, 'Unexpected bad count.'); |
---|
[157] | 96 | // echo "Good addresses: $gc\n"; |
---|
| 97 | // echo "Bad addresses: $bc\n"; |
---|
[26] | 98 | // echo join("\n", $bad); |
---|
| 99 | // echo "\n"; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | } |
---|
| 103 | // Running the test. |
---|
| 104 | $suite = new PHPUnit_TestSuite('EmailTest'); |
---|
| 105 | $result = PHPUnit::run($suite); |
---|
| 106 | echo $result->toString(); |
---|
| 107 | ?> |
---|