1<?php
2
3namespace Sabre\VObject\Property\VCard;
4
5use Sabre\VObject;
6
7class LanguageTagTest extends \PHPUnit_Framework_TestCase {
8
9    function testMimeDir() {
10
11        $input = "BEGIN:VCARD\r\nVERSION:4.0\r\nLANG:nl\r\nEND:VCARD\r\n";
12        $mimeDir = new VObject\Parser\MimeDir($input);
13
14        $result = $mimeDir->parse($input);
15
16        $this->assertInstanceOf('Sabre\VObject\Property\VCard\LanguageTag', $result->LANG);
17
18        $this->assertEquals('nl', $result->LANG->getValue());
19
20        $this->assertEquals(
21            $input,
22            $result->serialize()
23        );
24
25    }
26
27    function testChangeAndSerialize() {
28
29        $input = "BEGIN:VCARD\r\nVERSION:4.0\r\nLANG:nl\r\nEND:VCARD\r\n";
30        $mimeDir = new VObject\Parser\MimeDir($input);
31
32        $result = $mimeDir->parse($input);
33
34        $this->assertInstanceOf('Sabre\VObject\Property\VCard\LanguageTag', $result->LANG);
35        // This replicates what the vcard converter does and triggered a bug in
36        // the past.
37        $result->LANG->setValue(['de']);
38
39        $this->assertEquals('de', $result->LANG->getValue());
40
41        $expected = "BEGIN:VCARD\r\nVERSION:4.0\r\nLANG:de\r\nEND:VCARD\r\n";
42        $this->assertEquals(
43            $expected,
44            $result->serialize()
45        );
46    }
47
48}
49