1<?php 2/** 3 * Test the XML envelope handler. 4 * 5 * PHP version 5 6 * 7 * @category Kolab 8 * @package Kolab_Format 9 * @subpackage UnitTests 10 * @author Gunnar Wrobel <wrobel@pardus.de> 11 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 12 * @link http://www.horde.org/libraries/Horde_Kolab_Format 13 */ 14 15/** 16 * Test the XML envelope handler. 17 * 18 * Copyright 2011-2016 Horde LLC (http://www.horde.org/) 19 * 20 * See the enclosed file COPYING for license information (LGPL). If you 21 * did not receive this file, see http://www.horde.org/licenses/lgpl21. 22 * 23 * @category Kolab 24 * @package Kolab_Format 25 * @subpackage UnitTests 26 * @author Gunnar Wrobel <wrobel@pardus.de> 27 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 28 * @link http://www.horde.org/libraries/Horde_Kolab_Format 29 */ 30class Horde_Kolab_Format_Unit_Xml_EnvelopeTest 31extends PHPUnit_Framework_TestCase 32{ 33 public function testSave() 34 { 35 $this->assertContains( 36 '<uid>test</uid>', 37 $this->_getEnvelope()->save( 38 array('uid' => 'test', 'type' => 'test') 39 ) 40 ); 41 } 42 43 /** 44 * @expectedException Horde_Kolab_Format_Exception 45 */ 46 public function testMissingType() 47 { 48 $this->assertContains( 49 '<uid>test</uid>', 50 $this->_getEnvelope()->save(array('uid' => 'test')) 51 ); 52 } 53 54 public function testType() 55 { 56 $this->assertContains( 57 '<test version="1.0">', 58 $this->_getEnvelope()->save( 59 array('uid' => 'test', 'type' => 'test') 60 ) 61 ); 62 } 63 64 public function testXml() 65 { 66 $this->assertContains( 67 '<testelement/>', 68 $this->_getEnvelope()->save( 69 array('uid' => 'test', 'type' => 'test', 'xml' => '<testelement/>') 70 ) 71 ); 72 } 73 74 private function _getEnvelope() 75 { 76 $factory = new Horde_Kolab_Format_Factory(); 77 return $factory->create('Xml', 'Envelope'); 78 } 79} 80