Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }