public function testDeleteCollectionWithInvalidETag() { $testPath = '/collection/deep_collection'; $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/'); $collectionEtag = $backend->getProperty($testPath, 'getetag')->etag; $resourceEtag = $backend->getProperty($testPath . '/deep_test.txt', 'getetag')->etag; $req = new ezcWebdavDeleteRequest($testPath); $req->setHeader('If-None-Match', array('abc23', $resourceEtag)); $req->validateHeaders(); $res = $backend->delete($req); $this->assertEquals(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_412, "{$testPath}/deep_test.txt", 'If-None-Match header check failed.'), $res, 'Expected response does not match real response.', 0, 20); }
public function testResourceDeleteFailure() { $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/'); $this->assertTrue(is_file($this->tempDir . 'backend/collection/test.txt'), 'Expected existing file.'); chmod($this->tempDir . 'backend/collection', 0555); // @TODO: This can be removed with the latest PHPUnit release, but for // now we need it, or the is_file() call on backend/collection/test.txt // will return a wrong cached result. clearstatcache(); $request = new ezcWebdavDeleteRequest('/collection/test.txt'); $request->validateHeaders(); $response = $backend->delete($request); $this->assertEquals($response, new ezcWebdavMultistatusResponse(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_403, '/collection/test.txt')), 'Expected response does not match real response.', 0, 20); $this->assertTrue(is_file($this->tempDir . 'backend/resource'), 'Expected still existing file.'); chmod($this->tempDir . 'backend/collection', 0777); }
public function testResourceDeleteCausedError() { $backend = new ezcWebdavMemoryBackend(false); $backend->addContents(array('foo' => 'bar', 'bar' => array('blubb' => 'Somme blubb blubbs.'))); $backend->options->failingOperations = ezcWebdavMemoryBackendOptions::REQUEST_DELETE; $backend->options->failForRegexp = '(foo)'; $request = new ezcWebdavDeleteRequest('/foo'); $request->validateHeaders(); $response = $backend->delete($request); $this->assertEquals(new ezcWebdavMultistatusResponse(array(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_423, '/foo'))), $response, 'Expected response does not match real response.', 0, 20); $content = $this->readAttribute($backend, 'content'); $this->assertEquals(array('/' => array('/foo', '/bar'), '/foo' => 'bar', '/bar' => array('/bar/blubb'), '/bar/blubb' => 'Somme blubb blubbs.'), $content); }
/** * Parses the DELETE request and returns a request object. * * This method is responsible for parsing the DELETE request. It retrieves * the current request URI in $path and the request body as $body. The * return value, if no exception is thrown, is a valid {@link * ezcWebdavDeleteRequest} object. * * This method may be overwritten to adjust it to special client behaviour. * * @param string $path * @param string $body * @return ezcWebdavDeleteRequest */ protected function parseDeleteRequest($path, $body) { $req = new ezcWebdavDeleteRequest($path); $req->setHeaders(ezcWebdavServer::getInstance()->headerHandler->parseHeaders()); return $req; }