public function testPutOnExistingRessource()
 {
     if (version_compare(PHP_VERSION, '5.2.6', '<')) {
         $this->markTestSkipped('PHP DateTime broken in versions < 5.2.6');
         return;
     }
     $backend = new ezcWebdavMemoryBackend();
     $backend->addContents(array('foo' => 'bar', 'bar' => array('blubb' => 'Somme blubb blubbs.')));
     $request = new ezcWebdavPutRequest('/foo', 'some content');
     $request->setHeader('Content-Type', 'text/plain');
     $request->setHeader('Content-Length', strlen($request->body));
     $request->validateHeaders();
     $response = $backend->put($request);
     $expectedResponse = new ezcWebdavPutResponse('/foo');
     $expectedResponse->setHeader('ETag', '1effb2475fcfba4f9e8b8a1dbc8f3caf');
     $this->assertEquals($expectedResponse, $response, 'Expected response does not match real response.', 0, 20);
     $content = $this->readAttribute($backend, 'content');
     $this->assertEquals(array('/' => array('/foo', '/bar'), '/foo' => 'some content', '/bar' => array('/bar/blubb'), '/bar/blubb' => 'Somme blubb blubbs.'), $content);
 }
 public function testPutResourceWithInvalidETag()
 {
     $testPath = '/collection/test.txt';
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     $req = new ezcWebdavPutRequest($testPath, "Some new text to PUT into test.txt.\n");
     $req->setHeader('Content-Length', strlen($req->body));
     $req->setHeader('Content-Type', 'text/plain; charset=utf8');
     $req->setHeader('If-Match', array('abc23', 'foobar'));
     $req->validateHeaders();
     $res = $backend->put($req);
     $this->assertEquals(new ezcWebdavErrorResponse(ezcWebdavResponse::STATUS_412, $testPath, 'If-Match header check failed.'), $res, 'Expected response does not match real response.', 0, 20);
 }
Beispiel #3
0
 public function testPutOnExistingRessource()
 {
     $backend = new ezcWebdavFileBackend($this->tempDir . 'backend/');
     $this->assertTrue(is_file($this->tempDir . 'backend/resource'), 'Expected created resource.');
     $this->assertEquals("Some webdav contents.\n", file_get_contents($this->tempDir . 'backend/resource'));
     $request = new ezcWebdavPutRequest('/resource', 'some content');
     $request->setHeader('Content-Length', strlen($request->body));
     $request->validateHeaders();
     $response = $backend->put($request);
     $expectedResponse = new ezcWebdavPutResponse('/resource');
     $expectedResponse->setHeader('ETag', $backend->getProperty('/resource', 'getetag')->etag);
     $this->assertEquals($expectedResponse, $response, 'Expected response does not match real response.', 0, 20);
     $this->assertTrue(is_file($this->tempDir . 'backend/resource'), 'Expected created resource.');
     $this->assertEquals('some content', file_get_contents($this->tempDir . 'backend/resource'));
 }