public function testPropPatchCombinedSetDelete() { $backend = new ezcWebdavMemoryBackend(true); $backend->addContents(array('foo' => 'bar', 'bar' => array('blubb' => 'Somme blubb blubbs.'))); // First add some custom properties. $newProperties = new ezcWebdavFlaggedPropertyStorage(); $newProperties->attach($p_bar = new ezcWebdavDeadProperty('foo:', 'bar', 'some content'), ezcWebdavPropPatchRequest::SET); $newProperties->attach($p_blubb = new ezcWebdavDeadProperty('foo:', 'blubb', 'some other content'), ezcWebdavPropPatchRequest::SET); $request = new ezcWebdavPropPatchRequest('/foo'); $request->updates = $newProperties; $request->validateHeaders(); $response = $backend->proppatch($request); $resProps = new ezcWebdavBasicPropertyStorage(); $resProps->attach(new ezcWebdavDeadProperty('foo:', 'bar')); $resProps->attach(new ezcWebdavDeadProperty('foo:', 'blubb')); $this->assertEquals(new ezcWebdavPropPatchResponse(new ezcWebdavResource('/foo'), new ezcWebdavPropStatResponse($resProps)), $response, 'Expected property adding PROPPATCH response does not match real response.', 0, 20); // Then remove them again, with one live property in the middle to // check for proper failed dependency response codes. $updateProperties = new ezcWebdavFlaggedPropertyStorage(); $updateProperties->attach($p_blubb, ezcWebdavPropPatchRequest::REMOVE); $updateProperties->attach($p_foo = new ezcWebdavDeadProperty('foo:', 'foo', 'random content'), ezcWebdavPropPatchRequest::SET); $updateProperties->attach($p_bar, ezcWebdavPropPatchRequest::REMOVE); $request = new ezcWebdavPropPatchRequest('/foo'); $request->updates = $updateProperties; $request->validateHeaders(); $response = $backend->proppatch($request); $resProps = new ezcWebdavBasicPropertyStorage(); $resProps->attach(new ezcWebdavDeadProperty('foo:', 'blubb')); $resProps->attach(new ezcWebdavDeadProperty('foo:', 'foo')); $resProps->attach(new ezcWebdavDeadProperty('foo:', 'bar')); $this->assertEquals(new ezcWebdavPropPatchResponse(new ezcWebdavResource('/foo'), new ezcWebdavPropStatResponse($resProps)), $response, 'Expected property removing PROPPATCH response does not match real response.', 0, 20); // Ensure nothing has been removed, and the transactions has been // properly reverted. $leftProperties = new ezcWebdavBasicPropertyStorage(); $leftProperties->attach($p_bar); $request = new ezcWebdavPropFindRequest('/foo'); $request->prop = $updateProperties; $request->validateHeaders(); $response = $backend->propfind($request); $failed = new ezcWebdavBasicPropertyStorage(); $failed->attach($p_blubb); $failed->attach($p_bar); $failed->rewind(); $success = new ezcWebdavBasicPropertyStorage(); $success->attach($p_foo); $success->rewind(); $expectedResponse = new ezcWebdavMultistatusResponse(new ezcWebdavPropFindResponse(new ezcWebdavResource('/foo'), new ezcWebdavPropStatResponse($success), new ezcWebdavPropStatResponse($failed, ezcWebdavResponse::STATUS_404))); $this->assertEquals($expectedResponse, $response, 'Expected validating PROPFIND response does not match real response.', 0, 20); }