ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\PropPatchTest Class Reference
+ Inheritance diagram for Sabre\DAV\PropPatchTest:
+ Collaboration diagram for Sabre\DAV\PropPatchTest:

Public Member Functions

 setUp ()
 
 testHandleSingleSuccess ()
 
 testHandleSingleFail ()
 
 testHandleSingleCustomResult ()
 
 testHandleSingleDeleteSuccess ()
 
 testHandleNothing ()
 
 testHandleRemaining ()
 testHandleSingleSuccess More...
 
 testHandleRemainingNothingToDo ()
 
 testSetResultCode ()
 
 testSetResultCodeFail ()
 
 testSetRemainingResultCode ()
 
 testCommitNoHandler ()
 
 testHandlerNotCalled ()
 
 testDependencyFail ()
 
 testHandleSingleBrokenResult ()
 
 testHandleMultiValueSuccess ()
 
 testHandleMultiValueFail ()
 
 testHandleMultiValueCustomResult ()
 
 testHandleMultiValueBroken ()
 

Protected Attributes

 $propPatch
 

Detailed Description

Definition at line 5 of file PropPatchTest.php.

Member Function Documentation

◆ setUp()

Sabre\DAV\PropPatchTest::setUp ( )

Definition at line 9 of file PropPatchTest.php.

9  {
10 
11  $this->propPatch = new PropPatch([
12  '{DAV:}displayname' => 'foo',
13  ]);
14  $this->assertEquals(['{DAV:}displayname' => 'foo'], $this->propPatch->getMutations());
15 
16  }

◆ testCommitNoHandler()

Sabre\DAV\PropPatchTest::testCommitNoHandler ( )

Definition at line 164 of file PropPatchTest.php.

References $result.

164  {
165 
166  $this->assertFalse($this->propPatch->commit());
167  $result = $this->propPatch->getResult();
168  $this->assertEquals(['{DAV:}displayname' => 403], $result);
169 
170  }
$result

◆ testDependencyFail()

Sabre\DAV\PropPatchTest::testDependencyFail ( )

Definition at line 188 of file PropPatchTest.php.

References Sabre\DAV\PropPatchTest\$propPatch, and $result.

188  {
189 
190  $propPatch = new PropPatch([
191  '{DAV:}a' => 'foo',
192  '{DAV:}b' => 'bar',
193  ]);
194 
195  $calledA = false;
196  $calledB = false;
197 
198  $propPatch->handle('{DAV:}a', function() use (&$calledA) {
199  $calledA = true;
200  return false;
201  });
202  $propPatch->handle('{DAV:}b', function() use (&$calledB) {
203  $calledB = true;
204  return false;
205  });
206 
207  $result = $propPatch->commit();
208  $this->assertTrue($calledA);
209  $this->assertFalse($calledB);
210 
211  $this->assertFalse($result);
212 
213  $this->assertEquals([
214  '{DAV:}a' => 403,
215  '{DAV:}b' => 424,
216  ], $propPatch->getResult());
217 
218  }
$result

◆ testHandleMultiValueBroken()

Sabre\DAV\PropPatchTest::testHandleMultiValueBroken ( )

Definition at line 337 of file PropPatchTest.php.

References Sabre\DAV\PropPatchTest\$propPatch.

337  {
338 
339  $propPatch = new PropPatch([
340  '{DAV:}a' => 'foo',
341  '{DAV:}b' => 'bar',
342  '{DAV:}c' => null,
343  ]);
344 
345  $propPatch->handle(['{DAV:}a', '{DAV:}b', '{DAV:}c'], function($properties) {
346  return 'hi';
347  });
348  $propPatch->commit();
349 
350  }

◆ testHandleMultiValueCustomResult()

Sabre\DAV\PropPatchTest::testHandleMultiValueCustomResult ( )

Definition at line 299 of file PropPatchTest.php.

References Sabre\DAV\PropPatchTest\$propPatch, and $result.

299  {
300 
301  $propPatch = new PropPatch([
302  '{DAV:}a' => 'foo',
303  '{DAV:}b' => 'bar',
304  '{DAV:}c' => null,
305  ]);
306 
307  $calledA = false;
308 
309  $propPatch->handle(['{DAV:}a', '{DAV:}b', '{DAV:}c'], function($properties) use (&$calledA) {
310  $calledA = true;
311  $this->assertEquals([
312  '{DAV:}a' => 'foo',
313  '{DAV:}b' => 'bar',
314  '{DAV:}c' => null,
315  ], $properties);
316 
317  return [
318  '{DAV:}a' => 201,
319  '{DAV:}b' => 204,
320  ];
321  });
322  $result = $propPatch->commit();
323  $this->assertTrue($calledA);
324  $this->assertFalse($result);
325 
326  $this->assertEquals([
327  '{DAV:}a' => 201,
328  '{DAV:}b' => 204,
329  '{DAV:}c' => 500,
330  ], $propPatch->getResult());
331 
332  }
$result

