[26] | 1 | <?php |
---|
| 2 | /** |
---|
[362] | 3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
| 4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
[376] | 5 | * Copyright 2001-2010 Strangecode, LLC |
---|
[362] | 6 | * |
---|
| 7 | * This file is part of The Strangecode Codebase. |
---|
[42] | 8 | * |
---|
[362] | 9 | * The Strangecode Codebase is free software: you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License as published by the |
---|
| 11 | * Free Software Foundation, either version 3 of the License, or (at your option) |
---|
| 12 | * any later version. |
---|
| 13 | * |
---|
| 14 | * The Strangecode Codebase is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
| 17 | * details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License along with |
---|
| 20 | * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | /** |
---|
| 24 | * PHPUnit test case for codebase/lib/Email.inc.php |
---|
| 25 | * |
---|
[42] | 26 | * The method skeletons below need to be filled in with |
---|
| 27 | * real data so that the tests will run correctly. Replace |
---|
| 28 | * all EXPECTED_VAL and PARAM strings with real data. |
---|
| 29 | * |
---|
[26] | 30 | * Created with PHPUnit_Skeleton on 2005-12-01 |
---|
| 31 | */ |
---|
| 32 | require_once 'PHPUnit.php'; |
---|
| 33 | class EmailTest extends PHPUnit_TestCase { |
---|
| 34 | |
---|
| 35 | var $Email; |
---|
| 36 | |
---|
| 37 | function EmailTest($name) |
---|
| 38 | { |
---|
| 39 | $this->PHPUnit_TestCase($name); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | function setUp() |
---|
| 43 | { |
---|
| 44 | require dirname(__FILE__) . '/_config.inc.php'; |
---|
| 45 | require_once '../lib/Email.inc.php'; |
---|
| 46 | $this->Email =& new Email(); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | function tearDown() |
---|
| 50 | { |
---|
| 51 | unset($this->Email); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | // function testsetparam() |
---|
| 55 | // { |
---|
| 56 | // $result = $this->Email->setparam(PARAM); |
---|
| 57 | // $expected = EXPECTED_VAL; |
---|
| 58 | // $this->assertEquals($expected, $result); |
---|
| 59 | // } |
---|
[42] | 60 | // |
---|
[26] | 61 | // function testgetparam() |
---|
| 62 | // { |
---|
| 63 | // $result = $this->Email->getparam(PARAM); |
---|
| 64 | // $expected = EXPECTED_VAL; |
---|
| 65 | // $this->assertEquals($expected, $result); |
---|
| 66 | // } |
---|
[42] | 67 | // |
---|
[26] | 68 | // function testsettemplate() |
---|
| 69 | // { |
---|
| 70 | // $result = $this->Email->settemplate(PARAM); |
---|
| 71 | // $expected = EXPECTED_VAL; |
---|
| 72 | // $this->assertEquals($expected, $result); |
---|
| 73 | // } |
---|
[42] | 74 | // |
---|
[26] | 75 | // function testsetstring() |
---|
| 76 | // { |
---|
| 77 | // $result = $this->Email->setstring(PARAM); |
---|
| 78 | // $expected = EXPECTED_VAL; |
---|
| 79 | // $this->assertEquals($expected, $result); |
---|
| 80 | // } |
---|
[42] | 81 | // |
---|
[26] | 82 | // function testreplace() |
---|
| 83 | // { |
---|
| 84 | // $result = $this->Email->replace(PARAM); |
---|
| 85 | // $expected = EXPECTED_VAL; |
---|
| 86 | // $this->assertEquals($expected, $result); |
---|
| 87 | // } |
---|
[42] | 88 | // |
---|
[26] | 89 | // function testsend() |
---|
| 90 | // { |
---|
| 91 | // $result = $this->Email->send(PARAM); |
---|
| 92 | // $expected = EXPECTED_VAL; |
---|
| 93 | // $this->assertEquals($expected, $result); |
---|
| 94 | // } |
---|
| 95 | |
---|
| 96 | function testvalidemail() |
---|
| 97 | { |
---|
| 98 | $testpool = file('_email_test_addresses.txt'); |
---|
[42] | 99 | |
---|
[26] | 100 | $gc = 0; |
---|
| 101 | $bc = 0; |
---|
| 102 | $good = array(); |
---|
| 103 | $bad = array(); |
---|
| 104 | if (is_array($testpool) && !empty($testpool)) { |
---|
| 105 | foreach ($testpool as $a) { |
---|
| 106 | if ($this->Email->validEmail($a)) { |
---|
| 107 | $good[] = trim($a); |
---|
| 108 | $gc++; |
---|
| 109 | } else { |
---|
| 110 | $bad[] = trim($a); |
---|
| 111 | $bc++; |
---|
| 112 | } |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | $this->assertEquals(41, $gc, 'Unexpected good count.'); |
---|
| 116 | $this->assertEquals(47, $bc, 'Unexpected bad count.'); |
---|
[154] | 117 | // echo "Good addresses: $gc\n"; |
---|
| 118 | // echo "Bad addresses: $bc\n"; |
---|
[26] | 119 | // echo join("\n", $bad); |
---|
| 120 | // echo "\n"; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | } |
---|
| 124 | // Running the test. |
---|
| 125 | $suite = new PHPUnit_TestSuite('EmailTest'); |
---|
| 126 | $result = PHPUnit::run($suite); |
---|
| 127 | echo $result->toString(); |
---|
| 128 | ?> |
---|