8require_once 
'Sabre/DAV/AbstractServer.php';
 
   20        $request = 
new HTTP\Request(
'GET', 
'/test.txt');
 
   22        $this->server->httpRequest = 
$request;
 
   23        $this->server->exec();
 
   25        $this->assertEquals(200, $this->response->getStatus(), 
'Invalid status code received.');
 
   28            'Content-Type'    => [
'application/octet-stream'],
 
   29            'Content-Length'  => [13],
 
   33            $this->response->getHeaders()
 
   37        $this->assertEquals(
'Test contents', stream_get_contents($this->response->body));
 
   43        $request = 
new HTTP\Request(
'HEAD', 
'/test.txt');
 
   45        $this->server->httpRequest = (
$request);
 
   46        $this->server->exec();
 
   50            'Content-Type'    => [
'application/octet-stream'],
 
   51            'Content-Length'  => [13],
 
   52            'Last-Modified'   => [HTTP\
Util::toHTTPDate(
new \DateTime(
'@' . filemtime($this->tempDir . 
'/test.txt')))],
 
   55            $this->response->getHeaders()
 
   58        $this->assertEquals(200, $this->response->status);
 
   59        $this->assertEquals(
'', $this->response->body);
 
   65        $request = 
new HTTP\Request(
'PUT', 
'/testput.txt');
 
   66        $filename = $this->tempDir . 
'/testput.txt';
 
   67        $request->setBody(
'Testing new file');
 
   68        $this->server->httpRequest = (
$request);
 
   69        $this->server->exec();
 
   73            'Content-Length'  => [
'0'],
 
   75        ], $this->response->getHeaders());
 
   77        $this->assertEquals(201, $this->response->status);
 
   78        $this->assertEquals(
'', $this->response->body);
 
   79        $this->assertEquals(
'Testing new file', file_get_contents(
$filename));
 
   85        $request = 
new HTTP\Request(
'PUT', 
'/test.txt', [
'If-None-Match' => 
'*']);
 
   86        $request->setBody(
'Testing new file');
 
   87        $this->server->httpRequest = (
$request);
 
   88        $this->server->exec();
 
   92            'Content-Type'    => [
'application/xml; charset=utf-8'],
 
   93        ], $this->response->getHeaders());
 
   95        $this->assertEquals(412, $this->response->status);
 
   96        $this->assertNotEquals(
'Testing new file', file_get_contents($this->tempDir . 
'/test.txt'));
 
  102        $request = 
new HTTP\Request(
'MKCOL', 
'/testcol');
 
  103        $this->server->httpRequest = (
$request);
 
  104        $this->server->exec();
 
  106        $this->assertEquals([
 
  108            'Content-Length'  => [
'0'],
 
  109        ], $this->response->getHeaders());
 
  111        $this->assertEquals(201, $this->response->status);
 
  112        $this->assertEquals(
'', $this->response->body);
 
  113        $this->assertTrue(is_dir($this->tempDir . 
'/testcol'));
 
  119        $request = 
new HTTP\Request(
'PUT', 
'/test.txt');
 
  120        $request->setBody(
'Testing updated file');
 
  121        $this->server->httpRequest = (
$request);
 
  122        $this->server->exec();
 
  124        $this->assertEquals(
'0', $this->response->getHeader(
'Content-Length'));
 
  126        $this->assertEquals(204, $this->response->status);
 
  127        $this->assertEquals(
'', $this->response->body);
 
  128        $this->assertEquals(
'Testing updated file', file_get_contents($this->tempDir . 
'/test.txt'));
 
  134        $request = 
new HTTP\Request(
'DELETE', 
'/test.txt');
 
  135        $this->server->httpRequest = (
$request);
 
  136        $this->server->exec();
 
  138        $this->assertEquals([
 
  140            'Content-Length'  => [
'0'],
 
  141        ], $this->response->getHeaders());
 
  143        $this->assertEquals(204, $this->response->status);
 
  144        $this->assertEquals(
'', $this->response->body);
 
  145        $this->assertFalse(file_exists($this->tempDir . 
'/test.txt'));
 
  151        mkdir($this->tempDir . 
'/testcol');
 
  152        file_put_contents($this->tempDir . 
'/testcol/test.txt', 
'Hi! I\'m a file with a short lifespan');
 
  154        $request = 
new HTTP\Request(
'DELETE', 
'/testcol');
 
  155        $this->server->httpRequest = (
$request);
 
  156        $this->server->exec();
 
  158        $this->assertEquals([
 
  160            'Content-Length'  => [
'0'],
 
  161        ], $this->response->getHeaders());
 
  162        $this->assertEquals(204, $this->response->status);
 
  163        $this->assertEquals(
'', $this->response->body);
 
  164        $this->assertFalse(file_exists($this->tempDir . 
'/testcol'));
 
  170        $request = 
new HTTP\Request(
'OPTIONS', 
'/');
 
  171        $this->server->httpRequest = (
$request);
 
  172        $this->server->exec();
 
  174        $this->assertEquals([
 
  175            'DAV'             => [
'1, 3, extended-mkcol'],
 
  176            'MS-Author-Via'   => [
'DAV'],
 
  177            'Allow'           => [
'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'],
 
  178            'Accept-Ranges'   => [
'bytes'],
 
  179            'Content-Length'  => [
'0'],
 
  181        ], $this->response->getHeaders());
 
  183        $this->assertEquals(200, $this->response->status);
 
  184        $this->assertEquals(
'', $this->response->body);
 
  190        mkdir($this->tempDir . 
'/testcol');
 
  192        $request = 
new HTTP\Request(
'MOVE', 
'/test.txt', [
'Destination' => 
'/testcol/test2.txt']);
 
  193        $this->server->httpRequest = (
$request);
 
  194        $this->server->exec();
 
  196        $this->assertEquals(201, $this->response->status);
 
  197        $this->assertEquals(
'', $this->response->body);
 
  199        $this->assertEquals([
 
  200            'Content-Length'  => [
'0'],
 
  202        ], $this->response->getHeaders());
 
  205            is_file($this->tempDir . 
'/testcol/test2.txt')
 
  220        mkdir($this->tempDir . 
'/tree1');
 
  221        mkdir($this->tempDir . 
'/tree2');
 
  224            new DAV\FS\
Directory($this->tempDir . 
'/tree1'),
 
  225            new DAV\FSExt\
Directory($this->tempDir . 
'/tree2'),
 
  227        $this->server->tree = 
$tree;
 
  229        $request = 
new HTTP\Request(
'MOVE', 
'/tree1', [
'Destination' => 
'/tree2/tree1']);
 
  230        $this->server->httpRequest = (
$request);
 
  231        $this->server->exec();
 
  233        $this->assertEquals(201, $this->response->status);
 
  234        $this->assertEquals(
'', $this->response->body);
 
  236        $this->assertEquals([
 
  237            'Content-Length'  => [
'0'],
 
  239        ], $this->response->getHeaders());
 
  242            is_dir($this->tempDir . 
'/tree2/tree1')
 
An exception for terminatinating execution or to throw for unit testing.
testMoveOtherObject()
This test checks if it's possible to move a non-FSExt collection into a FSExt collection.
The tree object is responsible for basic tree operations.
const VERSION
Full version number.
static toHTTPDate(\DateTime $dateTime)
Transforms a DateTime object to HTTP's most common date format.