示例#1
0
 public function testDeadPropertyRetrieval()
 {
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     $backend->options->useMimeExts = false;
     $newProperties = new ezcWebdavFlaggedPropertyStorage();
     $newProperties->attach($prop = new ezcWebdavDeadProperty('foo:', 'bar', "<?xml version=\"1.0\"?>\n<bar xmlns=\"foo:\">some content</bar>\n"), ezcWebdavPropPatchRequest::SET);
     $request = new ezcWebdavPropPatchRequest('/resource');
     $request->updates = $newProperties;
     $request->validateHeaders();
     $response = $backend->proppatch($request);
     $this->assertTrue(is_file($this->tempDir . 'backend/.ezc/resource.xml'), 'Expected creation of property storage.');
     $request = new ezcWebdavPropFindRequest('/resource');
     $request->prop = $newProperties;
     $request->validateHeaders();
     $response = $backend->propfind($request);
     $responseProperty = new ezcWebdavBasicPropertyStorage();
     $responseProperty->attach($prop);
     $responseProperty->rewind();
     $expectedResponse = new ezcWebdavMultistatusResponse(new ezcWebdavPropFindResponse(new ezcWebdavResource('/resource'), new ezcWebdavPropStatResponse($responseProperty)));
     $this->assertEquals($expectedResponse, $response, 'Expected response does not match real response.', 0, 20);
     $this->assertEquals(new ezcWebdavDeadProperty('foo:', 'bar', "<?xml version=\"1.0\"?>\n<bar xmlns=\"foo:\">some content</bar>\n"), $backend->getProperty('/resource', 'bar', 'foo:'));
 }
示例#2
0
 public function testPropPatchCombinedSetDelete()
 {
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     // First add some custom properties.
     $newProperties = new ezcWebdavFlaggedPropertyStorage();
     $newProperties->attach($p_bar = new ezcWebdavDeadProperty('foo:', 'bar', "<?xml version=\"1.0\"?>\n<bar xmlns=\"foo:\">some content</bar>\n"), ezcWebdavPropPatchRequest::SET);
     $newProperties->attach($p_blubb = new ezcWebdavDeadProperty('foo:', 'blubb', "<?xml version=\"1.0\"?>\n<blubb xmlns=\"foo:\">some other content</blubb>\n"), ezcWebdavPropPatchRequest::SET);
     $request = new ezcWebdavPropPatchRequest('/resource');
     $request->updates = $newProperties;
     $request->validateHeaders();
     $response = $backend->proppatch($request);
     $this->assertEquals(new ezcWebdavPropPatchResponse(new ezcWebdavResource('/resource')), $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', "<?xml version=\"1.0\"?>\n<foo xmlns=\"foo:\">random content</foo>\n"), ezcWebdavPropPatchRequest::SET);
     $updateProperties->attach($p_bar, ezcWebdavPropPatchRequest::REMOVE);
     $request = new ezcWebdavPropPatchRequest('/resource');
     $request->updates = $updateProperties;
     $request->validateHeaders();
     $response = $backend->proppatch($request);
     $this->assertEquals(new ezcWebdavPropPatchResponse(new ezcWebdavResource('/resource')), $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('/resource');
     $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('/resource'), new ezcWebdavPropStatResponse($success), new ezcWebdavPropStatResponse($failed, ezcWebdavResponse::STATUS_404)));
     $this->assertEquals($expectedResponse, $response, 'Expected validating PROPFIND response does not match real response.', 0, 20);
 }