◆ testHandleMultiValueFail()

Sabre\DAV\PropPatchTest::testHandleMultiValueFail ( )

Definition at line 268 of file PropPatchTest.php.

References Sabre\DAV\PropPatchTest\$propPatch, and $result.

268  {
269 
270  $propPatch = new PropPatch([
271  '{DAV:}a' => 'foo',
272  '{DAV:}b' => 'bar',
273  '{DAV:}c' => null,
274  ]);
275 
276  $calledA = false;
277 
278  $propPatch->handle(['{DAV:}a', '{DAV:}b', '{DAV:}c'], function($properties) use (&$calledA) {
279  $calledA = true;
280  $this->assertEquals([
281  '{DAV:}a' => 'foo',
282  '{DAV:}b' => 'bar',
283  '{DAV:}c' => null,
284  ], $properties);
285  return false;
286  });
287  $result = $propPatch->commit();
288  $this->assertTrue($calledA);
289  $this->assertFalse($result);
290 
291  $this->assertEquals([
292  '{DAV:}a' => 403,
293  '{DAV:}b' => 403,
294  '{DAV:}c' => 403,
295  ], $propPatch->getResult());
296 
297  }
$result

◆ testHandleMultiValueSuccess()

Sabre\DAV\PropPatchTest::testHandleMultiValueSuccess ( )

Definition at line 236 of file PropPatchTest.php.

References Sabre\DAV\PropPatchTest\$propPatch, and $result.

236  {
237 
238  $propPatch = new PropPatch([
239  '{DAV:}a' => 'foo',
240  '{DAV:}b' => 'bar',
241  '{DAV:}c' => null,
242  ]);
243 
244  $calledA = false;
245 
246  $propPatch->handle(['{DAV:}a', '{DAV:}b', '{DAV:}c'], function($properties) use (&$calledA) {
247  $calledA = true;
248  $this->assertEquals([
249  '{DAV:}a' => 'foo',
250  '{DAV:}b' => 'bar',
251  '{DAV:}c' => null,
252  ], $properties);
253  return true;
254  });
255  $result = $propPatch->commit();
256  $this->assertTrue($calledA);
257  $this->assertTrue($result);
258 
259  $this->assertEquals([
260  '{DAV:}a' => 200,
261  '{DAV:}b' => 200,
262  '{DAV:}c' => 204,
263  ], $propPatch->getResult());
264 
265  }
$result

◆ testHandleNothing()

Sabre\DAV\PropPatchTest::testHandleNothing ( )

Definition at line 92 of file PropPatchTest.php.

92  {
93 
94  $hasRan = false;
95 
96  $this->propPatch->handle('{DAV:}foobar', function($value) use (&$hasRan) {
97  $hasRan = true;
98  });
99 
100  $this->assertFalse($hasRan);
101 
102  }

◆ testHandleRemaining()

Sabre\DAV\PropPatchTest::testHandleRemaining ( )

testHandleSingleSuccess

Definition at line 107 of file PropPatchTest.php.

References $result.

107  {
108 
109  $hasRan = false;
110 
111  $this->propPatch->handleRemaining(function($mutations) use (&$hasRan) {
112  $hasRan = true;
113  $this->assertEquals(['{DAV:}displayname' => 'foo'], $mutations);
114  return true;
115  });
116 
117  $this->assertTrue($this->propPatch->commit());
118  $result = $this->propPatch->getResult();
119  $this->assertEquals(['{DAV:}displayname' => 200], $result);
120 
121  $this->assertTrue($hasRan);
122 
123  }
$result

◆ testHandleRemainingNothingToDo()

Sabre\DAV\PropPatchTest::testHandleRemainingNothingToDo ( )

Definition at line 124 of file PropPatchTest.php.

124  {
125 
126  $hasRan = false;
127 
128  $this->propPatch->handle('{DAV:}displayname', function() {});
129  $this->propPatch->handleRemaining(function($mutations) use (&$hasRan) {
130  $hasRan = true;
131  });
132 
133  $this->assertFalse($hasRan);
134 
135  }

◆ testHandlerNotCalled()

Sabre\DAV\PropPatchTest::testHandlerNotCalled ( )

Definition at line 172 of file PropPatchTest.php.

172  {
173 
174  $hasRan = false;
175 
176  $this->propPatch->setResultCode('{DAV:}displayname', 402);
177  $this->propPatch->handle('{DAV:}displayname', function($value) use (&$hasRan) {
178  $hasRan = true;
179  });
180 
181  $this->propPatch->commit();
182 
183  // The handler is not supposed to have ran
184  $this->assertFalse($hasRan);
185 
186  }

◆ testHandleSingleBrokenResult()

