예제 #1
0
 public function testValidateHeadersFailure()
 {
     $req = new ezcWebdavMoveRequest('/foo', '/bar');
     $req->setHeader('Overwrite', null);
     try {
         $req->validateHeaders();
         $this->fail('Exception not thrown on missing Overwrite header.');
     } catch (ezcWebdavMissingHeaderException $e) {
     }
     $req->setHeader('Overwrite', 'A');
     try {
         $req->validateHeaders();
         $this->fail('Exception not thrown on invalid Overwrite header.');
     } catch (ezcWebdavInvalidHeaderException $e) {
     }
 }
예제 #2
0
 public function testMoveCollectionWithInvalidETag()
 {
     $testSourcePath = '/collection';
     $testSource = "{$testSourcePath}/deep_collection";
     $testDestPath = $testSourcePath;
     $testDest = "{$testDestPath}/copied_collection";
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     // Initialize all property directories
     $req = new ezcWebdavPropFindRequest($testSource);
     $req->allProp = true;
     $req->setHeader('Depth', ezcWebdavRequest::DEPTH_INFINITY);
     $req->validateHeaders();
     $backend->propFind($req);
     $eTag = $backend->getProperty($testDestPath, 'getetag')->etag;
     $req = new ezcWebdavMoveRequest($testSource, $testDest);
     $req->setHeader('If-None-Match', array('abc23', $eTag));
     $req->validateHeaders();
     $res = $backend->move($req);
     $this->assertEquals(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_412, '/collection', 'If-None-Match header check failed.'), $res, 'Expected response does not match real response.', 0, 20);
 }
예제 #3
0
 public function testResourceMoveDepthInfinityErrors()
 {
     $backend = new ezcWebdavMemoryBackend(false);
     $backend->addContents(array('bar' => array('_1' => 'contents', '_2' => 'contents', '_3' => 'contents', '_4' => 'contents', '_5' => 'contents')));
     $backend->options->failingOperations = ezcWebdavMemoryBackendOptions::REQUEST_COPY;
     $backend->options->failForRegexp = '(_[24]$)';
     $request = new ezcWebdavMoveRequest('/bar', '/foo');
     $request->setHeader('Depth', ezcWebdavRequest::DEPTH_INFINITY);
     $request->validateHeaders();
     $response = $backend->move($request);
     $this->assertEquals(new ezcWebdavMultistatusResponse(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_423, '/bar/_2'), new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_423, '/bar/_4')), $response, 'Expected response does not match real response.', 0, 20);
     $content = $this->readAttribute($backend, 'content');
     $this->assertEquals(array('/' => array('/bar', '/foo'), '/bar' => array('/bar/_1', '/bar/_2', '/bar/_3', '/bar/_4', '/bar/_5'), '/bar/_1' => 'contents', '/bar/_2' => 'contents', '/bar/_3' => 'contents', '/bar/_4' => 'contents', '/bar/_5' => 'contents', '/foo' => array('/foo/_1', '/foo/_3', '/foo/_5'), '/foo/_1' => 'contents', '/foo/_3' => 'contents', '/foo/_5' => 'contents'), $content);
 }
예제 #4
0
 public function testResourceMoveDepthInfinityErrors()
 {
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     // Cause error by making file not readable
     chmod($this->tempDir . 'backend/collection/test.txt', 0);
     $this->assertTrue(is_dir($this->tempDir . 'backend/collection'), 'Expected existing collection before request.');
     $request = new ezcWebdavMoveRequest('/collection', '/new_collection');
     $request->setHeader('Depth', ezcWebdavRequest::DEPTH_INFINITY);
     $request->validateHeaders();
     $response = $backend->move($request);
     $this->assertEquals($response, new ezcWebdavMultistatusResponse(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_423, '/collection/test.txt')), 'Expected response does not match real response.', 0, 20);
     $this->assertTrue(is_dir($this->tempDir . 'backend/collection'), 'Expected collection not to be removed.');
     $this->assertTrue(is_dir($this->tempDir . 'backend/new_collection'), 'Expected created collection.');
     $this->assertFalse(is_file($this->tempDir . 'backend/new_collection/test.txt'), 'Expected file in collection not to be created.');
     $this->assertTrue(is_file($this->tempDir . 'backend/new_collection/deep_collection/deep_test.txt'), 'Expected created deep file in collection.');
     chmod($this->tempDir . 'backend/collection/test.txt', 0777);
 }