summaryrefslogtreecommitdiff
path: root/tests/unit/Xml/TXmlElementListTest.php
blob: 7667c64d09ee1b1b9386df41158f66548f2cbabb (plain)
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
<?php

Prado::using('System.Xml.TXmlDocument');

/**
 * @package System.Xml
 */
class TXmlElementListTest extends PHPUnit_Framework_TestCase {

	public function testConstruct() {
		$element=new TXmlElement('tag');
		$list=new TXmlElementList($element);
		self::assertEquals($element,self::readAttribute($list, '_o'));
	}

	public function testInsertAt() {
		$element=new TXmlElement('tag');
		$list=new TXmlElementList($element);
		try {
			$list->insertAt(0,'ABadElement');
			self::fail('Expected TInvalidDataTypeException not thrown');
		} catch (TInvalidDataTypeException $e) {}
		$newElement=new TXmlElement('newTag');
		$list->insertAt(0,$newElement);
		self::assertEquals($newElement,$list->itemAt(0));

	}

	public function testRemoveAt() {
		$element=new TXmlElement('tag');
		$list=new TXmlElementList($element);
		$newElement=new TXmlElement('newTag');
		$list->insertAt(0,$newElement);
		self::assertEquals($newElement,$list->removeAt(0));
	}
}