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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<?php
Prado::using('System.Collections.TAttributeCollection');
/**
* @package System.Collections
*/
class TAttributeCollectionTest extends PHPUnit_Framework_TestCase {
public function setUp() {
}
public function tearDown() {
}
public function testCanGetProperty() {
$collection = new TAttributeCollection();
$collection->Property = 'value';
self::assertEquals('value', $collection->Property);
self::assertEquals(true, $collection->canGetProperty('Property'));
}
public function testCanNotGetUndefinedProperty() {
$collection = new TAttributeCollection(array(), true);
self::assertEquals(false, $collection->canGetProperty('Property'));
try {
$value = $collection->Property;
} catch(TInvalidOperationException $e) {
return;
}
self::fail('An expected TInvalidOperationException was not raised');
}
public function testCanSetProperty() {
$collection = new TAttributeCollection();
$collection->Property = 'value';
self::assertEquals('value', $collection->itemAt('Property'));
self::assertEquals(true, $collection->canSetProperty('Property'));
}
public function testCanNotSetPropertyIfReadOnly() {
$collection = new TAttributeCollection(array(), true);
try {
$collection->Property = 'value';
} catch(TInvalidOperationException $e) {
return;
}
self::fail('An expected TInvalidOperationException was not raised');
}
public function testGetCaseSensitive() {
$collection = new TAttributeCollection();
$collection->setCaseSensitive(false);
self::assertEquals(false, $collection->getCaseSensitive());
$collection->setCaseSensitive(true);
self::assertEquals(true, $collection->getCaseSensitive());
}
public function testSetCaseSensitive() {
$collection = new TAttributeCollection();
$collection->Property = 'value';
$collection->setCaseSensitive(false);
self::assertEquals('value', $collection->itemAt('property'));
}
public function testItemAt() {
$collection = new TAttributeCollection();
$collection->Property = 'value';
self::assertEquals('value', $collection->itemAt('Property'));
}
public function testAdd() {
$collection = new TAttributeCollection();
$collection->add('Property', 'value');
self::assertEquals('value', $collection->itemAt('Property'));
}
public function testRemove() {
$collection = new TAttributeCollection();
$collection->add('Property', 'value');
$collection->remove('Property');
self::assertEquals(0, count($collection));
}
public function testContains() {
$collection = new TAttributeCollection();
self::assertEquals(false, $collection->contains('Property'));
$collection->Property = 'value';
self::assertEquals(true, $collection->contains('Property'));
}
public function testHasProperty() {
$collection = new TAttributeCollection();
self::assertEquals(false, $collection->hasProperty('Property'));
$collection->Property = 'value';
self::assertEquals(true, $collection->hasProperty('Property'));
}
}
|