xref: /plugin/davcal/vendor/sabre/vobject/tests/VObject/Property/CompoundTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\VObject\Property;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\VObject\Component\VCard;
6*a1a3b679SAndreas Boehler
7*a1a3b679SAndreas Boehlerclass CompoundTest extends \PHPUnit_Framework_TestCase {
8*a1a3b679SAndreas Boehler
9*a1a3b679SAndreas Boehler    function testSetParts() {
10*a1a3b679SAndreas Boehler
11*a1a3b679SAndreas Boehler        $arr = array(
12*a1a3b679SAndreas Boehler            'ABC, Inc.',
13*a1a3b679SAndreas Boehler            'North American Division',
14*a1a3b679SAndreas Boehler            'Marketing;Sales',
15*a1a3b679SAndreas Boehler        );
16*a1a3b679SAndreas Boehler
17*a1a3b679SAndreas Boehler        $vcard = new VCard();
18*a1a3b679SAndreas Boehler        $elem = $vcard->createProperty('ORG');
19*a1a3b679SAndreas Boehler        $elem->setParts($arr);
20*a1a3b679SAndreas Boehler
21*a1a3b679SAndreas Boehler        $this->assertEquals('ABC\, Inc.;North American Division;Marketing\;Sales', $elem->getValue());
22*a1a3b679SAndreas Boehler        $this->assertEquals(3, count($elem->getParts()));
23*a1a3b679SAndreas Boehler        $parts = $elem->getParts();
24*a1a3b679SAndreas Boehler        $this->assertEquals('Marketing;Sales', $parts[2]);
25*a1a3b679SAndreas Boehler
26*a1a3b679SAndreas Boehler    }
27*a1a3b679SAndreas Boehler
28*a1a3b679SAndreas Boehler    function testGetParts() {
29*a1a3b679SAndreas Boehler
30*a1a3b679SAndreas Boehler        $str = 'ABC\, Inc.;North American Division;Marketing\;Sales';
31*a1a3b679SAndreas Boehler
32*a1a3b679SAndreas Boehler        $vcard = new VCard();
33*a1a3b679SAndreas Boehler        $elem = $vcard->createProperty('ORG');
34*a1a3b679SAndreas Boehler        $elem->setRawMimeDirValue($str);
35*a1a3b679SAndreas Boehler
36*a1a3b679SAndreas Boehler        $this->assertEquals(3, count($elem->getParts()));
37*a1a3b679SAndreas Boehler        $parts = $elem->getParts();
38*a1a3b679SAndreas Boehler        $this->assertEquals('Marketing;Sales', $parts[2]);
39*a1a3b679SAndreas Boehler    }
40*a1a3b679SAndreas Boehler
41*a1a3b679SAndreas Boehler    function testGetPartsNull() {
42*a1a3b679SAndreas Boehler
43*a1a3b679SAndreas Boehler        $vcard = new VCard();
44*a1a3b679SAndreas Boehler        $elem = $vcard->createProperty('ORG', null);
45*a1a3b679SAndreas Boehler
46*a1a3b679SAndreas Boehler        $this->assertEquals(0, count($elem->getParts()));
47*a1a3b679SAndreas Boehler
48*a1a3b679SAndreas Boehler    }
49*a1a3b679SAndreas Boehler
50*a1a3b679SAndreas Boehler}
51