File: GroupTest.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 (74 lines) | stat: -rw-r--r-- 1,778 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
<?php
/**
 * @author     Michael Slusarz <slusarz@horde.org>
 * @category   Horde
 * @license    http://www.horde.org/licenses/bsd BSD
 * @package    Mail
 * @subpackage UnitTests
 */

class Horde_Mail_GroupTest extends PHPUnit_Framework_TestCase
{
    public function testWriteAddress()
    {
        $addresses = array(
            'Test <test@example.com>',
            'foo@example.com'
        );
        $groupname = 'Testing';

        $group_ob = new Horde_Mail_Rfc822_Group($groupname, $addresses);

        $this->assertEquals(
            'Testing: Test <test@example.com>, foo@example.com;',
            $group_ob->writeAddress()
        );
    }

    public function testWriteAddressEncode()
    {
        $addresses = array(
            'Fooã <test@example.com>',
            'foo@example.com'
        );
        $groupname = 'Testing';

        $group_ob = new Horde_Mail_Rfc822_Group($groupname, $addresses);

        $this->assertEquals(
            'Testing: =?utf-8?b?Rm9vw6M=?= <test@example.com>, foo@example.com;',
            $group_ob->writeAddress(array('encode' => true))
        );
    }

    public function testValid()
    {
        $group_ob = new Horde_Mail_Rfc822_Group();

        $this->assertTrue($group_ob->valid);

        $group_ob->groupname = '';

        $this->assertFalse($group_ob->valid);
    }

    public function testEmptyGroupCount()
    {
        $group_ob = new Horde_Mail_Rfc822_Group('Group');
        $this->assertEquals(
            0,
            count($group_ob)
        );
    }

    public function testEncodingGroupname()
    {
        $group_ob = new Horde_Mail_Rfc822_Group('Group "Foo"');

        $this->assertEquals(
            '"Group \"Foo\"":;',
            $group_ob->writeAddress(true)
        );
    }

}