Blame view

sources/tests/lib/vobject.php 1.17 KB
31b7f2792   Kload   Upgrade to ownclo...
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
  <?php
  /**
   * Copyright (c) 2013 Thomas Tanghus (thomas@tanghus.net)
   * This file is licensed under the Affero General Public License version 3 or
   * later.
   * See the COPYING-README file.
   */
  
  class Test_VObject extends PHPUnit_Framework_TestCase {
  
  	public function setUp() {
  		Sabre\VObject\Property::$classMap['SUMMARY'] = 'OC\VObject\StringProperty';
  		Sabre\VObject\Property::$classMap['ORG'] = 'OC\VObject\CompoundProperty';
  	}
  
  	function testStringProperty() {
  		$property = Sabre\VObject\Property::create('SUMMARY', 'Escape;this,please');
  		$this->assertEquals("SUMMARY:Escape\;this\,please\r
  ", $property->serialize());
  	}
  
  	function testCompoundProperty() {
  
  		$arr = array(
  			'ABC, Inc.',
  			'North American Division',
  			'Marketing;Sales',
  		);
  
  		$property = Sabre\VObject\Property::create('ORG');
  		$property->setParts($arr);
  
  		$this->assertEquals('ABC\, Inc.;North American Division;Marketing\;Sales', $property->value);
  		$this->assertEquals('ORG:ABC\, Inc.;North American Division;Marketing\;Sales' . "\r
  ", $property->serialize());
  		$this->assertEquals(3, count($property->getParts()));
  		$parts = $property->getParts();
  		$this->assertEquals('Marketing;Sales', $parts[2]);
  	}
  }