File: IdentificationTest.php

package info (click to toggle)
php-horde-mail 2.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 320 kB
  • ctags: 582
  • sloc: php: 2,850; xml: 647; sh: 3; makefile: 2
file content (81 lines) | stat: -rw-r--r-- 2,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
 * Copyright 2012-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/licenses/bsd.
 *
 * @category   Horde
 * @copyright  2012-2014 Horde LLC
 * @license    http://www.horde.org/licenses/bsd New BSD License
 * @package    Mail
 * @subpackage UnitTests
 */

/**
 * Test identification fields parsing code.
 *
 * @author     Michael Slusarz <slusarz@horde.org>
 * @category   Horde
 * @copyright  2012-2014 Horde LLC
 * @ignore
 * @license    http://www.horde.org/licenses/bsd New BSD License
 * @package    Mail
 * @subpackage UnitTests
 */
class Horde_Mail_IdentificationTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider provider
     */
    public function testParsing($value, $count)
    {
        $ob = new Horde_Mail_Rfc822_Identification($value);

        $this->assertEquals(
            $count,
            count($ob->ids)
        );
    }

    public function provider()
    {
        return array(
            array(
                '<foo@example.com> <foo2@example.com> <foo3@example.com>',
                3
            ),
            array(
                '<foo@example.com><foo2@example.com><foo3@example.com>',
                3
            ),
            array(
                '<foo@example.com>, <foo2@example.com>,<foo3@example.com>',
                3
            ),
            array(
                '<foo@example.com>, <foo2@example.com>,<foo3@example.com> <foo4@example.com>     <foo5@example.com>  ',
                5
            ),
            // Bug #11953
            array(
                '<foo@example@example.com>',
                1
            ),
            // Parse non-compliant IDs
            array(
                'foo@example.com',
                1
            ),
            array(
                'foo@example.com  <foo2@example.com>',
                2
            ),
            array(
                'foo@example.com, <foo2@example.com>',
                2
            )
        );
    }

}