Sabre\DAV\PropPatchTest::testHandleSingleBrokenResult ( )

Definition at line 223 of file PropPatchTest.php.

References Sabre\DAV\PropPatchTest\$propPatch.

223  {
224 
225  $propPatch = new PropPatch([
226  '{DAV:}a' => 'foo',
227  ]);
228 
229  $propPatch->handle('{DAV:}a', function() {
230  return [];
231  });
232  $propPatch->commit();
233 
234  }

◆ testHandleSingleCustomResult()

Sabre\DAV\PropPatchTest::testHandleSingleCustomResult ( )

Definition at line 54 of file PropPatchTest.php.

References $result.

54  {
55 
56  $hasRan = false;
57 
58  $this->propPatch->handle('{DAV:}displayname', function($value) use (&$hasRan) {
59  $hasRan = true;
60  $this->assertEquals('foo', $value);
61  return 201;
62  });
63 
64  $this->assertTrue($this->propPatch->commit());
65  $result = $this->propPatch->getResult();
66  $this->assertEquals(['{DAV:}displayname' => 201], $result);
67 
68  $this->assertTrue($hasRan);
69 
70  }
$result

◆ testHandleSingleDeleteSuccess()

Sabre\DAV\PropPatchTest::testHandleSingleDeleteSuccess ( )

Definition at line 72 of file PropPatchTest.php.

References $result.

72  {
73 
74  $hasRan = false;
75 
76  $this->propPatch = new PropPatch(['{DAV:}displayname' => null]);
77  $this->propPatch->handle('{DAV:}displayname', function($value) use (&$hasRan) {
78  $hasRan = true;
79  $this->assertNull($value);
80  return true;
81  });
82 
83  $this->assertTrue($this->propPatch->commit());
84  $result = $this->propPatch->getResult();
85  $this->assertEquals(['{DAV:}displayname' => 204], $result);
86 
87  $this->assertTrue($hasRan);
88 
89  }
$result

◆ testHandleSingleFail()

Sabre\DAV\PropPatchTest::testHandleSingleFail ( )

Definition at line 36 of file PropPatchTest.php.

References $result.

36  {
37 
38  $hasRan = false;
39 
40  $this->propPatch->handle('{DAV:}displayname', function($value) use (&$hasRan) {
41  $hasRan = true;
42  $this->assertEquals('foo', $value);
43  return false;
44  });
45 
46  $this->assertFalse($this->propPatch->commit());
47  $result = $this->propPatch->getResult();
48  $this->assertEquals(['{DAV:}displayname' => 403], $result);
49 
50  $this->assertTrue($hasRan);
51 
52  }
$result

◆ testHandleSingleSuccess()

Sabre\DAV\PropPatchTest::testHandleSingleSuccess ( )

Definition at line 18 of file PropPatchTest.php.

References $result.

18  {
19 
20  $hasRan = false;
21 
22  $this->propPatch->handle('{DAV:}displayname', function($value) use (&$hasRan) {
23  $hasRan = true;
24  $this->assertEquals('foo', $value);
25  return true;
26  });
27 
28  $this->assertTrue($this->propPatch->commit());
29  $result = $this->propPatch->getResult();
30  $this->assertEquals(['{DAV:}displayname' => 200], $result);
31 
32  $this->assertTrue($hasRan);
33 
34  }
$result

◆ testSetRemainingResultCode()

Sabre\DAV\PropPatchTest::testSetRemainingResultCode ( )

Definition at line 155 of file PropPatchTest.php.

References $result.

155  {
156 
157  $this->propPatch->setRemainingResultCode(204);
158  $this->assertTrue($this->propPatch->commit());
159  $result = $this->propPatch->getResult();
160  $this->assertEquals(['{DAV:}displayname' => 204], $result);
161 
162  }
$result

◆ testSetResultCode()

Sabre\DAV\PropPatchTest::testSetResultCode ( )

Definition at line 137 of file PropPatchTest.php.

References $result.

137  {
138 
139  $this->propPatch->setResultCode('{DAV:}displayname', 201);
140  $this->assertTrue($this->propPatch->commit());
141  $result = $this->propPatch->getResult();
142  $this->assertEquals(['{DAV:}displayname' => 201], $result);
143 
144  }
$result

◆ testSetResultCodeFail()

Sabre\DAV\PropPatchTest::testSetResultCodeFail ( )

Definition at line 146 of file PropPatchTest.php.

References $result.

146  {
147 
148  $this->propPatch->setResultCode('{DAV:}displayname', 402);
149  $this->assertFalse($this->propPatch->commit());
150  $result = $this->propPatch->getResult();
151  $this->assertEquals(['{DAV:}displayname' => 402], $result);
152 
153  }
$result

Field Documentation

◆ $propPatch


The documentation for this class was generated from the following file: