1<?php
2/**
3 * Copyright 2015-2017 Horde LLC (http://www.horde.org/)
4 *
5 * @category   Horde
6 * @copyright  2015-2016 Horde LLC
7 * @license    http://www.horde.org/licenses/lgpl21 LGPL 2.1
8 * @package    Mime
9 * @subpackage UnitTests
10 */
11
12/**
13 * Tests for the Horde_Mime_Headers_ContentId class.
14 *
15 * @author     Michael Slusarz <slusarz@horde.org>
16 * @category   Horde
17 * @copyright  2015-2016 Horde LLC
18 * @internal
19 * @license    http://www.horde.org/licenses/lgpl21 LGPL 2.1
20 * @package    Mime
21 * @subpackage UnitTests
22 */
23class Horde_Mime_Headers_ContentIdTest
24extends PHPUnit_Framework_TestCase
25{
26    /**
27     * @dataProvider valueProvider
28     */
29    public function testValue($input, $expected_val)
30    {
31        $ob = new Horde_Mime_Headers_ContentId(null, $input);
32
33        $this->assertEquals(
34            $expected_val,
35            $ob->value
36        );
37
38        $this->assertFalse($ob->isDefault());
39    }
40
41    public function valueProvider()
42    {
43        return array(
44            array(
45                'foo',
46                '<foo>'
47            ),
48            array(
49                '<foo>',
50                '<foo>'
51            ),
52            array(
53                '<<foo',
54                '<foo>'
55            )
56        );
57    }
58
59    public function testClone()
60    {
61        $ob = new Horde_Mime_Headers_ContentId(null, 'foo');
62
63        $ob2 = clone $ob;
64
65        $ob->setValue('bar');
66
67        $this->assertEquals(
68            '<foo>',
69            $ob2->value
70        );
71    }
72
73    public function testSerialize()
74    {
75        $ob = new Horde_Mime_Headers_ContentId(null, 'foo');
76
77        $ob2 = unserialize(serialize($ob));
78
79        $this->assertEquals(
80            '<foo>',
81            $ob2->value
82        );
83    }
84
85    public function testStaticCreateMethod()
86    {
87        $ob = Horde_Mime_Headers_ContentId::create();
88
89        $this->assertStringMatchesFormat(
90            '<%s@%a>',
91            $ob->value
92        );
93    }
94
95}
96