source: trunk/tests/EmailTest.php @ 599

Last change on this file since 599 was 468, checked in by anonymous, 10 years ago

Completed integrating /branches/eli_branch into /trunk. Changes include:

  • Removed closing ?> from end of files
  • Upgrade old-style contructor methods to use construct() instead.
  • Class properties and methods defined as public, private, static or protected
  • Ensure code runs under E_ALL with only mysql_* deprecated warnings
  • Search for the '@' symbol anywhere it might be used to supress runtime errors, then replace with proper error recovery.
  • Run the php cli -l option to check files for syntax errors.
  • Bring tests up-to-date with latest version and methods of PHPUnit
File size: 3.5 KB
RevLine 
[26]1<?php
[468]2
[26]3/**
[362]4 * The Strangecode Codebase - a general application development framework for PHP
5 * For details visit the project site: <http://trac.strangecode.com/codebase/>
[396]6 * Copyright 2001-2012 Strangecode, LLC
[362]7 *
8 * This file is part of The Strangecode Codebase.
[42]9 *
[362]10 * The Strangecode Codebase is free software: you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as published by the
12 * Free Software Foundation, either version 3 of the License, or (at your option)
13 * any later version.
14 *
15 * The Strangecode Codebase is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24/**
25 * PHPUnit test case for codebase/lib/Email.inc.php
26 *
[42]27 * The method skeletons below need to be filled in with
28 * real data so that the tests will run correctly. Replace
29 * all EXPECTED_VAL and PARAM strings with real data.
30 *
[26]31 * Created with PHPUnit_Skeleton on 2005-12-01
32 */
33
[468]34class EmailTest extends PHPUnit_Framework_TestCase {
35
[26]36    var $Email;
37
38    function setUp()
39    {
40        require dirname(__FILE__) . '/_config.inc.php';
41        require_once '../lib/Email.inc.php';
[468]42        $this->Email = new Email();
[26]43    }
44
45    function tearDown()
46    {
47        unset($this->Email);
48    }
49
50//     function testsetparam()
51//     {
52//         $result   = $this->Email->setparam(PARAM);
53//         $expected = EXPECTED_VAL;
54//         $this->assertEquals($expected, $result);
55//     }
[42]56//
[26]57//     function testgetparam()
58//     {
59//         $result   = $this->Email->getparam(PARAM);
60//         $expected = EXPECTED_VAL;
61//         $this->assertEquals($expected, $result);
62//     }
[42]63//
[26]64//     function testsettemplate()
65//     {
66//         $result   = $this->Email->settemplate(PARAM);
67//         $expected = EXPECTED_VAL;
68//         $this->assertEquals($expected, $result);
69//     }
[42]70//
[26]71//     function testsetstring()
72//     {
73//         $result   = $this->Email->setstring(PARAM);
74//         $expected = EXPECTED_VAL;
75//         $this->assertEquals($expected, $result);
76//     }
[42]77//
[26]78//     function testreplace()
79//     {
80//         $result   = $this->Email->replace(PARAM);
81//         $expected = EXPECTED_VAL;
82//         $this->assertEquals($expected, $result);
83//     }
[42]84//
[26]85//     function testsend()
86//     {
87//         $result   = $this->Email->send(PARAM);
88//         $expected = EXPECTED_VAL;
89//         $this->assertEquals($expected, $result);
90//     }
91
92    function testvalidemail()
93    {
94        $testpool = file('_email_test_addresses.txt');
[42]95
[26]96        $gc = 0;
97        $bc = 0;
98        $good = array();
99        $bad = array();
100        if (is_array($testpool) && !empty($testpool)) {
101            foreach ($testpool as $a) {
102                if ($this->Email->validEmail($a)) {
103                    $good[] = trim($a);
104                    $gc++;
105                } else {
106                    $bad[] = trim($a);
107                    $bc++;
108                }
109            }
110        }
[399]111        $this->assertEquals(45, $gc, 'Unexpected number of valid emails found.');
112        $this->assertEquals(45, $bc, 'Unexpected number of invalid emails found.');
[154]113        // echo "Good addresses: $gc\n";
114        // echo "Bad addresses: $bc\n";
[399]115        // echo join("\n", $bad);
116        // echo "\n";
[26]117    }
118
119}
Note: See TracBrowser for help on using the repository browser.