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 #2
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'));
 }