ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractPDOTest.php
Go to the documentation of this file.
1<?php
2
4
9
11
13
14 function getBackend() {
15
16 $this->dropTables('propertystorage');
17 $this->createSchema('propertystorage');
18
19 $pdo = $this->getPDO();
20
21 $pdo->exec("INSERT INTO propertystorage (path, name, valuetype, value) VALUES ('dir', '{DAV:}displayname', 1, 'Directory')");
22
23 return new PDO($this->getPDO());
24
25 }
26
27 function testPropFind() {
28
29 $backend = $this->getBackend();
30
31 $propFind = new PropFind('dir', ['{DAV:}displayname']);
32 $backend->propFind('dir', $propFind);
33
34 $this->assertEquals('Directory', $propFind->get('{DAV:}displayname'));
35
36 }
37
39
40 $backend = $this->getBackend();
41
42 $propFind = new PropFind('dir', ['{DAV:}displayname']);
43 $propFind->set('{DAV:}displayname', 'foo');
44 $backend->propFind('dir', $propFind);
45
46 $this->assertEquals('foo', $propFind->get('{DAV:}displayname'));
47
48 }
49
54
55 $backend = $this->getBackend();
56
57 $propPatch = new PropPatch(['{DAV:}displayname' => 'bar']);
58 $backend->propPatch('dir', $propPatch);
59 $propPatch->commit();
60
61 $propFind = new PropFind('dir', ['{DAV:}displayname']);
62 $backend->propFind('dir', $propFind);
63
64 $this->assertEquals('bar', $propFind->get('{DAV:}displayname'));
65
66 }
67
72
73 $backend = $this->getBackend();
74
75 $complex = new Complex('<foo xmlns="DAV:">somevalue</foo>');
76
77 $propPatch = new PropPatch(['{DAV:}complex' => $complex]);
78 $backend->propPatch('dir', $propPatch);
79 $propPatch->commit();
80
81 $propFind = new PropFind('dir', ['{DAV:}complex']);
82 $backend->propFind('dir', $propFind);
83
84 $this->assertEquals($complex, $propFind->get('{DAV:}complex'));
85
86 }
87
88
93
94 $backend = $this->getBackend();
95
96 $custom = new Href('/foo/bar/');
97
98 $propPatch = new PropPatch(['{DAV:}custom' => $custom]);
99 $backend->propPatch('dir', $propPatch);
100 $propPatch->commit();
101
102 $propFind = new PropFind('dir', ['{DAV:}custom']);
103 $backend->propFind('dir', $propFind);
104
105 $this->assertEquals($custom, $propFind->get('{DAV:}custom'));
106
107 }
108
113
114 $backend = $this->getBackend();
115
116 $propPatch = new PropPatch(['{DAV:}displayname' => null]);
117 $backend->propPatch('dir', $propPatch);
118 $propPatch->commit();
119
120 $propFind = new PropFind('dir', ['{DAV:}displayname']);
121 $backend->propFind('dir', $propFind);
122
123 $this->assertEquals(null, $propFind->get('{DAV:}displayname'));
124
125 }
126
130 function testDelete() {
131
132 $backend = $this->getBackend();
133 $backend->delete('dir');
134
135 $propFind = new PropFind('dir', ['{DAV:}displayname']);
136 $backend->propFind('dir', $propFind);
137
138 $this->assertEquals(null, $propFind->get('{DAV:}displayname'));
139
140 }
141
145 function testMove() {
146
147 $backend = $this->getBackend();
148 // Creating a new child property.
149 $propPatch = new PropPatch(['{DAV:}displayname' => 'child']);
150 $backend->propPatch('dir/child', $propPatch);
151 $propPatch->commit();
152
153 $backend->move('dir', 'dir2');
154
155 // Old 'dir'
156 $propFind = new PropFind('dir', ['{DAV:}displayname']);
157 $backend->propFind('dir', $propFind);
158 $this->assertEquals(null, $propFind->get('{DAV:}displayname'));
159
160 // Old 'dir/child'
161 $propFind = new PropFind('dir/child', ['{DAV:}displayname']);
162 $backend->propFind('dir/child', $propFind);
163 $this->assertEquals(null, $propFind->get('{DAV:}displayname'));
164
165 // New 'dir2'
166 $propFind = new PropFind('dir2', ['{DAV:}displayname']);
167 $backend->propFind('dir2', $propFind);
168 $this->assertEquals('Directory', $propFind->get('{DAV:}displayname'));
169
170 // New 'dir2/child'
171 $propFind = new PropFind('dir2/child', ['{DAV:}displayname']);
172 $backend->propFind('dir2/child', $propFind);
173 $this->assertEquals('child', $propFind->get('{DAV:}displayname'));
174 }
175
179 function testDeepDelete() {
180
181 $backend = $this->getBackend();
182 $propPatch = new PropPatch(['{DAV:}displayname' => 'child']);
183 $backend->propPatch('dir/child', $propPatch);
184 $propPatch->commit();
185 $backend->delete('dir');
186
187 $propFind = new PropFind('dir/child', ['{DAV:}displayname']);
188 $backend->propFind('dir/child', $propFind);
189
190 $this->assertEquals(null, $propFind->get('{DAV:}displayname'));
191
192 }
193}
An exception for terminatinating execution or to throw for unit testing.
This class holds all the information about a PROPFIND request.
Definition: PropFind.php:11
This class represents a set of properties that are going to be updated.
Definition: PropPatch.php:20
testPropPatchComplex()
@depends testPropPatchUpdate
testPropPatchCustom()
@depends testPropPatchComplex
PropertyStorage PDO backend.
Definition: PDO.php:21
This class represents a 'complex' property that didn't have a default decoder.
Definition: Complex.php:18
Href property.
Definition: Href.php:26
$pdo
Definition: migrateto20.php:62
trait DbTestHelperTrait
dropTables($tableNames)
Drops tables, if they exist.
getPDO()
Alias for getDb.
createSchema($schemaName)
Uses .sql files from the examples directory to initialize the database.