aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/FSExt
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/FSExt')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php73
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php178
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php236
3 files changed, 174 insertions, 313 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php
index 8947c6688..3708594e0 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php
@@ -22,73 +22,90 @@ class FileTest extends \PHPUnit_Framework_TestCase {
function testPut() {
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $result = $file->put('New contents');
-
- $this->assertEquals('New contents',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
- $this->assertEquals('"' . md5('New contents') . '"', $result);
+ $filename = SABRE_TEMPDIR . '/file.txt';
+ $file = new File($filename);
+ $result = $file->put('New contents');
+
+ $this->assertEquals('New contents',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
+ $this->assertEquals(
+ '"' .
+ sha1(
+ fileinode($filename) .
+ filesize($filename ) .
+ filemtime($filename)
+ ) . '"',
+ $result
+ );
}
function testRange() {
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $file->put('0000000');
- $file->patch('111', 2, 3);
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $file->put('0000000');
+ $file->patch('111', 2, 3);
- $this->assertEquals('0001110',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
+ $this->assertEquals('0001110',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
}
function testRangeStream() {
- $stream = fopen('php://memory','r+');
- fwrite($stream, "222");
- rewind($stream);
+ $stream = fopen('php://memory','r+');
+ fwrite($stream, "222");
+ rewind($stream);
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $file->put('0000000');
- $file->patch($stream, 2, 3);
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $file->put('0000000');
+ $file->patch($stream, 2, 3);
- $this->assertEquals('0002220',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
+ $this->assertEquals('0002220',file_get_contents(SABRE_TEMPDIR . '/file.txt'));
}
function testGet() {
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $this->assertEquals('Contents',stream_get_contents($file->get()));
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $this->assertEquals('Contents',stream_get_contents($file->get()));
}
function testDelete() {
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $file->delete();
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $file->delete();
- $this->assertFalse(file_exists(SABRE_TEMPDIR . '/file.txt'));
+ $this->assertFalse(file_exists(SABRE_TEMPDIR . '/file.txt'));
}
function testGetETag() {
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $this->assertEquals('"' . md5('Contents') . '"',$file->getETag());
-
+ $filename = SABRE_TEMPDIR . '/file.txt';
+ $file = new File($filename);
+ $this->assertEquals(
+ '"' .
+ sha1(
+ fileinode($filename) .
+ filesize($filename ) .
+ filemtime($filename)
+ ) . '"',
+ $file->getETag()
+ );
}
function testGetContentType() {
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $this->assertNull($file->getContentType());
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $this->assertNull($file->getContentType());
}
function testGetSize() {
- $file = new File(SABRE_TEMPDIR . '/file.txt');
- $this->assertEquals(8,$file->getSize());
+ $file = new File(SABRE_TEMPDIR . '/file.txt');
+ $this->assertEquals(8,$file->getSize());
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php
deleted file mode 100644
index 275075b4c..000000000
--- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/NodeTest.php
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-
-namespace Sabre\DAV\FSExt;
-use Sabre\DAV;
-
-require_once 'Sabre/TestUtil.php';
-
-class NodeTest extends \PHPUnit_Framework_TestCase {
-
- function setUp() {
-
- mkdir(SABRE_TEMPDIR . '/dir');
- file_put_contents(SABRE_TEMPDIR . '/dir/file.txt', 'Contents');
- file_put_contents(SABRE_TEMPDIR . '/dir/file2.txt', 'Contents2');
-
- }
-
- function tearDown() {
-
- \Sabre\TestUtil::clearTempDir();
-
- }
-
- function testUpdateProperties() {
-
- $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
- $properties = array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- );
-
- $result = $file->updateProperties($properties);
- $expected = true;
-
- $this->assertEquals($expected, $result);
-
- $getProperties = $file->getProperties(array_keys($properties));
-
- $this->assertEquals($properties, $getProperties);
-
- }
-
- /**
- * @depends testUpdateProperties
- */
- function testUpdatePropertiesAgain() {
-
- $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
- $mutations = array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- );
-
- $result = $file->updateProperties($mutations);
-
- $this->assertEquals(true, $result);
-
- $mutations = array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test3' => 'baz',
- );
-
- $result = $file->updateProperties($mutations);
-
- $this->assertEquals(true, $result);
- }
-
- /**
- * @depends testUpdateProperties
- */
- function testUpdatePropertiesDelete() {
-
- $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
-
- $mutations = array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- );
-
- $result = $file->updateProperties($mutations);
-
- $this->assertEquals(true, $result);
-
- $mutations = array(
- '{http://sabredav.org/NS/2010}test1' => null,
- '{http://sabredav.org/NS/2010}test3' => null
- );
-
- $result = $file->updateProperties($mutations);
-
- $this->assertEquals(true, $result);
-
- $properties = $file->getProperties(array('http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
-
- $this->assertEquals(array(
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- ), $properties);
- }
-
- /**
- * @depends testUpdateProperties
- */
- function testUpdatePropertiesMove() {
-
- $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
-
- $mutations = array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- );
-
- $result = $file->updateProperties($mutations);
-
- $this->assertEquals(true, $result);
-
- $properties = $file->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
-
- $this->assertEquals(array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- ), $properties);
-
- // Renaming
- $file->setName('file3.txt');
-
- $this->assertFalse(file_exists(SABRE_TEMPDIR . '/dir/file.txt'));
- $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir/file3.txt'));
- $this->assertEquals('file3.txt',$file->getName());
-
- $newFile = new File(SABRE_TEMPDIR . '/dir/file3.txt');
- $this->assertEquals('file3.txt',$newFile->getName());
-
- $properties = $newFile->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
-
- $this->assertEquals(array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- ), $properties);
- }
-
- /**
- * @depends testUpdatePropertiesMove
- */
- function testUpdatePropertiesDeleteBleed() {
-
- $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
- $mutations = array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- );
-
- $result = $file->updateProperties($mutations);
-
- $this->assertEquals(true, $result);
-
- $properties = $file->getProperties(array('{http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
-
- $this->assertEquals(array(
- '{http://sabredav.org/NS/2010}test1' => 'foo',
- '{http://sabredav.org/NS/2010}test2' => 'bar',
- ), $properties);
-
- // Deleting
- $file->delete();
-
- $this->assertFalse(file_exists(SABRE_TEMPDIR . '/dir/file.txt'));
-
- // Creating it again
- file_put_contents(SABRE_TEMPDIR . '/dir/file.txt','New Contents');
- $file = new File(SABRE_TEMPDIR . '/dir/file.txt');
-
- $properties = $file->getProperties(array('http://sabredav.org/NS/2010}test1','{http://sabredav.org/NS/2010}test2','{http://sabredav.org/NS/2010}test3'));
-
- $this->assertEquals(array(), $properties);
-
- }
-
-}
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php
index 907ede40b..63d858de1 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php
@@ -17,116 +17,98 @@ class ServerTest extends DAV\AbstractServer{
function testGet() {
- $serverVars = array(
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'GET',
- );
-
- $request = new HTTP\Request($serverVars);
- $this->server->httpRequest = ($request);
+ $request = new HTTP\Request('GET', '/test.txt');
+ $filename = $this->tempDir . '/test.txt';
+ $this->server->httpRequest = $request;
$this->server->exec();
- $this->assertEquals(array(
- 'Content-Type' => 'application/octet-stream',
- 'Content-Length' => 13,
- 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
- 'ETag' => '"' .md5_file($this->tempDir . '/test.txt') . '"',
- ),
- $this->response->headers
+ $this->assertEquals(200, $this->response->getStatus(), 'Invalid status code received.');
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [13],
+ 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))],
+ 'ETag' => ['"' . sha1(fileinode($filename ) . filesize($filename) . filemtime($filename)) . '"'],
+ ],
+ $this->response->getHeaders()
);
- $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+
$this->assertEquals('Test contents', stream_get_contents($this->response->body));
}
function testHEAD() {
- $serverVars = array(
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'HEAD',
- );
-
- $request = new HTTP\Request($serverVars);
+ $request = new HTTP\Request('HEAD', '/test.txt');
+ $filename = $this->tempDir . '/test.txt';
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(array(
- 'Content-Type' => 'application/octet-stream',
- 'Content-Length' => 13,
- 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))),
- 'ETag' => '"' . md5_file($this->tempDir . '/test.txt') . '"',
- ),
- $this->response->headers
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['application/octet-stream'],
+ 'Content-Length' => [13],
+ 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))],
+ 'ETag' => ['"' . sha1(fileinode($filename ) . filesize($filename) . filemtime($filename)) . '"'],
+ ],
+ $this->response->getHeaders()
);
- $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals(200,$this->response->status);
$this->assertEquals('', $this->response->body);
}
function testPut() {
- $serverVars = array(
- 'REQUEST_URI' => '/testput.txt',
- 'REQUEST_METHOD' => 'PUT',
- );
-
- $request = new HTTP\Request($serverVars);
+ $request = new HTTP\Request('PUT', '/testput.txt');
+ $filename = $this->tempDir . '/testput.txt';
$request->setBody('Testing new file');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(array(
- 'Content-Length' => 0,
- 'ETag' => '"' . md5('Testing new file') . '"',
- ), $this->response->headers);
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Length' => ['0'],
+ 'ETag' => ['"' . sha1(fileinode($filename ) . filesize($filename) . filemtime($filename)) . '"'],
+ ], $this->response->getHeaders());
- $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(201, $this->response->status);
$this->assertEquals('', $this->response->body);
- $this->assertEquals('Testing new file',file_get_contents($this->tempDir . '/testput.txt'));
+ $this->assertEquals('Testing new file',file_get_contents($filename));
}
function testPutAlreadyExists() {
- $serverVars = array(
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'PUT',
- 'HTTP_IF_NONE_MATCH' => '*',
- );
-
- $request = new HTTP\Request($serverVars);
+ $request = new HTTP\Request('PUT', '/test.txt', ['If-None-Match' => '*']);
$request->setBody('Testing new file');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(array(
- 'Content-Type' => 'application/xml; charset=utf-8',
- ),$this->response->headers);
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Type' => ['application/xml; charset=utf-8'],
+ ],$this->response->getHeaders());
- $this->assertEquals('HTTP/1.1 412 Precondition failed',$this->response->status);
+ $this->assertEquals(412, $this->response->status);
$this->assertNotEquals('Testing new file',file_get_contents($this->tempDir . '/test.txt'));
}
function testMkcol() {
- $serverVars = array(
- 'REQUEST_URI' => '/testcol',
- 'REQUEST_METHOD' => 'MKCOL',
- );
-
- $request = new HTTP\Request($serverVars);
- $request->setBody("");
+ $request = new HTTP\Request('MKCOL', '/testcol');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(array(
- 'Content-Length' => '0',
- ),$this->response->headers);
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Length' => ['0'],
+ ],$this->response->getHeaders());
- $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
+ $this->assertEquals(201, $this->response->status);
$this->assertEquals('', $this->response->body);
$this->assertTrue(is_dir($this->tempDir . '/testcol'));
@@ -134,19 +116,14 @@ class ServerTest extends DAV\AbstractServer{
function testPutUpdate() {
- $serverVars = array(
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'PUT',
- );
-
- $request = new HTTP\Request($serverVars);
+ $request = new HTTP\Request('PUT', '/test.txt');
$request->setBody('Testing updated file');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals('0', $this->response->headers['Content-Length']);
+ $this->assertEquals('0', $this->response->getHeader('Content-Length'));
- $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals(204, $this->response->status);
$this->assertEquals('', $this->response->body);
$this->assertEquals('Testing updated file',file_get_contents($this->tempDir . '/test.txt'));
@@ -154,20 +131,16 @@ class ServerTest extends DAV\AbstractServer{
function testDelete() {
- $serverVars = array(
- 'REQUEST_URI' => '/test.txt',
- 'REQUEST_METHOD' => 'DELETE',
- );
-
- $request = new HTTP\Request($serverVars);
+ $request = new HTTP\Request('DELETE', '/test.txt');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(array(
- 'Content-Length' => '0',
- ),$this->response->headers);
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Length' => ['0'],
+ ],$this->response->getHeaders());
- $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals(204, $this->response->status);
$this->assertEquals('', $this->response->body);
$this->assertFalse(file_exists($this->tempDir . '/test.txt'));
@@ -175,50 +148,99 @@ class ServerTest extends DAV\AbstractServer{
function testDeleteDirectory() {
- $serverVars = array(
- 'REQUEST_URI' => '/testcol',
- 'REQUEST_METHOD' => 'DELETE',
- );
-
mkdir($this->tempDir.'/testcol');
file_put_contents($this->tempDir.'/testcol/test.txt','Hi! I\'m a file with a short lifespan');
- $request = new HTTP\Request($serverVars);
+ $request = new HTTP\Request('DELETE', '/testcol');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(array(
- 'Content-Length' => '0',
- ),$this->response->headers);
- $this->assertEquals('HTTP/1.1 204 No Content',$this->response->status);
+ $this->assertEquals([
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Length' => ['0'],
+ ],$this->response->getHeaders());
+ $this->assertEquals(204, $this->response->status);
$this->assertEquals('', $this->response->body);
- $this->assertFalse(file_exists($this->tempDir . '/col'));
+ $this->assertFalse(file_exists($this->tempDir . '/testcol'));
}
function testOptions() {
- $serverVars = array(
- 'REQUEST_URI' => '/',
- 'REQUEST_METHOD' => 'OPTIONS',
- );
-
- $request = new HTTP\Request($serverVars);
+ $request = new HTTP\Request('OPTIONS', '/');
$this->server->httpRequest = ($request);
$this->server->exec();
- $this->assertEquals(array(
- 'DAV' => '1, 3, extended-mkcol',
- 'MS-Author-Via' => 'DAV',
- 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT',
- 'Accept-Ranges' => 'bytes',
- 'Content-Length' => '0',
- 'X-Sabre-Version'=> DAV\Version::VERSION,
- ),$this->response->headers);
+ $this->assertEquals([
+ 'DAV' => ['1, 3, extended-mkcol'],
+ 'MS-Author-Via' => ['DAV'],
+ 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'],
+ 'Accept-Ranges' => ['bytes'],
+ 'Content-Length' => ['0'],
+ 'X-Sabre-Version'=> [DAV\Version::VERSION],
+ ], $this->response->getHeaders());
- $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
+ $this->assertEquals(200, $this->response->status);
$this->assertEquals('', $this->response->body);
}
+ function testMove() {
+
+ mkdir($this->tempDir.'/testcol');
+
+ $request = new HTTP\Request('MOVE', '/test.txt', ['Destination' => '/testcol/test2.txt']);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(201, $this->response->status);
+ $this->assertEquals('', $this->response->body);
+
+ $this->assertEquals([
+ 'Content-Length' => ['0'],
+ 'X-Sabre-Version'=> [DAV\Version::VERSION],
+ ],$this->response->getHeaders());
+
+ $this->assertTrue(
+ is_file($this->tempDir . '/testcol/test2.txt')
+ );
+
+
+ }
+
+ /**
+ * This test checks if it's possible to move a non-FSExt collection into a
+ * FSExt collection.
+ *
+ * The moveInto function *should* ignore the object and let sabredav itself
+ * execute the slow move.
+ */
+ function testMoveOtherObject() {
+
+ mkdir($this->tempDir.'/tree1');
+ mkdir($this->tempDir.'/tree2');
+
+ $tree = new DAV\Tree(new DAV\SimpleCollection('root', [
+ new DAV\FS\Directory($this->tempDir . '/tree1'),
+ new DAV\FSExt\Directory($this->tempDir . '/tree2'),
+ ]));
+ $this->server->tree = $tree;
+
+ $request = new HTTP\Request('MOVE', '/tree1', ['Destination' => '/tree2/tree1']);
+ $this->server->httpRequest = ($request);
+ $this->server->exec();
+
+ $this->assertEquals(201, $this->response->status);
+ $this->assertEquals('', $this->response->body);
+
+ $this->assertEquals([
+ 'Content-Length' => ['0'],
+ 'X-Sabre-Version'=> [DAV\Version::VERSION],
+ ],$this->response->getHeaders());
+
+ $this->assertTrue(
+ is_dir($this->tempDir . '/tree2/tree1')
+ );
+
+ }
}