diff options
author | Mario <mario@mariovavti.com> | 2019-11-10 12:49:51 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-11-10 14:10:03 +0100 |
commit | 580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch) | |
tree | 82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/tests/Sabre/DAV | |
parent | d22766f458a8539a40a57f3946459a9be1f21cd6 (diff) | |
download | volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2 volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip |
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV')
52 files changed, 1846 insertions, 2404 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php index 6a8d389a0..5f5d666f9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/AbstractServer.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -abstract class AbstractServer extends \PHPUnit_Framework_TestCase { - +abstract class AbstractServer extends \PHPUnit\Framework\TestCase +{ /** * @var Sabre\HTTP\ResponseMock */ @@ -17,48 +19,44 @@ abstract class AbstractServer extends \PHPUnit_Framework_TestCase { protected $server; protected $tempDir = SABRE_TEMPDIR; - function setUp() { - + public function setUp() + { $this->response = new HTTP\ResponseMock(); $this->server = new Server($this->getRootNode()); $this->server->sapi = new HTTP\SapiMock(); $this->server->httpResponse = $this->response; $this->server->debugExceptions = true; $this->deleteTree(SABRE_TEMPDIR, false); - file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents'); - mkdir(SABRE_TEMPDIR . '/dir'); - file_put_contents(SABRE_TEMPDIR . '/dir/child.txt', 'Child contents'); - - + file_put_contents(SABRE_TEMPDIR.'/test.txt', 'Test contents'); + mkdir(SABRE_TEMPDIR.'/dir'); + file_put_contents(SABRE_TEMPDIR.'/dir/child.txt', 'Child contents'); } - function tearDown() { - + public function tearDown() + { $this->deleteTree(SABRE_TEMPDIR, false); - } - protected function getRootNode() { - + protected function getRootNode() + { return new FS\Directory(SABRE_TEMPDIR); - } - private function deleteTree($path, $deleteRoot = true) { - + private function deleteTree($path, $deleteRoot = true) + { foreach (scandir($path) as $node) { - - if ($node == '.' || $node == '.svn' || $node == '..') continue; - $myPath = $path . '/' . $node; + if ('.' == $node || '.svn' == $node || '..' == $node) { + continue; + } + $myPath = $path.'/'.$node; if (is_file($myPath)) { unlink($myPath); } else { $this->deleteTree($myPath); } - } - if ($deleteRoot) rmdir($path); - + if ($deleteRoot) { + rmdir($path); + } } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php index 917f5ec3f..ebc1e3f7b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP; -class AbstractBasicTest extends \PHPUnit_Framework_TestCase { - - function testCheckNoHeaders() { - - $request = new HTTP\Request(); +class AbstractBasicTest extends \PHPUnit\Framework\TestCase +{ + public function testCheckNoHeaders() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); @@ -16,14 +18,15 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckUnknownUser() { - + public function testCheckUnknownUser() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'wrongpassword', + 'PHP_AUTH_PW' => 'wrongpassword', ]); $response = new HTTP\Response(); @@ -32,14 +35,15 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckSuccess() { - + public function testCheckSuccess() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'password', + 'PHP_AUTH_PW' => 'password', ]); $response = new HTTP\Response(); @@ -48,44 +52,39 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase { [true, 'principals/username'], $backend->check($request, $response) ); - } - function testRequireAuth() { - - $request = new HTTP\Request(); + public function testRequireAuth() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractBasicMock(); $backend->setRealm('writing unittests on a saturday night'); $backend->challenge($request, $response); - $this->assertContains( - 'Basic realm="writing unittests on a saturday night"', + $this->assertEquals( + 'Basic realm="writing unittests on a saturday night", charset="UTF-8"', $response->getHeader('WWW-Authenticate') ); - } - } - -class AbstractBasicMock extends AbstractBasic { - +class AbstractBasicMock extends AbstractBasic +{ /** - * Validates a username and password + * Validates a username and password. * * This method should return true or false depending on if login * succeeded. * * @param string $username * @param string $password + * * @return bool */ - function validateUserPass($username, $password) { - - return ($username == 'username' && $password == 'password'); - + public function validateUserPass($username, $password) + { + return 'username' == $username && 'password' == $password; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php index 14c72aaa0..d9af326fe 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractDigestTest.php @@ -1,27 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP; -class AbstractDigestTest extends \PHPUnit_Framework_TestCase { - - function testCheckNoHeaders() { - - $request = new HTTP\Request(); +class AbstractDigestTest extends \PHPUnit\Framework\TestCase +{ + public function testCheckNoHeaders() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractDigestMock(); $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckBadGetUserInfoResponse() { - + public function testCheckBadGetUserInfoResponse() + { $header = 'username=null, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, ]); $response = new HTTP\Response(); @@ -30,16 +33,17 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testCheckBadGetUserInfoResponse2() { - + public function testCheckBadGetUserInfoResponse2() + { $header = 'username=array, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, ]); @@ -47,13 +51,14 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $backend = new AbstractDigestMock(); $backend->check($request, $response); - } - function testCheckUnknownUser() { - + public function testCheckUnknownUser() + { $header = 'username=false, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, ]); @@ -63,15 +68,15 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheckBadPassword() { - + public function testCheckBadPassword() + { $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=HASH, opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'PUT', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, - 'REQUEST_METHOD' => 'PUT', ]); $response = new HTTP\Response(); @@ -80,17 +85,16 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testCheck() { - - $digestHash = md5('HELLO:12345:1:1:auth:' . md5('GET:/')); - $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=' . $digestHash . ', opaque=1, qop=auth, nc=1, cnonce=1'; + public function testCheck() + { + $digestHash = md5('HELLO:12345:1:1:auth:'.md5('GET:/')); + $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response='.$digestHash.', opaque=1, qop=auth, nc=1, cnonce=1'; $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'GET', + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'PHP_AUTH_DIGEST' => $header, - 'REQUEST_URI' => '/', ]); $response = new HTTP\Response(); @@ -100,12 +104,11 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { [true, 'principals/user'], $backend->check($request, $response) ); - } - function testRequireAuth() { - - $request = new HTTP\Request(); + public function testRequireAuth() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new AbstractDigestMock(); @@ -116,23 +119,18 @@ class AbstractDigestTest extends \PHPUnit_Framework_TestCase { 'Digest realm="writing unittests on a saturday night"', $response->getHeader('WWW-Authenticate') ); - } - } - -class AbstractDigestMock extends AbstractDigest { - - function getDigestHash($realm, $userName) { - +class AbstractDigestMock extends AbstractDigest +{ + public function getDigestHash($realm, $userName) + { switch ($userName) { - case 'null' : return null; - case 'false' : return false; - case 'array' : return []; - case 'user' : return 'HELLO'; + case 'null': return null; + case 'false': return false; + case 'array': return []; + case 'user': return 'HELLO'; } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php index b14e9fa2e..5e34f9c49 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/AbstractPDOTest.php @@ -1,36 +1,35 @@ <?php -namespace Sabre\DAV\Auth\Backend; +declare(strict_types=1); -abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { +namespace Sabre\DAV\Auth\Backend; +abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase +{ use \Sabre\DAV\DbTestHelperTrait; - function setUp() { - + public function setUp() + { $this->dropTables('users'); $this->createSchema('users'); $this->getPDO()->query( "INSERT INTO users (username,digesta1) VALUES ('user','hash')" - ); - } - function testConstruct() { - + public function testConstruct() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertTrue($backend instanceof PDO); - } /** * @depends testConstruct */ - function testUserInfo() { - + public function testUserInfo() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); @@ -39,7 +38,5 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = 'hash'; $this->assertEquals($expected, $backend->getDigestHash('realm', 'user')); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php index 29cbc2162..a0086518f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/ApacheTest.php @@ -1,33 +1,35 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP; -class ApacheTest extends \PHPUnit_Framework_TestCase { - - function testConstruct() { - +class ApacheTest extends \PHPUnit\Framework\TestCase +{ + public function testConstruct() + { $backend = new Apache(); $this->assertInstanceOf('Sabre\DAV\Auth\Backend\Apache', $backend); - } - function testNoHeader() { - - $request = new HTTP\Request(); + public function testNoHeader() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new Apache(); $this->assertFalse( $backend->check($request, $response)[0] ); - } - function testRemoteUser() { - + public function testRemoteUser() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'REMOTE_USER' => 'username', ]); $response = new HTTP\Response(); @@ -37,12 +39,13 @@ class ApacheTest extends \PHPUnit_Framework_TestCase { [true, 'principals/username'], $backend->check($request, $response) ); - } - function testRedirectRemoteUser() { - + public function testRedirectRemoteUser() + { $request = HTTP\Sapi::createFromServerArray([ + 'REQUEST_METHOD' => 'GET', + 'REQUEST_URI' => '/', 'REDIRECT_REMOTE_USER' => 'username', ]); $response = new HTTP\Response(); @@ -52,12 +55,11 @@ class ApacheTest extends \PHPUnit_Framework_TestCase { [true, 'principals/username'], $backend->check($request, $response) ); - } - function testRequireAuth() { - - $request = new HTTP\Request(); + public function testRequireAuth() + { + $request = new HTTP\Request('GET', '/'); $response = new HTTP\Response(); $backend = new Apache(); @@ -66,6 +68,5 @@ class ApacheTest extends \PHPUnit_Framework_TestCase { $this->assertNull( $response->getHeader('WWW-Authenticate') ); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php index f694f4806..0297b17f9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/FileTest.php @@ -1,41 +1,40 @@ <?php -namespace Sabre\DAV\Auth\Backend; - -class FileTest extends \PHPUnit_Framework_TestCase { - - function tearDown() { +declare(strict_types=1); - if (file_exists(SABRE_TEMPDIR . '/filebackend')) unlink(SABRE_TEMPDIR . '/filebackend'); +namespace Sabre\DAV\Auth\Backend; +class FileTest extends \PHPUnit\Framework\TestCase +{ + public function tearDown() + { + if (file_exists(SABRE_TEMPDIR.'/filebackend')) { + unlink(SABRE_TEMPDIR.'/filebackend'); + } } - function testConstruct() { - + public function testConstruct() + { $file = new File(); $this->assertTrue($file instanceof File); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testLoadFileBroken() { - - file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:hash'); - $file = new File(SABRE_TEMPDIR . '/backend'); - + public function testLoadFileBroken() + { + file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:hash'); + $file = new File(SABRE_TEMPDIR.'/backend'); } - function testLoadFile() { - - file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:' . md5('user:realm:password')); + public function testLoadFile() + { + file_put_contents(SABRE_TEMPDIR.'/backend', 'user:realm:'.md5('user:realm:password')); $file = new File(); - $file->loadFile(SABRE_TEMPDIR . '/backend'); + $file->loadFile(SABRE_TEMPDIR.'/backend'); $this->assertFalse($file->getDigestHash('realm', 'blabla')); $this->assertEquals(md5('user:realm:password'), $file->getDigestHash('realm', 'user')); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php index 369bc249e..730f2a975 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/Mock.php @@ -1,22 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth\Backend; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -class Mock implements BackendInterface { - +class Mock implements BackendInterface +{ public $fail = false; public $invalidCheckResponse = false; public $principal = 'principals/admin'; - function setPrincipal($principal) { - + public function setPrincipal($principal) + { $this->principal = $principal; - } /** @@ -43,20 +44,21 @@ class Mock implements BackendInterface { * * principals/users/[username] * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response + * * @return array */ - function check(RequestInterface $request, ResponseInterface $response) { - + public function check(RequestInterface $request, ResponseInterface $response) + { if ($this->invalidCheckResponse) { return 'incorrect!'; } if ($this->fail) { - return [false, "fail!"]; + return [false, 'fail!']; } - return [true, $this->principal]; + return [true, $this->principal]; } /** @@ -76,12 +78,10 @@ class Mock implements BackendInterface { * append your own WWW-Authenticate header instead of overwriting the * existing one. * - * @param RequestInterface $request + * @param RequestInterface $request * @param ResponseInterface $response - * @return void */ - function challenge(RequestInterface $request, ResponseInterface $response) { - + public function challenge(RequestInterface $request, ResponseInterface $response) + { } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php index 18f59793a..6ad7906c4 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAV\Auth\Backend; +declare(strict_types=1); -class PDOMySQLTest extends AbstractPDOTest { +namespace Sabre\DAV\Auth\Backend; +class PDOMySQLTest extends AbstractPDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php index b1f382237..b42b40eff 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAV\Auth\Backend; +declare(strict_types=1); -class PDOSqliteTest extends AbstractPDOTest { +namespace Sabre\DAV\Auth\Backend; +class PDOSqliteTest extends AbstractPDOTest +{ public $driver = 'sqlite'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php index 743446127..03c8a4624 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php @@ -1,58 +1,57 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Auth; use Sabre\DAV; use Sabre\HTTP; -class PluginTest extends \PHPUnit_Framework_TestCase { - - function testInit() { - +class PluginTest extends \PHPUnit\Framework\TestCase +{ + public function testInit() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('auth')); $this->assertInternalType('array', $plugin->getPluginInfo()); - } /** * @depends testInit */ - function testAuthenticate() { - + public function testAuthenticate() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); $this->assertTrue( - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) ); - } /** * @depends testInit - * @expectedException Sabre\DAV\Exception\NotAuthenticated + * @expectedException \Sabre\DAV\Exception\NotAuthenticated */ - function testAuthenticateFail() { - + public function testAuthenticateFail() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; $plugin = new Plugin($backend); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } /** * @depends testAuthenticateFail */ - function testAuthenticateFailDontAutoRequire() { - + public function testAuthenticateFailDontAutoRequire() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->fail = true; @@ -61,17 +60,16 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $plugin->autoRequireLogin = false; $fakeServer->addPlugin($plugin); $this->assertTrue( - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]) + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]) ); $this->assertEquals(1, count($plugin->getLoginFailedReasons())); - } /** * @depends testAuthenticate */ - function testMultipleBackend() { - + public function testMultipleBackend() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend1 = new Backend\Mock(); $backend2 = new Backend\Mock(); @@ -82,52 +80,48 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $plugin->addBackend($backend2); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } /** * @depends testInit - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testNoAuthBackend() { - + public function testNoAuthBackend() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } + /** * @depends testInit - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testInvalidCheckResponse() { - + public function testInvalidCheckResponse() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $backend = new Backend\Mock(); $backend->invalidCheckResponse = true; $plugin = new Plugin($backend); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); - + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); } /** * @depends testAuthenticate */ - function testGetCurrentPrincipal() { - + public function testGetCurrentPrincipal() + { $fakeServer = new DAV\Server(new DAV\SimpleCollection('bla')); $plugin = new Plugin(new Backend\Mock()); $fakeServer->addPlugin($plugin); - $fakeServer->emit('beforeMethod', [new HTTP\Request(), new HTTP\Response()]); + $fakeServer->emit('beforeMethod:GET', [new HTTP\Request('GET', '/'), new HTTP\Response()]); $this->assertEquals('principals/admin', $plugin->getCurrentPrincipal()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php index ec104ec80..60fcc73fc 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php @@ -1,235 +1,138 @@ <?php -namespace Sabre\DAV; +declare(strict_types=1); -class BasicNodeTest extends \PHPUnit_Framework_TestCase { +namespace Sabre\DAV; +class BasicNodeTest extends \PHPUnit\Framework\TestCase +{ /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testPut() { - + public function testPut() + { $file = new FileMock(); $file->put('hi'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testGet() { - + public function testGet() + { $file = new FileMock(); $file->get(); - } - function testGetSize() { - + public function testGetSize() + { $file = new FileMock(); $this->assertEquals(0, $file->getSize()); - } - - function testGetETag() { - + public function testGetETag() + { $file = new FileMock(); $this->assertNull($file->getETag()); - } - function testGetContentType() { - + public function testGetContentType() + { $file = new FileMock(); $this->assertNull($file->getContentType()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testDelete() { - + public function testDelete() + { $file = new FileMock(); $file->delete(); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetName() { - + public function testSetName() + { $file = new FileMock(); $file->setName('hi'); - } - function testGetLastModified() { - + public function testGetLastModified() + { $file = new FileMock(); // checking if lastmod is within the range of a few seconds $lastMod = $file->getLastModified(); $compareTime = ($lastMod + 1) - time(); $this->assertTrue($compareTime < 3); - } - function testGetChild() { - + public function testGetChild() + { $dir = new DirectoryMock(); $file = $dir->getChild('mockfile'); $this->assertTrue($file instanceof FileMock); - } - function testChildExists() { - + public function testChildExists() + { $dir = new DirectoryMock(); $this->assertTrue($dir->childExists('mockfile')); - } - function testChildExistsFalse() { - + public function testChildExistsFalse() + { $dir = new DirectoryMock(); $this->assertFalse($dir->childExists('mockfile2')); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChild404() { - + public function testGetChild404() + { $dir = new DirectoryMock(); $file = $dir->getChild('blabla'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateFile() { - + public function testCreateFile() + { $dir = new DirectoryMock(); $dir->createFile('hello', 'data'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $dir = new DirectoryMock(); $dir->createDirectory('hello'); - - } - - function testSimpleDirectoryConstruct() { - - $dir = new SimpleCollection('simpledir', []); - $this->assertInstanceOf('Sabre\DAV\SimpleCollection', $dir); - - } - - /** - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryConstructChild() { - - $file = new FileMock(); - $dir = new SimpleCollection('simpledir', [$file]); - $file2 = $dir->getChild('mockfile'); - - $this->assertEquals($file, $file2); - - } - - /** - * @expectedException Sabre\DAV\Exception - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryBadParam() { - - $dir = new SimpleCollection('simpledir', ['string shouldn\'t be here']); - - } - - /** - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryAddChild() { - - $file = new FileMock(); - $dir = new SimpleCollection('simpledir'); - $dir->addChild($file); - $file2 = $dir->getChild('mockfile'); - - $this->assertEquals($file, $file2); - - } - - /** - * @depends testSimpleDirectoryConstruct - * @depends testSimpleDirectoryAddChild - */ - function testSimpleDirectoryGetChildren() { - - $file = new FileMock(); - $dir = new SimpleCollection('simpledir'); - $dir->addChild($file); - - $this->assertEquals([$file], $dir->getChildren()); - - } - - /* - * @depends testSimpleDirectoryConstruct - */ - function testSimpleDirectoryGetName() { - - $dir = new SimpleCollection('simpledir'); - $this->assertEquals('simpledir', $dir->getName()); - - } - - /** - * @depends testSimpleDirectoryConstruct - * @expectedException Sabre\DAV\Exception\NotFound - */ - function testSimpleDirectoryGetChild404() { - - $dir = new SimpleCollection('simpledir'); - $dir->getChild('blabla'); - } } -class DirectoryMock extends Collection { - - function getName() { - +class DirectoryMock extends Collection +{ + public function getName() + { return 'mockdir'; - } - function getChildren() { - + public function getChildren() + { return [new FileMock()]; - } - } -class FileMock extends File { - - function getName() { - +class FileMock extends File +{ + public function getName() + { return 'mockfile'; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php index 54a3053ec..1f48256e0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/GuessContentTypeTest.php @@ -1,29 +1,30 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; require_once 'Sabre/DAV/AbstractServer.php'; -class GuessContentTypeTest extends DAV\AbstractServer { - - function setUp() { - +class GuessContentTypeTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); \Sabre\TestUtil::clearTempDir(); - file_put_contents(SABRE_TEMPDIR . '/somefile.jpg', 'blabla'); - file_put_contents(SABRE_TEMPDIR . '/somefile.hoi', 'blabla'); - + file_put_contents(SABRE_TEMPDIR.'/somefile.jpg', 'blabla'); + file_put_contents(SABRE_TEMPDIR.'/somefile.hoi', 'blabla'); } - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); parent::tearDown(); } - function testGetProperties() { - + public function testGetProperties() + { $properties = [ '{DAV:}getcontenttype', ]; @@ -31,31 +32,29 @@ class GuessContentTypeTest extends DAV\AbstractServer { $this->assertArrayHasKey(0, $result); $this->assertArrayHasKey(404, $result[0]); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][404]); - } /** * @depends testGetProperties */ - function testGetPropertiesPluginEnabled() { - + public function testGetPropertiesPluginEnabled() + { $this->server->addPlugin(new GuessContentType()); $properties = [ '{DAV:}getcontenttype', ]; $result = $this->server->getPropertiesForPath('/somefile.jpg', $properties); $this->assertArrayHasKey(0, $result); - $this->assertArrayHasKey(200, $result[0], 'We received: ' . print_r($result, true)); + $this->assertArrayHasKey(200, $result[0], 'We received: '.print_r($result, true)); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); $this->assertEquals('image/jpeg', $result[0][200]['{DAV:}getcontenttype']); - } /** * @depends testGetPropertiesPluginEnabled */ - function testGetPropertiesUnknown() { - + public function testGetPropertiesUnknown() + { $this->server->addPlugin(new GuessContentType()); $properties = [ '{DAV:}getcontenttype', @@ -65,6 +64,5 @@ class GuessContentTypeTest extends DAV\AbstractServer { $this->assertArrayHasKey(200, $result[0]); $this->assertArrayHasKey('{DAV:}getcontenttype', $result[0][200]); $this->assertEquals('application/octet-stream', $result[0][200]['{DAV:}getcontenttype']); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php index 33c4ede96..de7b85f32 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/MapGetToPropFindTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -7,19 +9,18 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class MapGetToPropFindTest extends DAV\AbstractServer { - - function setUp() { - +class MapGetToPropFindTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); $this->server->addPlugin(new MapGetToPropFind()); - } - function testCollectionGet() { - + public function testCollectionGet() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET', ]; @@ -28,17 +29,14 @@ class MapGetToPropFindTest extends DAV\AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol'], + 'Vary' => ['Brief,Prefer'], ], $this->response->getHeaders() ); - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php index f20c50f86..fb7c63d46 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Browser/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Browser; use Sabre\DAV; @@ -7,129 +9,123 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class PluginTest extends DAV\AbstractServer{ - +class PluginTest extends DAV\AbstractServer +{ protected $plugin; - function setUp() { - + public function setUp() + { parent::setUp(); $this->server->addPlugin($this->plugin = new Plugin()); $this->server->tree->getNodeForPath('')->createDirectory('dir2'); - } - function testCollectionGet() { - + public function testCollectionGet() + { $request = new HTTP\Request('GET', '/dir'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>dir'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); } /** * Adding the If-None-Match should have 0 effect, but it threw an error. */ - function testCollectionGetIfNoneMatch() { - + public function testCollectionGetIfNoneMatch() + { $request = new HTTP\Request('GET', '/dir'); $request->setHeader('If-None-Match', '"foo-bar"'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->getStatus(), 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>dir') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>dir'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/child.txt">')); } - function testCollectionGetRoot() { + public function testCollectionGetRoot() + { $request = new HTTP\Request('GET', '/'); $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString()); + $this->assertEquals(200, $this->response->status, 'Incorrect status received. Full response body: '.$this->response->getBodyAsString()); $this->assertEquals( [ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['text/html; charset=utf-8'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['text/html; charset=utf-8'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders() ); $body = $this->response->getBodyAsString(); - $this->assertTrue(strpos($body, '<title>/') !== false, $body); - $this->assertTrue(strpos($body, '<a href="/dir/">') !== false); - $this->assertTrue(strpos($body, '<span class="btn disabled">') !== false); - + $this->assertTrue(false !== strpos($body, '<title>/'), $body); + $this->assertTrue(false !== strpos($body, '<a href="/dir/">')); + $this->assertTrue(false !== strpos($body, '<span class="btn disabled">')); } - function testGETPassthru() { - + public function testGETPassthru() + { $request = new HTTP\Request('GET', '/random'); $response = new HTTP\Response(); $this->assertNull( $this->plugin->httpGet($request, $response) ); - } - function testPostOtherContentType() { - + public function testPostOtherContentType() + { $request = new HTTP\Request('POST', '/', ['Content-Type' => 'text/xml']); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(501, $this->response->status); - } - function testPostNoSabreAction() { - + public function testPostNoSabreAction() + { $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']); $request->setPostData([]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(501, $this->response->status); - } - function testPostMkCol() { - + public function testPostMkCol() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', ]; $postVars = [ 'sabreAction' => 'mkcol', - 'name' => 'new_collection', + 'name' => 'new_collection', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -140,47 +136,43 @@ class PluginTest extends DAV\AbstractServer{ $this->assertEquals(302, $this->response->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Location' => ['/'], + 'Location' => ['/'], ], $this->response->getHeaders()); - $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection')); - + $this->assertTrue(is_dir(SABRE_TEMPDIR.'/new_collection')); } - function testGetAsset() { - + public function testGetAsset() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=favicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(200, $this->response->getStatus(), 'Error: ' . $this->response->body); + $this->assertEquals(200, $this->response->getStatus(), 'Error: '.$this->response->body); $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['image/vnd.microsoft.icon'], - 'Content-Length' => ['4286'], - 'Cache-Control' => ['public, max-age=1209600'], - 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"] + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Type' => ['image/vnd.microsoft.icon'], + 'Content-Length' => ['4286'], + 'Cache-Control' => ['public, max-age=1209600'], + 'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"], ], $this->response->getHeaders()); - } - function testGetAsset404() { - + public function testGetAsset404() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=flavicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body); - + $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->body); } - function testGetAssetEscapeBasePath() { - + public function testGetAssetEscapeBasePath() + { $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=./../assets/favicon.ico'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body); - + $this->assertEquals(404, $this->response->getStatus(), 'Error: '.$this->response->body); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php index 5a48b063c..7d787744a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php @@ -1,11 +1,14 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; -class ClientMock extends Client { - +class ClientMock extends Client +{ public $request; public $response; @@ -13,22 +16,21 @@ class ClientMock extends Client { public $curlSettings; /** - * Just making this method public + * Just making this method public. * * @param string $url + * * @return string */ - function getAbsoluteUrl($url) { - + public function getAbsoluteUrl($url) + { return parent::getAbsoluteUrl($url); - } - function doRequest(RequestInterface $request) { - + public function doRequest(RequestInterface $request): ResponseInterface + { $this->request = $request; - return $this->response; + return $this->response; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php index 687f61e2f..e9362c8e4 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php @@ -1,119 +1,111 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; -use Sabre\HTTP\Request; use Sabre\HTTP\Response; require_once 'Sabre/DAV/ClientMock.php'; -class ClientTest extends \PHPUnit_Framework_TestCase { - - function setUp() { - +class ClientTest extends \PHPUnit\Framework\TestCase +{ + public function setUp() + { if (!function_exists('curl_init')) { $this->markTestSkipped('CURL must be installed to test the client'); } - } - function testConstruct() { - + public function testConstruct() + { $client = new ClientMock([ 'baseUri' => '/', ]); $this->assertInstanceOf('Sabre\DAV\ClientMock', $client); - } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ - function testConstructNoBaseUri() { - + public function testConstructNoBaseUri() + { $client = new ClientMock([]); - } - function testAuth() { - + public function testAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_BASIC | CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testBasicAuth() { - + public function testBasicAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', - 'authType' => Client::AUTH_BASIC + 'authType' => Client::AUTH_BASIC, ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_BASIC, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testDigestAuth() { - + public function testDigestAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', - 'authType' => Client::AUTH_DIGEST + 'authType' => Client::AUTH_DIGEST, ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testNTLMAuth() { - + public function testNTLMAuth() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'userName' => 'foo', 'password' => 'bar', - 'authType' => Client::AUTH_NTLM + 'authType' => Client::AUTH_NTLM, ]); - $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]); + $this->assertEquals('foo:bar', $client->curlSettings[CURLOPT_USERPWD]); $this->assertEquals(CURLAUTH_NTLM, $client->curlSettings[CURLOPT_HTTPAUTH]); - } - function testProxy() { - + public function testProxy() + { $client = new ClientMock([ 'baseUri' => '/', - 'proxy' => 'localhost:8888', + 'proxy' => 'localhost:8888', ]); - $this->assertEquals("localhost:8888", $client->curlSettings[CURLOPT_PROXY]); - + $this->assertEquals('localhost:8888', $client->curlSettings[CURLOPT_PROXY]); } - function testEncoding() { - + public function testEncoding() + { $client = new ClientMock([ - 'baseUri' => '/', + 'baseUri' => '/', 'encoding' => Client::ENCODING_IDENTITY | Client::ENCODING_GZIP | Client::ENCODING_DEFLATE, ]); - $this->assertEquals("identity,deflate,gzip", $client->curlSettings[CURLOPT_ENCODING]); - + $this->assertEquals('identity,deflate,gzip', $client->curlSettings[CURLOPT_ENCODING]); } - function testPropFind() { - + public function testPropFind() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -142,28 +134,26 @@ XML; $this->assertEquals('PROPFIND', $request->getMethod()); $this->assertEquals('/foo', $request->getUrl()); $this->assertEquals([ - 'Depth' => ['0'], + 'Depth' => ['0'], 'Content-Type' => ['application/xml'], ], $request->getHeaders()); - } /** * @expectedException \Sabre\HTTP\ClientHttpException */ - function testPropFindError() { - + public function testPropFindError() + { $client = new ClientMock([ 'baseUri' => '/', ]); $client->response = new Response(405, []); $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir']); - } - function testPropFindDepth1() { - + public function testPropFindDepth1() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -188,7 +178,7 @@ XML; $this->assertEquals([ '/foo' => [ - '{DAV:}displayname' => 'bar' + '{DAV:}displayname' => 'bar', ], ], $result); @@ -196,14 +186,13 @@ XML; $this->assertEquals('PROPFIND', $request->getMethod()); $this->assertEquals('/foo', $request->getUrl()); $this->assertEquals([ - 'Depth' => ['1'], + 'Depth' => ['1'], 'Content-Type' => ['application/xml'], ], $request->getHeaders()); - } - function testPropPatch() { - + public function testPropPatch() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -232,30 +221,28 @@ XML; $this->assertEquals([ 'Content-Type' => ['application/xml'], ], $request->getHeaders()); - } /** * @depends testPropPatch * @expectedException \Sabre\HTTP\ClientHttpException */ - function testPropPatchHTTPError() { - + public function testPropPatchHTTPError() + { $client = new ClientMock([ 'baseUri' => '/', ]); $client->response = new Response(403, [], ''); $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]); - } /** * @depends testPropPatch - * @expectedException Sabre\HTTP\ClientException + * @expectedException \Sabre\HTTP\ClientException */ - function testPropPatchMultiStatusError() { - + public function testPropPatchMultiStatusError() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -277,11 +264,10 @@ XML; $client->response = new Response(207, [], $responseBody); $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]); - } - function testOPTIONS() { - + public function testOPTIONS() + { $client = new ClientMock([ 'baseUri' => '/', ]); @@ -301,6 +287,5 @@ XML; $this->assertEquals('/', $request->getUrl()); $this->assertEquals([ ], $request->getHeaders()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php index 174a561b5..5fc271587 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Exception/LockedTest.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Exception; use DOMDocument; use Sabre\DAV; -class LockedTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class LockedTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $dom = new DOMDocument('1.0'); $dom->formatOutput = true; $root = $dom->createElement('d:root'); @@ -33,11 +35,10 @@ class LockedTest extends \PHPUnit_Framework_TestCase { '; $this->assertEquals($expected, $output); - } - function testSerializeAmpersand() { - + public function testSerializeAmpersand() + { $dom = new DOMDocument('1.0'); $dom->formatOutput = true; $root = $dom->createElement('d:root'); @@ -62,6 +63,5 @@ class LockedTest extends \PHPUnit_Framework_TestCase { '; $this->assertEquals($expected, $output); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php index 7142937b4..42775a313 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Exception/PaymentRequiredTest.php @@ -1,14 +1,14 @@ <?php -namespace Sabre\DAV\Exception; - -class PaymentRequiredTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testGetHTTPCode() { +namespace Sabre\DAV\Exception; +class PaymentRequiredTest extends \PHPUnit\Framework\TestCase +{ + public function testGetHTTPCode() + { $ex = new PaymentRequired(); $this->assertEquals(402, $ex->getHTTPCode()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php index 0eb4f3dd8..7237aea0d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php @@ -1,30 +1,27 @@ <?php -namespace Sabre\DAV; - -class ExceptionTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testStatus() { +namespace Sabre\DAV; +class ExceptionTest extends \PHPUnit\Framework\TestCase +{ + public function testStatus() + { $e = new Exception(); $this->assertEquals(500, $e->getHTTPCode()); - } - function testExceptionStatuses() { - + public function testExceptionStatuses() + { $c = [ - 'Sabre\\DAV\\Exception\\NotAuthenticated' => 401, + 'Sabre\\DAV\\Exception\\NotAuthenticated' => 401, 'Sabre\\DAV\\Exception\\InsufficientStorage' => 507, ]; foreach ($c as $class => $status) { - $obj = new $class(); $this->assertEquals($status, $obj->getHTTPCode()); - } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php index f5d65a44f..4bc79b597 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php @@ -1,110 +1,101 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; require_once 'Sabre/TestUtil.php'; -class FileTest extends \PHPUnit_Framework_TestCase { - - function setUp() { - - file_put_contents(SABRE_TEMPDIR . '/file.txt', 'Contents'); - +class FileTest extends \PHPUnit\Framework\TestCase +{ + public function setUp() + { + file_put_contents(SABRE_TEMPDIR.'/file.txt', 'Contents'); } - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } - function testPut() { - - $filename = SABRE_TEMPDIR . '/file.txt'; + public function testPut() + { + $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('New contents', file_get_contents(SABRE_TEMPDIR.'/file.txt')); $this->assertEquals( - '"' . + '"'. sha1( - fileinode($filename) . - filesize($filename) . + fileinode($filename). + filesize($filename). filemtime($filename) - ) . '"', + ).'"', $result ); - } - function testRange() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testRange() + { + $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() { - + public function testRangeStream() + { $stream = fopen('php://memory', 'r+'); - fwrite($stream, "222"); + fwrite($stream, '222'); rewind($stream); - $file = new File(SABRE_TEMPDIR . '/file.txt'); + $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'); + public function testGet() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $this->assertEquals('Contents', stream_get_contents($file->get())); - } - function testDelete() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testDelete() + { + $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() { - - $filename = SABRE_TEMPDIR . '/file.txt'; + public function testGetETag() + { + $filename = SABRE_TEMPDIR.'/file.txt'; $file = new File($filename); $this->assertEquals( - '"' . + '"'. sha1( - fileinode($filename) . - filesize($filename) . + fileinode($filename). + filesize($filename). filemtime($filename) - ) . '"', + ).'"', $file->getETag() ); } - function testGetContentType() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testGetContentType() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $this->assertNull($file->getContentType()); - } - function testGetSize() { - - $file = new File(SABRE_TEMPDIR . '/file.txt'); + public function testGetSize() + { + $file = new File(SABRE_TEMPDIR.'/file.txt'); $this->assertEquals(8, $file->getSize()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php index 20fca490a..daa04c354 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\FSExt; use Sabre\DAV; @@ -7,81 +9,76 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class ServerTest extends DAV\AbstractServer{ - - protected function getRootNode() { - +class ServerTest extends DAV\AbstractServer +{ + protected function getRootNode() + { return new Directory($this->tempDir); - } - function testGet() { - + public function testGet() + { $request = new HTTP\Request('GET', '/test.txt'); - $filename = $this->tempDir . '/test.txt'; + $filename = $this->tempDir.'/test.txt'; $this->server->httpRequest = $request; $this->server->exec(); $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)) . '"'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($filename)))], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders() ); - $this->assertEquals('Test contents', stream_get_contents($this->response->body)); - } - function testHEAD() { - + public function testHEAD() + { $request = new HTTP\Request('HEAD', '/test.txt'); - $filename = $this->tempDir . '/test.txt'; + $filename = $this->tempDir.'/test.txt'; $this->server->httpRequest = ($request); $this->server->exec(); $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)) . '"'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($this->tempDir.'/test.txt')))], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders() ); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testPut() { - + public function testPut() + { $request = new HTTP\Request('PUT', '/testput.txt'); - $filename = $this->tempDir . '/testput.txt'; + $filename = $this->tempDir.'/testput.txt'; $request->setBody('Testing new file'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); $this->assertEquals('Testing new file', file_get_contents($filename)); - } - function testPutAlreadyExists() { - + public function testPutAlreadyExists() + { $request = new HTTP\Request('PUT', '/test.txt', ['If-None-Match' => '*']); $request->setBody('Testing new file'); $this->server->httpRequest = ($request); @@ -89,33 +86,31 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(412, $this->response->status); - $this->assertNotEquals('Testing new file', file_get_contents($this->tempDir . '/test.txt')); - + $this->assertNotEquals('Testing new file', file_get_contents($this->tempDir.'/test.txt')); } - function testMkcol() { - + public function testMkcol() + { $request = new HTTP\Request('MKCOL', '/testcol'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertTrue(is_dir($this->tempDir . '/testcol')); - + $this->assertTrue(is_dir($this->tempDir.'/testcol')); } - function testPutUpdate() { - + public function testPutUpdate() + { $request = new HTTP\Request('PUT', '/test.txt'); $request->setBody('Testing updated file'); $this->server->httpRequest = ($request); @@ -125,31 +120,29 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt')); - + $this->assertEquals('Testing updated file', file_get_contents($this->tempDir.'/test.txt')); } - function testDelete() { - + public function testDelete() + { $request = new HTTP\Request('DELETE', '/test.txt'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertFalse(file_exists($this->tempDir . '/test.txt')); - + $this->assertFalse(file_exists($this->tempDir.'/test.txt')); } - function testDeleteDirectory() { - - mkdir($this->tempDir . '/testcol'); - file_put_contents($this->tempDir . '/testcol/test.txt', 'Hi! I\'m a file with a short lifespan'); + public function testDeleteDirectory() + { + 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('DELETE', '/testcol'); $this->server->httpRequest = ($request); @@ -157,37 +150,35 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(204, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertFalse(file_exists($this->tempDir . '/testcol')); - + $this->assertFalse(file_exists($this->tempDir.'/testcol')); } - function testOptions() { - + public function testOptions() + { $request = new HTTP\Request('OPTIONS', '/'); $this->server->httpRequest = ($request); $this->server->exec(); $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'], + '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(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testMove() { - - mkdir($this->tempDir . '/testcol'); + public function testMove() + { + mkdir($this->tempDir.'/testcol'); $request = new HTTP\Request('MOVE', '/test.txt', ['Destination' => '/testcol/test2.txt']); $this->server->httpRequest = ($request); @@ -197,15 +188,13 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals('', $this->response->body); $this->assertEquals([ - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [DAV\Version::VERSION], ], $this->response->getHeaders()); $this->assertTrue( - is_file($this->tempDir . '/testcol/test2.txt') + is_file($this->tempDir.'/testcol/test2.txt') ); - - } /** @@ -215,14 +204,14 @@ class ServerTest extends DAV\AbstractServer{ * 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'); + public 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'), + new DAV\FS\Directory($this->tempDir.'/tree1'), + new DAV\FSExt\Directory($this->tempDir.'/tree2'), ])); $this->server->tree = $tree; @@ -234,13 +223,32 @@ class ServerTest extends DAV\AbstractServer{ $this->assertEquals('', $this->response->body); $this->assertEquals([ - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [DAV\Version::VERSION], ], $this->response->getHeaders()); $this->assertTrue( - is_dir($this->tempDir . '/tree2/tree1') + is_dir($this->tempDir.'/tree2/tree1') ); + } + + public function testCopy() + { + mkdir($this->tempDir.'/testcol'); + + $request = new HTTP\Request('COPY', '/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.'/test.txt')); + $this->assertTrue(is_file($this->tempDir.'/testcol/test2.txt')); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php index cd8bee968..d0ff77eb4 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php @@ -1,88 +1,85 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class HTTPPreferParsingTest extends \Sabre\DAVServerTest { - - function testParseSimple() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'return-asynch', +class HTTPPreferParsingTest extends \Sabre\DAVServerTest +{ + public function assertParseResult($input, $expected) + { + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'Prefer' => $input, ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals([ - 'respond-async' => true, - 'return' => null, - 'handling' => null, - 'wait' => null, - ], $server->getHTTPPrefer()); - + $this->assertEquals( + $expected, + $server->getHTTPPrefer() + ); } - function testParseValue() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'wait=10', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => '10', - ], $server->getHTTPPrefer()); - + public function testParseSimple() + { + $this->assertParseResult( + 'return-asynch', + [ + 'respond-async' => true, + 'return' => null, + 'handling' => null, + 'wait' => null, + ] + ); } - function testParseMultiple() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'return-minimal, strict,lenient', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => 'minimal', - 'handling' => 'lenient', - 'wait' => null, - ], $server->getHTTPPrefer()); - + public function testParseValue() + { + $this->assertParseResult( + 'wait=10', + [ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => '10', + ] + ); } - function testParseWeirdValue() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'BOOOH', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => null, - 'boooh' => true, - ], $server->getHTTPPrefer()); - + public function testParseMultiple() + { + $this->assertParseResult( + 'return-minimal, strict,lenient', + [ + 'respond-async' => false, + 'return' => 'minimal', + 'handling' => 'lenient', + 'wait' => null, + ] + ); } - function testBrief() { + public function testParseWeirdValue() + { + $this->assertParseResult( + 'BOOOH', + [ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => null, + 'boooh' => true, + ] + ); + } - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_BRIEF' => 't', + public function testBrief() + { + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'Brief' => 't', ]); $server = new Server(); @@ -90,24 +87,19 @@ class HTTPPreferParsingTest extends \Sabre\DAVServerTest { $this->assertEquals([ 'respond-async' => false, - 'return' => 'minimal', - 'handling' => null, - 'wait' => null, + 'return' => 'minimal', + 'handling' => null, + 'wait' => null, ], $server->getHTTPPrefer()); - } /** - * propfindMinimal - * - * @return void + * propfindMinimal. */ - function testpropfindMinimal() { - - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PROPFIND', - 'REQUEST_URI' => '/', - 'HTTP_PREFER' => 'return-minimal', + public function testpropfindMinimal() + { + $request = new HTTP\Request('PROPFIND', '/', [ + 'Prefer' => 'return-minimal', ]); $request->setBody(<<<BLA <?xml version="1.0"?> @@ -126,13 +118,12 @@ BLA $this->assertEquals(207, $response->getStatus(), $body); - $this->assertTrue(strpos($body, 'resourcetype') !== false, $body); - $this->assertTrue(strpos($body, 'something') === false, $body); - + $this->assertTrue(false !== strpos($body, 'resourcetype'), $body); + $this->assertTrue(false === strpos($body, 'something'), $body); } - function testproppatchMinimal() { - + public function testproppatchMinimal() + { $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<<<BLA <?xml version="1.0"?> @@ -146,23 +137,20 @@ BLA BLA ); - $this->server->on('propPatch', function($path, PropPatch $propPatch) { - - $propPatch->handle('{DAV:}something', function($props) { + $this->server->on('propPatch', function ($path, PropPatch $propPatch) { + $propPatch->handle('{DAV:}something', function ($props) { return true; }); - }); $response = $this->request($request); - $this->assertEquals(0, strlen($response->body), 'Expected empty body: ' . $response->body); + $this->assertEquals('', $response->getBodyAsString(), 'Expected empty body: '.$response->body); $this->assertEquals(204, $response->status); - } - function testproppatchMinimalError() { - + public function testproppatchMinimalError() + { $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<<<BLA <?xml version="1.0"?> @@ -181,8 +169,7 @@ BLA $body = $response->getBodyAsString(); $this->assertEquals(207, $response->status); - $this->assertTrue(strpos($body, 'something') !== false); - $this->assertTrue(strpos($body, '403 Forbidden') !== false, $body); - + $this->assertTrue(false !== strpos($body, 'something')); + $this->assertTrue(false !== strpos($body, '403 Forbidden'), $body); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php index bd1b33150..f70febabd 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\DAVServerTest; @@ -12,30 +14,27 @@ use Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HttpDeleteTest extends DAVServerTest { - +class HttpDeleteTest extends DAVServerTest +{ /** * Sets up the DAV tree. - * - * @return void */ - function setUpTree() { - + public function setUpTree() + { $this->tree = new Mock\Collection('root', [ 'file1' => 'foo', - 'dir' => [ - 'subfile' => 'bar', + 'dir' => [ + 'subfile' => 'bar', 'subfile2' => 'baz', ], ]); - } /** - * A successful DELETE + * A successful DELETE. */ - function testDelete() { - + public function testDelete() + { $request = new HTTP\Request('DELETE', '/file1'); $response = $this->request($request); @@ -43,24 +42,23 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 204, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $response->getHeaders() ); - } /** - * Deleting a Directory + * Deleting a Directory. */ - function testDeleteDirectory() { - + public function testDeleteDirectory() + { $request = new HTTP\Request('DELETE', '/dir'); $response = $this->request($request); @@ -68,42 +66,40 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 204, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $response->getHeaders() ); - } /** - * DELETE on a node that does not exist + * DELETE on a node that does not exist. */ - function testDeleteNotFound() { - + public function testDeleteNotFound() + { $request = new HTTP\Request('DELETE', '/file2'); $response = $this->request($request); $this->assertEquals( 404, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); - } /** - * DELETE with preconditions + * DELETE with preconditions. */ - function testDeletePreconditions() { - + public function testDeletePreconditions() + { $request = new HTTP\Request('DELETE', '/file1', [ - 'If-Match' => '"' . md5('foo') . '"', + 'If-Match' => '"'.md5('foo').'"', ]); $response = $this->request($request); @@ -111,18 +107,17 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 204, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); - } /** - * DELETE with incorrect preconditions + * DELETE with incorrect preconditions. */ - function testDeletePreconditionsFailed() { - + public function testDeletePreconditionsFailed() + { $request = new HTTP\Request('DELETE', '/file1', [ - 'If-Match' => '"' . md5('bar') . '"', + 'If-Match' => '"'.md5('bar').'"', ]); $response = $this->request($request); @@ -130,8 +125,7 @@ class HttpDeleteTest extends DAVServerTest { $this->assertEquals( 412, $response->getStatus(), - "Incorrect status code. Response body: " . $response->getBodyAsString() + 'Incorrect status code. Response body: '.$response->getBodyAsString() ); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php index 86480b1c2..d3932a4c6 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\DAVServerTest; @@ -12,31 +14,28 @@ use Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class HttpPutTest extends DAVServerTest { - +class HttpPutTest extends DAVServerTest +{ /** * Sets up the DAV tree. - * - * @return void */ - function setUpTree() { - + public function setUpTree() + { $this->tree = new Mock\Collection('root', [ 'file1' => 'foo', ]); - } /** * A successful PUT of a new file. */ - function testPut() { - + public function testPut() + { $request = new HTTP\Request('PUT', '/file2', [], 'hello'); $response = $this->request($request); - $this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Full response body:' . $response->getBodyAsString()); + $this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Full response body:'.$response->getBodyAsString()); $this->assertEquals( 'hello', @@ -46,12 +45,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -59,8 +57,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutExisting() { - + public function testPutExisting() + { $request = new HTTP\Request('PUT', '/file1', [], 'bar'); $response = $this->request($request); @@ -75,21 +73,20 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('bar') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('bar').'"'], ], $response->getHeaders() ); - } /** - * PUT on existing file with If-Match: * + * PUT on existing file with If-Match: *. * * @depends testPutExisting */ - function testPutExistingIfMatchStar() { - + public function testPutExistingIfMatchStar() + { $request = new HTTP\Request( 'PUT', '/file1', @@ -109,25 +106,24 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** - * PUT on existing file with If-Match: with a correct etag + * PUT on existing file with If-Match: with a correct etag. * * @depends testPutExisting */ - function testPutExistingIfMatchCorrect() { - + public function testPutExistingIfMatchCorrect() + { $request = new HTTP\Request( 'PUT', '/file1', - ['If-Match' => '"' . md5('foo') . '"'], + ['If-Match' => '"'.md5('foo').'"'], 'hello' ); @@ -143,12 +139,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -156,8 +151,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutContentRange() { - + public function testPutContentRange() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -167,7 +162,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(400, $response->getStatus()); - } /** @@ -175,8 +169,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutIfNoneMatchStar() { - + public function testPutIfNoneMatchStar() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -196,12 +190,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'] + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -209,8 +202,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutIfMatchStar() { - + public function testPutIfMatchStar() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -221,7 +214,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(412, $response->getStatus()); - } /** @@ -229,8 +221,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutExistingIfNoneMatchStar() { - + public function testPutExistingIfNoneMatchStar() + { $request = new HTTP\Request( 'PUT', '/file1', @@ -242,7 +234,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(412, $response->getStatus()); - } /** @@ -250,8 +241,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutNoParent() { - + public function testPutNoParent() + { $request = new HTTP\Request( 'PUT', '/file1/file2', @@ -261,7 +252,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(409, $response->getStatus()); - } /** @@ -271,8 +261,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testFinderPutSuccess() { - + public function testFinderPutSuccess() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -291,12 +281,11 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals( [ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5('hello') . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5('hello').'"'], ], $response->getHeaders() ); - } /** @@ -304,8 +293,8 @@ class HttpPutTest extends DAVServerTest { * * @depends testFinderPutSuccess */ - function testFinderPutFail() { - + public function testFinderPutFail() + { $request = new HTTP\Request( 'PUT', '/file2', @@ -316,7 +305,6 @@ class HttpPutTest extends DAVServerTest { $response = $this->request($request); $this->assertEquals(403, $response->getStatus()); - } /** @@ -324,17 +312,18 @@ class HttpPutTest extends DAVServerTest { * * @depends testPut */ - function testPutIntercept() { - - $this->server->on('beforeBind', function($uri) { + public function testPutIntercept() + { + $this->server->on('beforeBind', function ($uri) { $this->server->httpResponse->setStatus(418); + return false; }); $request = new HTTP\Request('PUT', '/file2', [], 'hello'); $response = $this->request($request); - $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: ' . $response->getBodyAsString()); + $this->assertEquals(418, $response->getStatus(), 'Incorrect status code received. Full response body: '.$response->getBodyAsString()); $this->assertFalse( $this->server->tree->nodeExists('file2') @@ -343,7 +332,5 @@ class HttpPutTest extends DAVServerTest { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], ], $response->getHeaders()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php index ba2cf3dc1..500ad6147 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php @@ -1,34 +1,32 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/TestUtil.php'; -class Issue33Test extends \PHPUnit_Framework_TestCase { - - function setUp() { - +class Issue33Test extends \PHPUnit\Framework\TestCase +{ + public function setUp() + { \Sabre\TestUtil::clearTempDir(); - } - function testCopyMoveInfo() { - + public function testCopyMoveInfo() + { $bar = new SimpleCollection('bar'); $root = new SimpleCollection('webdav', [$bar]); $server = new Server($root); $server->setBaseUri('/webdav/'); - $serverVars = [ - 'REQUEST_URI' => '/webdav/bar', - 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'HTTP_OVERWRITE' => 'F', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('GET', '/webdav/bar', [ + 'Destination' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', + 'Overwrite' => 'F', + ]); $server->httpRequest = $request; @@ -37,13 +35,12 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { $this->assertEquals('%C3%A0fo%C3%B3', urlencode($info['destination'])); $this->assertFalse($info['destinationExists']); $this->assertFalse($info['destinationNode']); - } - function testTreeMove() { - - mkdir(SABRE_TEMPDIR . '/issue33'); - $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33'); + public function testTreeMove() + { + mkdir(SABRE_TEMPDIR.'/issue33'); + $dir = new FS\Directory(SABRE_TEMPDIR.'/issue33'); $dir->createDirectory('bar'); @@ -52,40 +49,34 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3')); $this->assertEquals(urldecode('%C3%A0fo%C3%B3'), $node->getName()); - } - function testDirName() { - + public function testDirName() + { $dirname1 = 'bar'; $dirname2 = urlencode('%C3%A0fo%C3%B3'); $this->assertTrue(dirname($dirname1) == dirname($dirname2)); - } /** * @depends testTreeMove * @depends testCopyMoveInfo */ - function testEverything() { + public function testEverything() + { + $request = new HTTP\Request('MOVE', '/webdav/bar', [ + 'Destination' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', + 'Overwrite' => 'F', + ]); - // Request object - $serverVars = [ - 'REQUEST_METHOD' => 'MOVE', - 'REQUEST_URI' => '/webdav/bar', - 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', - 'HTTP_OVERWRITE' => 'F', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); $response = new HTTP\ResponseMock(); // Server setup - mkdir(SABRE_TEMPDIR . '/issue33'); - $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33'); + mkdir(SABRE_TEMPDIR.'/issue33'); + $dir = new FS\Directory(SABRE_TEMPDIR.'/issue33'); $dir->createDirectory('bar'); @@ -99,8 +90,6 @@ class Issue33Test extends \PHPUnit_Framework_TestCase { $server->sapi = new HTTP\SapiMock(); $server->exec(); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3'))); - + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/issue33/'.urldecode('%C3%A0fo%C3%B3'))); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php index bbde69097..d1cd1799c 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/AbstractTest.php @@ -1,29 +1,31 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; use Sabre\DAV; -abstract class AbstractTest extends \PHPUnit_Framework_TestCase { - +abstract class AbstractTest extends \PHPUnit\Framework\TestCase +{ /** * @abstract + * * @return AbstractBackend */ - abstract function getBackend(); - - function testSetup() { - - $backend = $this->getBackend(); - $this->assertInstanceOf('Sabre\\DAV\\Locks\\Backend\\AbstractBackend', $backend); + abstract public function getBackend(); + public function testSetup() + { + $backend = $this->getBackend(); + $this->assertInstanceOf('Sabre\\DAV\\Locks\\Backend\\AbstractBackend', $backend); } /** * @depends testSetup */ - function testGetLocks() { - + public function testGetLocks() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -40,14 +42,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($locks)); $this->assertEquals('Sinterklaas', $locks[0]->owner); $this->assertEquals('someuri', $locks[0]->uri); - } /** * @depends testGetLocks */ - function testGetLocksParent() { - + public function testGetLocksParent() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -64,15 +65,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($locks)); $this->assertEquals('Sinterklaas', $locks[0]->owner); $this->assertEquals('someuri', $locks[0]->uri); - } - /** * @depends testGetLocks */ - function testGetLocksParentDepth0() { - + public function testGetLocksParentDepth0() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -87,11 +86,10 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri/child', false); $this->assertEquals(0, count($locks)); - } - function testGetLocksChildren() { - + public function testGetLocksChildren() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -111,14 +109,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri', true); $this->assertEquals(1, count($locks)); - } /** * @depends testGetLocks */ - function testLockRefresh() { - + public function testLockRefresh() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -139,14 +136,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('Santa Clause', $locks[0]->owner); $this->assertEquals('someuri', $locks[0]->uri); - } /** * @depends testGetLocks */ - function testUnlock() { - + public function testUnlock() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -164,14 +160,13 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri', false); $this->assertEquals(0, count($locks)); - } /** * @depends testUnlock */ - function testUnlockUnknownToken() { - + public function testUnlockUnknownToken() + { $backend = $this->getBackend(); $lock = new DAV\Locks\LockInfo(); @@ -190,7 +185,5 @@ abstract class AbstractTest extends \PHPUnit_Framework_TestCase { $locks = $backend->getLocks('someuri', false); $this->assertEquals(1, count($locks)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php index 537996f3b..50f17a7dd 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/FileTest.php @@ -1,24 +1,23 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks\Backend; require_once 'Sabre/TestUtil.php'; -class FileTest extends AbstractTest { - - function getBackend() { - +class FileTest extends AbstractTest +{ + public function getBackend() + { \Sabre\TestUtil::clearTempDir(); - $backend = new File(SABRE_TEMPDIR . '/lockdb'); - return $backend; + $backend = new File(SABRE_TEMPDIR.'/lockdb'); + return $backend; } - - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php index 0ba02fc8b..86ffc0bb3 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAV\Locks\Backend; +declare(strict_types=1); -class PDOMySQLTest extends PDOTest { +namespace Sabre\DAV\Locks\Backend; +class PDOMySQLTest extends PDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php index a27eae93c..f5ed98f50 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php @@ -1,20 +1,20 @@ <?php -namespace Sabre\DAV\Locks\Backend; +declare(strict_types=1); -abstract class PDOTest extends AbstractTest { +namespace Sabre\DAV\Locks\Backend; +abstract class PDOTest extends AbstractTest +{ use \Sabre\DAV\DbTestHelperTrait; - function getBackend() { - + public function getBackend() + { $this->dropTables('locks'); $this->createSchema('locks'); $pdo = $this->getPDO(); return new PDO($pdo); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php index 1111db5b5..a2a31e87f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; use Sabre\DAV; @@ -8,22 +10,21 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; require_once 'Sabre/TestUtil.php'; -class MSWordTest extends \PHPUnit_Framework_TestCase { - - function tearDown() { - +class MSWordTest extends \PHPUnit\Framework\TestCase +{ + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } - function testLockEtc() { - - mkdir(SABRE_TEMPDIR . '/mstest'); - $tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest'); + public function testLockEtc() + { + mkdir(SABRE_TEMPDIR.'/mstest'); + $tree = new DAV\FS\Directory(SABRE_TEMPDIR.'/mstest'); $server = new DAV\Server($tree); $server->debugExceptions = true; - $locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb'); + $locksBackend = new Backend\File(SABRE_TEMPDIR.'/locksdb'); $locksPlugin = new Plugin($locksBackend); $server->addPlugin($locksPlugin); @@ -34,8 +35,8 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { $server->sapi = new HTTP\SapiMock(); $server->exec(); - $this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:' . $response1->getBodyAsString()); - $this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token')); + $this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:'.$response1->getBodyAsString()); + $this->assertTrue((bool) $server->httpResponse->getHeaders('Lock-Token')); $lockToken = $server->httpResponse->getHeader('Lock-Token'); //sleep(10); @@ -47,7 +48,7 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(201, $server->httpResponse->status); - $this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token')); + $this->assertTrue((bool) $server->httpResponse->getHeaders('Lock-Token')); //sleep(10); @@ -57,16 +58,15 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(204, $server->httpResponse->status); - } - function getLockRequest() { - + public function getLockRequest() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'LOCK', + 'REQUEST_METHOD' => 'LOCK', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'HTTP_TIMEOUT' => 'Second-3600', - 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + 'HTTP_TIMEOUT' => 'Second-3600', + 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', ]); $request->setBody('<D:lockinfo xmlns:D="DAV:"> @@ -82,15 +82,15 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { </D:lockinfo>'); return $request; - } - function getLockRequest2() { + public function getLockRequest2() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'LOCK', + 'REQUEST_METHOD' => 'LOCK', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'HTTP_TIMEOUT' => 'Second-3600', - 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + 'HTTP_TIMEOUT' => 'Second-3600', + 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', ]); $request->setBody('<D:lockinfo xmlns:D="DAV:"> @@ -106,19 +106,17 @@ class MSWordTest extends \PHPUnit_Framework_TestCase { </D:lockinfo>'); return $request; - } - function getPutRequest($lockToken) { - + public function getPutRequest($lockToken) + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', - 'HTTP_IF' => 'If: (' . $lockToken . ')', + 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx', + 'HTTP_IF' => 'If: ('.$lockToken.')', ]); $request->setBody('FAKE BODY'); - return $request; + return $request; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php index dbbf6757a..b3a0ac9af 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Locks; use Sabre\DAV; @@ -7,63 +9,58 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class PluginTest extends DAV\AbstractServer { - +class PluginTest extends DAV\AbstractServer +{ /** * @var Plugin */ protected $locksPlugin; - function setUp() { - + public function setUp() + { parent::setUp(); - $locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb'); + $locksBackend = new Backend\File(SABRE_TEMPDIR.'/locksdb'); $locksPlugin = new Plugin($locksBackend); $this->server->addPlugin($locksPlugin); $this->locksPlugin = $locksPlugin; - } - function testGetInfo() { - + public function testGetInfo() + { $this->assertArrayHasKey( 'name', $this->locksPlugin->getPluginInfo() ); - } - function testGetFeatures() { - + public function testGetFeatures() + { $this->assertEquals([2], $this->locksPlugin->getFeatures()); - } - function testGetHTTPMethods() { - + public function testGetHTTPMethods() + { $this->assertEquals(['LOCK', 'UNLOCK'], $this->locksPlugin->getHTTPMethods('')); - } - function testLockNoBody() { - + public function testLockNoBody() + { $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); $this->assertEquals(400, $this->response->status); - } - function testLock() { - + public function testLock() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -78,11 +75,11 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); - $this->assertEquals(200, $this->response->status, 'Got an incorrect status back. Response body: ' . $this->response->body); + $this->assertEquals(200, $this->response->status, 'Got an incorrect status back. Response body: '.$this->response->body); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); @@ -105,22 +102,21 @@ class PluginTest extends DAV\AbstractServer { foreach ($elements as $elem) { $data = $xml->xpath($elem); - $this->assertEquals(1, count($data), 'We expected 1 match for the xpath expression "' . $elem . '". ' . count($data) . ' were found. Full response body: ' . $this->response->body); + $this->assertEquals(1, count($data), 'We expected 1 match for the xpath expression "'.$elem.'". '.count($data).' were found. Full response body: '.$this->response->body); } $depth = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:depth'); - $this->assertEquals('infinity', (string)$depth[0]); + $this->assertEquals('infinity', (string) $depth[0]); $token = $xml->xpath('/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href'); - $this->assertEquals($this->response->getHeader('Lock-Token'), '<' . (string)$token[0] . '>', 'Token in response body didn\'t match token in response header.'); - + $this->assertEquals($this->response->getHeader('Lock-Token'), '<'.(string) $token[0].'>', 'Token in response body didn\'t match token in response header.'); } /** * @depends testLock */ - function testDoubleLock() { - + public function testDoubleLock() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -141,15 +137,14 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(423, $this->response->status, 'Full response: ' . $this->response->body); - + $this->assertEquals(423, $this->response->status, 'Full response: '.$this->response->body); } /** * @depends testLock */ - function testLockRefresh() { - + public function testLockRefresh() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -168,7 +163,7 @@ class PluginTest extends DAV\AbstractServer { $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; - $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '(' . $lockToken . ')']); + $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '('.$lockToken.')']); $request->setBody(''); $this->server->httpRequest = $request; @@ -176,15 +171,14 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(200, $this->response->status, 'We received an incorrect status code. Full response body: ' . $this->response->getBody()); - + $this->assertEquals(200, $this->response->status, 'We received an incorrect status code. Full response body: '.$this->response->getBody()); } /** * @depends testLock */ - function testLockRefreshBadToken() { - + public function testLockRefreshBadToken() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -203,7 +197,7 @@ class PluginTest extends DAV\AbstractServer { $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; - $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '(' . $lockToken . 'foobar) (<opaquelocktoken:anotherbadtoken>)']); + $request = new HTTP\Request('LOCK', '/test.txt', ['If' => '('.$lockToken.'foobar) (<opaquelocktoken:anotherbadtoken>)']); $request->setBody(''); $this->server->httpRequest = $request; @@ -211,15 +205,14 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertEquals(423, $this->response->getStatus(), 'We received an incorrect status code. Full response body: ' . $this->response->getBody()); - + $this->assertEquals(423, $this->response->getStatus(), 'We received an incorrect status code. Full response body: '.$this->response->getBody()); } /** * @depends testLock */ - function testLockNoFile() { - + public function testLockNoFile() + { $request = new HTTP\Request('LOCK', '/notfound.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -234,57 +227,54 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->status); - } /** * @depends testLock */ - function testUnlockNoToken() { - + public function testUnlockNoToken() + { $request = new HTTP\Request('UNLOCK', '/test.txt'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); $this->assertEquals(400, $this->response->status); - } /** * @depends testLock */ - function testUnlockBadToken() { - + public function testUnlockBadToken() + { $request = new HTTP\Request('UNLOCK', '/test.txt', ['Lock-Token' => '<opaquelocktoken:blablabla>']); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); - $this->assertEquals(409, $this->response->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); - + $this->assertEquals(409, $this->response->status, 'Got an incorrect status code. Full response body: '.$this->response->body); } /** * @depends testLock */ - function testLockPutNoToken() { - + public function testLockPutNoToken() + { $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -299,7 +289,7 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); @@ -309,17 +299,16 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(423, $this->response->status); - } /** * @depends testLock */ - function testUnlock() { - + public function testUnlock() + { $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; @@ -340,22 +329,20 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpResponse = new HTTP\ResponseMock(); $this->server->invokeMethod($request, $this->server->httpResponse); - $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->server->httpResponse->getHeaders() ); - - } /** * @depends testLock */ - function testUnlockWindowsBug() { - + public function testUnlockWindowsBug() + { $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; @@ -379,26 +366,21 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpResponse = new HTTP\ResponseMock(); $this->server->invokeMethod($request, $this->server->httpResponse); - $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: ' . $this->response->body); + $this->assertEquals(204, $this->server->httpResponse->status, 'Got an incorrect status code. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->server->httpResponse->getHeaders() ); - - } /** * @depends testLock */ - function testLockRetainOwner() { - - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'LOCK', - ]); + public function testLockRetainOwner() + { + $request = new HTTP\Request('LOCK', '/test.txt'); $this->server->httpRequest = $request; $request->setBody('<?xml version="1.0"?> @@ -414,21 +396,14 @@ class PluginTest extends DAV\AbstractServer { $locks = $this->locksPlugin->getLocks('test.txt'); $this->assertEquals(1, count($locks)); $this->assertEquals('Evert', $locks[0]->owner); - - } /** * @depends testLock */ - function testLockPutBadToken() { - - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockPutBadToken() + { + $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -442,40 +417,30 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(<opaquelocktoken:token1>)', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '(<opaquelocktoken:token1>)', + ]); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); // $this->assertEquals('412 Precondition failed',$this->response->status); $this->assertEquals(423, $this->response->status); - } /** * @depends testLock */ - function testLockDeleteParent() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockDeleteParent() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -489,34 +454,24 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir', - 'REQUEST_METHOD' => 'DELETE', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('DELETE', '/dir'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } + /** * @depends testLock */ - function testLockDeleteSucceed() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockDeleteSucceed() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -530,36 +485,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'DELETE', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('DELETE', '/dir/child.txt', [ + 'If' => '('.$this->response->getHeader('Lock-Token').')', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(204, $this->response->status); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockCopyLockSource() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockCopyLockSource() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -573,35 +518,27 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'COPY', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; + $request = new HTTP\Request('COPY', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); - $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(201, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } + /** * @depends testLock */ - function testLockCopyLockDestination() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child2.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockCopyLockDestination() + { + $request = new HTTP\Request('LOCK', '/dir/child2.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -615,36 +552,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'COPY', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('COPY', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockMoveLockSourceLocked() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockSourceLocked() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -658,36 +585,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockMoveLockSourceSucceed() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockSourceSucceed() + { + $request = new HTTP\Request('LOCK', '/dir/child.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -701,36 +618,26 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + 'If' => '('.$this->response->getHeader('Lock-Token').')', + ]); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status, 'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this->response->body); - + $this->assertEquals(201, $this->response->status, 'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: '.$this->response->body); } /** * @depends testLock */ - function testLockMoveLockDestination() { - - $serverVars = [ - 'REQUEST_URI' => '/dir/child2.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockDestination() + { + $request = new HTTP\Request('LOCK', '/dir/child2.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -744,36 +651,28 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(423, $this->response->status, 'Copy must succeed if only the source is locked, but not the destination'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } + /** * @depends testLock */ - function testLockMoveLockParent() { - - $serverVars = [ - 'REQUEST_URI' => '/dir', - 'REQUEST_METHOD' => 'LOCK', - 'HTTP_DEPTH' => 'infinite', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockMoveLockParent() + { + $request = new HTTP\Request('LOCK', '/dir', [ + 'Depth' => 'infinite', + ]); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -787,37 +686,27 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/dir/child.txt', - 'REQUEST_METHOD' => 'MOVE', - 'HTTP_DESTINATION' => '/dir/child2.txt', - 'HTTP_IF' => '</dir> (' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('MOVE', '/dir/child.txt', [ + 'Destination' => '/dir/child2.txt', + 'If' => '</dir> ('.$this->response->getHeader('Lock-Token').')', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(201, $this->response->status, 'We locked the parent of both the source and destination, but the move didn\'t succeed.'); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - } /** * @depends testLock */ - function testLockPutGoodToken() { - - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'LOCK', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testLockPutGoodToken() + { + $request = new HTTP\Request('LOCK', '/test.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> <D:lockscope><D:exclusive/></D:lockscope> @@ -831,33 +720,28 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(200, $this->response->status); - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(' . $this->response->getHeader('Lock-Token') . ')', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '('.$this->response->getHeader('Lock-Token').')', + ]); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(204, $this->response->status); - } /** * @depends testLock */ - function testLockPutUnrelatedToken() { - + public function testLockPutUnrelatedToken() + { $request = new HTTP\Request('LOCK', '/unrelated.txt'); $request->setBody('<?xml version="1.0"?> <D:lockinfo xmlns:D="DAV:"> @@ -872,132 +756,109 @@ class PluginTest extends DAV\AbstractServer { $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(201, $this->response->getStatus()); $request = new HTTP\Request( 'PUT', '/test.txt', - ['If' => '</unrelated.txt> (' . $this->response->getHeader('Lock-Token') . ')'] + ['If' => '</unrelated.txt> ('.$this->response->getHeader('Lock-Token').')'] ); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals(204, $this->response->status); - } - function testPutWithIncorrectETag() { - - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(["etag1"])', - ]; - - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testPutWithIncorrectETag() + { + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '(["etag1"])', + ]); $request->setBody('newbody'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(412, $this->response->status); - } /** * @depends testPutWithIncorrectETag */ - function testPutWithCorrectETag() { - + public function testPutWithCorrectETag() + { // We need an ETag-enabled file node. $tree = new DAV\Tree(new DAV\FSExt\Directory(SABRE_TEMPDIR)); $this->server->tree = $tree; - $filename = SABRE_TEMPDIR . '/test.txt'; + $filename = SABRE_TEMPDIR.'/test.txt'; $etag = sha1( - fileinode($filename) . - filesize($filename) . + fileinode($filename). + filesize($filename). filemtime($filename) ); - $serverVars = [ - 'REQUEST_URI' => '/test.txt', - 'REQUEST_METHOD' => 'PUT', - 'HTTP_IF' => '(["' . $etag . '"])', - ]; - $request = HTTP\Sapi::createFromServerArray($serverVars); + $request = new HTTP\Request('PUT', '/test.txt', [ + 'If' => '(["'.$etag.'"])', + ]); $request->setBody('newbody'); + $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(204, $this->response->status, 'Incorrect status received. Full response body:' . $this->response->body); - + $this->assertEquals(204, $this->response->status, 'Incorrect status received. Full response body:'.$this->response->body); } - function testDeleteWithETagOnCollection() { - - $serverVars = [ - 'REQUEST_URI' => '/dir', - 'REQUEST_METHOD' => 'DELETE', - 'HTTP_IF' => '(["etag1"])', - ]; - $request = HTTP\Sapi::createFromServerArray($serverVars); + public function testDeleteWithETagOnCollection() + { + $request = new HTTP\Request('DELETE', '/dir', [ + 'If' => '(["etag1"])', + ]); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals(412, $this->response->status); - } - function testGetTimeoutHeader() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'second-100', + public function testGetTimeoutHeader() + { + $request = new HTTP\Request('LOCK', '/foo/bar', [ + 'Timeout' => 'second-100', ]); $this->server->httpRequest = $request; $this->assertEquals(100, $this->locksPlugin->getTimeoutHeader()); - } - function testGetTimeoutHeaderTwoItems() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'second-5, infinite', + public function testGetTimeoutHeaderTwoItems() + { + $request = new HTTP\Request('LOCK', '/foo/bar', [ + 'Timeout' => 'second-5, infinite', ]); - $this->server->httpRequest = $request; $this->assertEquals(5, $this->locksPlugin->getTimeoutHeader()); - } - function testGetTimeoutHeaderInfinite() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'infinite, second-5', + public function testGetTimeoutHeaderInfinite() + { + $request = new HTTP\Request('LOCK', '/foo/bar', [ + 'Timeout' => 'infinite, second-5', ]); - $this->server->httpRequest = $request; $this->assertEquals(LockInfo::TIMEOUT_INFINITE, $this->locksPlugin->getTimeoutHeader()); - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testGetTimeoutHeaderInvalid() { - - $request = HTTP\Sapi::createFromServerArray([ - 'HTTP_TIMEOUT' => 'yourmom', - ]); + public function testGetTimeoutHeaderInvalid() + { + $request = new HTTP\Request('GET', '/', ['Timeout' => 'yourmom']); $this->server->httpRequest = $request; $this->locksPlugin->getTimeoutHeader(); - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php index fded5e474..e0bdecc09 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/Collection.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mock; use Sabre\DAV; @@ -19,22 +21,21 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAV\Collection { - +class Collection extends DAV\Collection +{ protected $name; protected $children; protected $parent; /** - * Creates the object + * Creates the object. * - * @param string $name - * @param array $children + * @param string $name + * @param array $children * @param Collection $parent - * @return void */ - function __construct($name, array $children = [], Collection $parent = null) { - + public function __construct($name, array $children = [], Collection $parent = null) + { $this->name = $name; foreach ($children as $key => $value) { if (is_string($value)) { @@ -48,7 +49,6 @@ class Collection extends DAV\Collection { } } $this->parent = $parent; - } /** @@ -58,14 +58,13 @@ class Collection extends DAV\Collection { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** - * Creates a new file in the directory + * Creates a new file in the directory. * * Data will either be supplied as a stream resource, or in certain cases * as a string. Keep in mind that you may have to support either. @@ -84,41 +83,39 @@ class Collection extends DAV\Collection { * return the same contents of what was submitted here, you are strongly * recommended to omit the ETag. * - * @param string $name Name of the file + * @param string $name Name of the file * @param resource|string $data Initial payload - * @return null|string + * + * @return string|null */ - function createFile($name, $data = null) { - + public function createFile($name, $data = '') + { if (is_resource($data)) { $data = stream_get_contents($data); } $this->children[] = new File($name, $data, $this); - return '"' . md5($data) . '"'; + return '"'.md5($data).'"'; } /** - * Creates a new subdirectory + * Creates a new subdirectory. * * @param string $name - * @return void */ - function createDirectory($name) { - + public function createDirectory($name) + { $this->children[] = new self($name); - } /** - * Returns an array with all the child nodes + * Returns an array with all the child nodes. * * @return \Sabre\DAV\INode[] */ - function getChildren() { - + public function getChildren() + { return $this->children; - } /** @@ -126,43 +123,35 @@ class Collection extends DAV\Collection { * * @param \Sabre\DAV\INode $node */ - function addNode(\Sabre\DAV\INode $node) { - + public function addNode(\Sabre\DAV\INode $node) + { $this->children[] = $node; - } /** * Removes a childnode from this node. * * @param string $name - * @return void */ - function deleteChild($name) { - + public function deleteChild($name) + { foreach ($this->children as $key => $value) { - if ($value->getName() == $name) { unset($this->children[$key]); + return; } - } - } /** * Deletes this collection and all its children,. - * - * @return void */ - function delete() { - + public function delete() + { foreach ($this->getChildren() as $child) { $this->deleteChild($child->getName()); } $this->parent->deleteChild($this->getName()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php index a624b6b6b..d48ddaa92 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php @@ -1,11 +1,13 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mock; use Sabre\DAV; /** - * Mock File + * Mock File. * * See the Collection in this directory for more details. * @@ -13,34 +15,32 @@ use Sabre\DAV; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class File extends DAV\File { - +class File extends DAV\File +{ protected $name; protected $contents; protected $parent; protected $lastModified; /** - * Creates the object + * Creates the object. * - * @param string $name - * @param resource $contents + * @param string $name + * @param resource $contents * @param Collection $parent - * @param int $lastModified - * @return void + * @param int $lastModified */ - function __construct($name, $contents, Collection $parent = null, $lastModified = -1) { - + public function __construct($name, $contents, Collection $parent = null, $lastModified = -1) + { $this->name = $name; $this->put($contents); $this->parent = $parent; - if ($lastModified === -1) { + if (-1 === $lastModified) { $lastModified = time(); } $this->lastModified = $lastModified; - } /** @@ -50,26 +50,23 @@ class File extends DAV\File { * * @return string */ - function getName() { - + public function getName() + { return $this->name; - } /** * Changes the name of the node. * * @param string $name - * @return void */ - function setName($name) { - + public function setName($name) + { $this->name = $name; - } /** - * Updates the data + * Updates the data. * * The data argument is a readable stream resource. * @@ -86,66 +83,59 @@ class File extends DAV\File { * return an ETag, and just return null. * * @param resource $data + * * @return string|null */ - function put($data) { - + public function put($data) + { if (is_resource($data)) { $data = stream_get_contents($data); } $this->contents = $data; - return '"' . md5($data) . '"'; + return '"'.md5($data).'"'; } /** - * Returns the data + * Returns the data. * * This method may either return a string or a readable stream resource * * @return mixed */ - function get() { - + public function get() + { return $this->contents; - } /** - * Returns the ETag for a file + * Returns the ETag for a file. * * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. * * Return null if the ETag can not effectively be determined - * - * @return void */ - function getETag() { - - return '"' . md5($this->contents) . '"'; - + public function getETag() + { + return '"'.md5($this->contents).'"'; } /** - * Returns the size of the node, in bytes + * Returns the size of the node, in bytes. * * @return int */ - function getSize() { - + public function getSize() + { return strlen($this->contents); - } /** - * Delete the node - * - * @return void + * Delete the node. */ - function delete() { - + public function delete() + { $this->parent->deleteChild($this->name); - } /** @@ -154,10 +144,8 @@ class File extends DAV\File { * * @return int */ - function getLastModified() { - + public function getLastModified() + { return $this->lastModified; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php index 3213fcb1b..c993e609d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\Mount; use Sabre\DAV; @@ -7,19 +9,18 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class PluginTest extends DAV\AbstractServer { - - function setUp() { - +class PluginTest extends DAV\AbstractServer +{ + public function setUp() + { parent::setUp(); $this->server->addPlugin(new Plugin()); - } - function testPassThrough() { - + public function testPassThrough() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET', ]; @@ -27,17 +28,16 @@ class PluginTest extends DAV\AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(501, $this->response->status, 'We expected GET to not be implemented for Directories. Response body: ' . $this->response->body); - + $this->assertEquals(501, $this->response->status, 'We expected GET to not be implemented for Directories. Response body: '.$this->response->body); } - function testMountResponse() { - + public function testMountResponse() + { $serverVars = [ - 'REQUEST_URI' => '/?mount', + 'REQUEST_URI' => '/?mount', 'REQUEST_METHOD' => 'GET', - 'QUERY_STRING' => 'mount', - 'HTTP_HOST' => 'example.org', + 'QUERY_STRING' => 'mount', + 'HTTP_HOST' => 'example.org', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -47,12 +47,10 @@ class PluginTest extends DAV\AbstractServer { $this->assertEquals(200, $this->response->status); $xml = simplexml_load_string($this->response->body); - $this->assertInstanceOf('SimpleXMLElement', $xml, 'Response was not a valid xml document. The list of errors:' . print_r(libxml_get_errors(), true) . '. xml body: ' . $this->response->body . '. What type we got: ' . gettype($xml) . ' class, if object: ' . get_class($xml)); + $this->assertInstanceOf('SimpleXMLElement', $xml, 'Response was not a valid xml document. The list of errors:'.print_r(libxml_get_errors(), true).'. xml body: '.$this->response->body.'. What type we got: '.gettype($xml).' class, if object: '.get_class($xml)); $xml->registerXPathNamespace('dm', 'http://purl.org/NET/webdav/mount'); $url = $xml->xpath('//dm:url'); - $this->assertEquals('http://example.org/', (string)$url[0]); - + $this->assertEquals('http://example.org/', (string) $url[0]); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php index 15289ce52..6b6652967 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php @@ -1,100 +1,92 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; require_once 'Sabre/TestUtil.php'; -class ObjectTreeTest extends \PHPUnit_Framework_TestCase { - +class ObjectTreeTest extends \PHPUnit\Framework\TestCase +{ protected $tree; - function setup() { - + public function setup() + { \Sabre\TestUtil::clearTempDir(); - mkdir(SABRE_TEMPDIR . '/root'); - mkdir(SABRE_TEMPDIR . '/root/subdir'); - file_put_contents(SABRE_TEMPDIR . '/root/file.txt', 'contents'); - file_put_contents(SABRE_TEMPDIR . '/root/subdir/subfile.txt', 'subcontents'); - $rootNode = new FSExt\Directory(SABRE_TEMPDIR . '/root'); + mkdir(SABRE_TEMPDIR.'/root'); + mkdir(SABRE_TEMPDIR.'/root/subdir'); + file_put_contents(SABRE_TEMPDIR.'/root/file.txt', 'contents'); + file_put_contents(SABRE_TEMPDIR.'/root/subdir/subfile.txt', 'subcontents'); + $rootNode = new FSExt\Directory(SABRE_TEMPDIR.'/root'); $this->tree = new Tree($rootNode); - } - function teardown() { - + public function teardown() + { \Sabre\TestUtil::clearTempDir(); - } - function testGetRootNode() { - + public function testGetRootNode() + { $root = $this->tree->getNodeForPath(''); $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); - } - function testGetSubDir() { - + public function testGetSubDir() + { $root = $this->tree->getNodeForPath('subdir'); $this->assertInstanceOf('Sabre\\DAV\\FSExt\\Directory', $root); - } - function testCopyFile() { - - $this->tree->copy('file.txt', 'file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt')); - + public function testCopyFile() + { + $this->tree->copy('file.txt', 'file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); } /** * @depends testCopyFile */ - function testCopyDirectory() { - - $this->tree->copy('subdir', 'subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - + public function testCopyDirectory() + { + $this->tree->copy('subdir', 'subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); } /** * @depends testCopyFile */ - function testMoveFile() { - - $this->tree->move('file.txt', 'file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/file2.txt')); - + public function testMoveFile() + { + $this->tree->move('file.txt', 'file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/file2.txt')); } /** * @depends testMoveFile */ - function testMoveFileNewParent() { - - $this->tree->move('file.txt', 'subdir/file2.txt'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir/file2.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/file.txt')); - $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR . '/root/subdir/file2.txt')); - + public function testMoveFileNewParent() + { + $this->tree->move('file.txt', 'subdir/file2.txt'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir/file2.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/file.txt')); + $this->assertEquals('contents', file_get_contents(SABRE_TEMPDIR.'/root/subdir/file2.txt')); } /** * @depends testCopyDirectory */ - function testMoveDirectory() { - - $this->tree->move('subdir', 'subdir2'); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2')); - $this->assertTrue(file_exists(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/root/subdir')); - $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR . '/root/subdir2/subfile.txt')); - + public function testMoveDirectory() + { + $this->tree->move('subdir', 'subdir2'); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2')); + $this->assertTrue(file_exists(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/root/subdir')); + $this->assertEquals('subcontents', file_get_contents(SABRE_TEMPDIR.'/root/subdir2/subfile.txt')); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php index eff1e7d67..72fdb5ec8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/FileMock.php @@ -1,20 +1,21 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV; -class FileMock implements IPatchSupport { - +class FileMock implements IPatchSupport +{ protected $data = ''; - function put($str) { - + public function put($str) + { if (is_resource($str)) { $str = stream_get_contents($str); } $this->data = $str; - } /** @@ -40,83 +41,71 @@ class FileMock implements IPatchSupport { * time. * * @param resource|string $data - * @param int $rangeType - * @param int $offset + * @param int $rangeType + * @param int $offset + * * @return string|null */ - function patch($data, $rangeType, $offset = null) { - + public function patch($data, $rangeType, $offset = null) + { if (is_resource($data)) { $data = stream_get_contents($data); } switch ($rangeType) { - - case 1 : + case 1: $this->data .= $data; break; - case 3 : + case 3: // Turn the offset into an offset-offset. $offset = strlen($this->data) - $offset; - // No break is intentional - case 2 : + // no break is intentional + case 2: $this->data = - substr($this->data, 0, $offset) . - $data . + substr($this->data, 0, $offset). + $data. substr($this->data, $offset + strlen($data)); break; - } - } - function get() { - + public function get() + { return $this->data; - } - function getContentType() { - + public function getContentType() + { return 'text/plain'; - } - function getSize() { - + public function getSize() + { return strlen($this->data); - } - function getETag() { - - return '"' . $this->data . '"'; - + public function getETag() + { + return '"'.$this->data.'"'; } - function delete() { - + public function delete() + { throw new DAV\Exception\MethodNotAllowed(); - } - function setName($name) { - + public function setName($name) + { throw new DAV\Exception\MethodNotAllowed(); - } - function getName() { - + public function getName() + { return 'partial'; - } - function getLastModified() { - + public function getLastModified() + { return null; - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php index 5bd696416..63d692ec9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php @@ -1,19 +1,20 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; -use Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/DAV/PartialUpdate/FileMock.php'; -class PluginTest extends \Sabre\DAVServerTest { - +class PluginTest extends \Sabre\DAVServerTest +{ protected $node; protected $plugin; - function setUp() { - + public function setUp() + { $this->node = new FileMock(); $this->tree[] = $this->node; @@ -21,38 +22,33 @@ class PluginTest extends \Sabre\DAVServerTest { $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); - - - } - function testInit() { - + public function testInit() + { $this->assertEquals('partialupdate', $this->plugin->getPluginName()); $this->assertEquals(['sabredav-partialupdate'], $this->plugin->getFeatures()); $this->assertEquals([ - 'PATCH' + 'PATCH', ], $this->plugin->getHTTPMethods('partial')); $this->assertEquals([ ], $this->plugin->getHTTPMethods('')); - } - function testPatchNoRange() { - + public function testPatchNoRange() + { $this->node->put('aaaaaaaa'); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/partial', + 'REQUEST_URI' => '/partial', ]); $response = $this->request($request); - $this->assertEquals(400, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(400, $response->status, 'Full response body:'.$response->body); } - function testPatchNotSupported() { - + public function testPatchNotSupported() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/', ['X-Update-Range' => '3-4']); $request->setBody( @@ -60,12 +56,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(405, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(405, $response->status, 'Full response body:'.$response->body); } - function testPatchNoContentType() { - + public function testPatchNoContentType() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4']); $request->setBody( @@ -73,12 +68,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(415, $response->status, 'Full response body:'.$response->body); } - function testPatchBadRange() { - + public function testPatchBadRange() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); $request->setBody( @@ -86,12 +80,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(416, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(416, $response->status, 'Full response body:'.$response->body); } - function testPatchNoLength() { - + public function testPatchNoLength() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate']); $request->setBody( @@ -99,12 +92,11 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(411, $response->status, 'Full response body:' . $response->body); - + $this->assertEquals(411, $response->status, 'Full response body:'.$response->body); } - function testPatchSuccess() { - + public function testPatchSuccess() + { $this->node->put('aaaaaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => 3]); $request->setBody( @@ -112,13 +104,12 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals(204, $response->status, 'Full response body:' . $response->body); + $this->assertEquals(204, $response->status, 'Full response body:'.$response->body); $this->assertEquals('aaabbbaa', $this->node->get()); - } - function testPatchNoEndRange() { - + public function testPatchNoEndRange() + { $this->node->put('aaaaa'); $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); $request->setBody( @@ -127,9 +118,7 @@ class PluginTest extends \Sabre\DAVServerTest { $response = $this->request($request); - $this->assertEquals(204, $response->getStatus(), 'Full response body:' . $response->getBodyAsString()); + $this->assertEquals(204, $response->getStatus(), 'Full response body:'.$response->getBodyAsString()); $this->assertEquals('aaabbb', $this->node->get()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php index 2c6274173..56b2d576f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PartialUpdate; use Sabre\DAV\FSExt\File; @@ -12,14 +14,14 @@ use Sabre\HTTP; * * See: http://sabre.io/dav/http-patch/ */ -class SpecificationTest extends \PHPUnit_Framework_TestCase { - +class SpecificationTest extends \PHPUnit\Framework\TestCase +{ protected $server; - function setUp() { - + public function setUp() + { $tree = [ - new File(SABRE_TEMPDIR . '/foobar.txt') + new File(SABRE_TEMPDIR.'/foobar.txt'), ]; $server = new Server($tree); $server->debugExceptions = true; @@ -28,32 +30,30 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { $tree[0]->put('1234567890'); $this->server = $server; - } - function tearDown() { - + public function tearDown() + { \Sabre\TestUtil::clearTempDir(); - } /** * @param string $headerValue * @param string $httpStatus * @param string $endResult - * @param int $contentLength + * @param int $contentLength * * @dataProvider data */ - function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) { - + public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) + { $headers = [ - 'Content-Type' => 'application/x-sabredav-partialupdate', + 'Content-Type' => 'application/x-sabredav-partialupdate', 'X-Update-Range' => $headerValue, ]; if ($contentLength) { - $headers['Content-Length'] = (string)$contentLength; + $headers['Content-Length'] = (string) $contentLength; } $request = new HTTP\Request('PATCH', '/foobar.txt', $headers, '----'); @@ -64,15 +64,14 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { $this->server->sapi = new HTTP\SapiMock(); $this->server->exec(); - $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: ' . $this->server->httpResponse->body); + $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: '.$this->server->httpResponse->body); if (!is_null($endResult)) { - $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR . '/foobar.txt')); + $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR.'/foobar.txt')); } - } - function data() { - + public function data() + { return [ // Problems ['foo', 400, null], @@ -86,9 +85,6 @@ class SpecificationTest extends \PHPUnit_Framework_TestCase { ['bytes=-2', 204, '12345678----'], ['bytes=2-', 204, '12----7890'], ['append', 204, '1234567890----'], - ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php index 42759647a..7d55ea02e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php @@ -1,36 +1,36 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; -class ServerEventsTest extends AbstractServer { - +class ServerEventsTest extends AbstractServer +{ private $tempPath; private $exception; - function testAfterBind() { - + public function testAfterBind() + { $this->server->on('afterBind', [$this, 'afterBindHandler']); $newPath = 'afterBind'; $this->tempPath = ''; $this->server->createFile($newPath, 'body'); $this->assertEquals($newPath, $this->tempPath); - } - function afterBindHandler($path) { - - $this->tempPath = $path; - + public function afterBindHandler($path) + { + $this->tempPath = $path; } - function testAfterResponse() { - + public function testAfterResponse() + { $mock = $this->getMockBuilder('stdClass') ->setMethods(['afterResponseCallback']) ->getMock(); @@ -40,74 +40,65 @@ class ServerEventsTest extends AbstractServer { $this->server->httpRequest = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/test.txt', + 'REQUEST_URI' => '/test.txt', ]); $this->server->exec(); - } - function testBeforeBindCancel() { - + public function testBeforeBindCancel() + { $this->server->on('beforeBind', [$this, 'beforeBindCancelHandler']); $this->assertFalse($this->server->createFile('bla', 'body')); // Also testing put() $req = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/barbar', + 'REQUEST_URI' => '/barbar', ]); $this->server->httpRequest = $req; $this->server->exec(); $this->assertEquals(500, $this->server->httpResponse->getStatus()); - } - function beforeBindCancelHandler($path) { - + public function beforeBindCancelHandler($path) + { return false; - } - function testException() { - + public function testException() + { $this->server->on('exception', [$this, 'exceptionHandler']); $req = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/not/exisitng', + 'REQUEST_URI' => '/not/exisitng', ]); $this->server->httpRequest = $req; $this->server->exec(); $this->assertInstanceOf('Sabre\\DAV\\Exception\\NotFound', $this->exception); - } - function exceptionHandler(Exception $exception) { - + public function exceptionHandler(Exception $exception) + { $this->exception = $exception; - } - function testMethod() { - + public function testMethod() + { $k = 1; - $this->server->on('method', function($request, $response) use (&$k) { - - $k += 1; + $this->server->on('method:*', function ($request, $response) use (&$k) { + ++$k; return false; - }); - $this->server->on('method', function($request, $response) use (&$k) { - + $this->server->on('method:*', function ($request, $response) use (&$k) { $k += 2; return false; - }); try { @@ -116,11 +107,10 @@ class ServerEventsTest extends AbstractServer { new HTTP\Response(), false ); - } catch (Exception $e) {} + } catch (Exception $e) { + } // Fun fact, PHP 7.1 changes the order when sorting-by-callback. $this->assertTrue($k >= 2 && $k <= 3); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php index 557eddbbc..8e5bc6a64 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php @@ -1,91 +1,90 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class ServerMKCOLTest extends AbstractServer { - - function testMkcol() { - +class ServerMKCOLTest extends AbstractServer +{ + public function testMkcol() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', + 'REQUEST_URI' => '/testcol', 'REQUEST_METHOD' => 'MKCOL', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody(""); + $request->setBody(''); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); - $this->assertTrue(is_dir($this->tempDir . '/testcol')); - + $this->assertTrue(is_dir($this->tempDir.'/testcol')); } /** * @depends testMkcol */ - function testMKCOLUnknownBody() { - + public function testMKCOLUnknownBody() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', + 'REQUEST_URI' => '/testcol', 'REQUEST_METHOD' => 'MKCOL', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody("Hello"); + $request->setBody('Hello'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(415, $this->response->status); - } /** * @depends testMkcol */ - function testMKCOLBrokenXML() { - + public function testMKCOLBrokenXML() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); - $request->setBody("Hello"); + $request->setBody('Hello'); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(400, $this->response->getStatus(), $this->response->getBodyAsString()); - } /** * @depends testMkcol */ - function testMKCOLUnknownXML() { - + public function testMKCOLUnknownXML() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -96,21 +95,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(400, $this->response->getStatus()); - } /** * @depends testMkcol */ - function testMKCOLNoResourceType() { - + public function testMKCOLNoResourceType() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -128,21 +126,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMkcol */ - function testMKCOLIncorrectResourceType() { - + public function testMKCOLIncorrectResourceType() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -160,21 +157,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLSuccess() { - + public function testMKCOLSuccess() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -192,21 +188,20 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLWhiteSpaceResourceType() { - + public function testMKCOLWhiteSpaceResourceType() + { $serverVars = [ - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', + 'REQUEST_URI' => '/testcol', + 'REQUEST_METHOD' => 'MKCOL', 'HTTP_CONTENT_TYPE' => 'application/xml', ]; @@ -226,20 +221,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Length' => ['0'], + 'Content-Length' => ['0'], ], $this->response->getHeaders()); - $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLNoParent() { - + public function testMKCOLNoParent() + { $serverVars = [ - 'REQUEST_URI' => '/testnoparent/409me', + 'REQUEST_URI' => '/testnoparent/409me', 'REQUEST_METHOD' => 'MKCOL', ]; @@ -251,20 +245,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLParentIsNoCollection() { - + public function testMKCOLParentIsNoCollection() + { $serverVars = [ - 'REQUEST_URI' => '/test.txt/409me', + 'REQUEST_URI' => '/test.txt/409me', 'REQUEST_METHOD' => 'MKCOL', ]; @@ -276,20 +269,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLIncorrectResourceType */ - function testMKCOLAlreadyExists() { - + public function testMKCOLAlreadyExists() + { $serverVars = [ - 'REQUEST_URI' => '/test.txt', + 'REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'MKCOL', ]; @@ -301,20 +293,19 @@ class ServerMKCOLTest extends AbstractServer { $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], ], $this->response->getHeaders()); - $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); - + $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); } /** * @depends testMKCOLSuccess * @depends testMKCOLAlreadyExists */ - function testMKCOLAndProps() { - + public function testMKCOLAndProps() + { $request = new HTTP\Request( 'MKCOL', '/testcol', @@ -332,11 +323,11 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $responseBody = $this->response->getBodyAsString(); @@ -360,7 +351,5 @@ XML; $expected, $responseBody ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php index fa67102cc..35de59e37 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; @@ -7,44 +9,40 @@ use Sabre\HTTP; require_once 'Sabre/DAV/AbstractServer.php'; require_once 'Sabre/DAV/TestPlugin.php'; -class ServerPluginTest extends AbstractServer { - +class ServerPluginTest extends AbstractServer +{ /** * @var Sabre\DAV\TestPlugin */ protected $testPlugin; - function setUp() { - + public function setUp() + { parent::setUp(); $testPlugin = new TestPlugin(); $this->server->addPlugin($testPlugin); $this->testPlugin = $testPlugin; - } - /** - */ - function testBaseClass() { - + public function testBaseClass() + { $p = new ServerPluginMock(); $this->assertEquals([], $p->getFeatures()); $this->assertEquals([], $p->getHTTPMethods('')); $this->assertEquals( [ - 'name' => 'Sabre\DAV\ServerPluginMock', + 'name' => 'Sabre\DAV\ServerPluginMock', 'description' => null, - 'link' => null + 'link' => null, ], $p->getPluginInfo() ); - } - function testOptions() { - + public function testOptions() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'OPTIONS', ]; @@ -53,56 +51,49 @@ class ServerPluginTest extends AbstractServer { $this->server->exec(); $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol, drinking'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], + 'DAV' => ['1, 3, extended-mkcol, drinking'], + 'MS-Author-Via' => ['DAV'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'], + 'Accept-Ranges' => ['bytes'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); $this->assertEquals('OPTIONS', $this->testPlugin->beforeMethod); - - } - function testGetPlugin() { - + public function testGetPlugin() + { $this->assertEquals($this->testPlugin, $this->server->getPlugin(get_class($this->testPlugin))); - } - function testUnknownPlugin() { - + public function testUnknownPlugin() + { $this->assertNull($this->server->getPlugin('SomeRandomClassName')); - } - function testGetSupportedReportSet() { - + public function testGetSupportedReportSet() + { $this->assertEquals([], $this->testPlugin->getSupportedReportSet('/')); - } - function testGetPlugins() { - + public function testGetPlugins() + { $this->assertEquals( [ get_class($this->testPlugin) => $this->testPlugin, - 'core' => $this->server->getPlugin('core'), + 'core' => $this->server->getPlugin('core'), ], $this->server->getPlugins() ); - } - - } -class ServerPluginMock extends ServerPlugin { - - function initialize(Server $s) { } - +class ServerPluginMock extends ServerPlugin +{ + public function initialize(Server $s) + { + } } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php index 203cf26d9..fa88e9095 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPreconditionTest.php @@ -1,61 +1,55 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { - +class ServerPreconditionsTest extends \PHPUnit\Framework\TestCase +{ /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfMatchNoNode() { - + public function testIfMatchNoNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/bar', ['If-Match' => '*']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfMatchHasNode() { - + public function testIfMatchHasNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '*']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfMatchWrongEtag() { - + public function testIfMatchWrongEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '1234']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfMatchCorrectEtag() { - + public function testIfMatchCorrectEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '"abc123"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** @@ -63,107 +57,89 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { * * @depends testIfMatchCorrectEtag */ - function testIfMatchEvolutionEtag() { - + public function testIfMatchEvolutionEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '\\"abc123\\"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfMatchMultiple() { - + public function testIfMatchMultiple() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-Match' => '"hellothere", "abc123"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfNoneMatchNoNode() { - + public function testIfNoneMatchNoNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/bar', ['If-None-Match' => '*']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfNoneMatchHasNode() { - + public function testIfNoneMatchHasNode() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '*']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfNoneMatchWrongEtag() { - + public function testIfNoneMatchWrongEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfNoneMatchWrongEtagMultiple() { - + public function testIfNoneMatchWrongEtagMultiple() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234", "5678"']); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfNoneMatchCorrectEtag() { - + public function testIfNoneMatchCorrectEtag() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"abc123"']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfNoneMatchCorrectEtagMultiple() { - + public function testIfNoneMatchCorrectEtagMultiple() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('POST', '/foo', ['If-None-Match' => '"1234, "abc123"']); $httpResponse = new HTTP\Response(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfNoneMatchCorrectEtagAsGet() { - + public function testIfNoneMatchCorrectEtagAsGet() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $httpRequest = new HTTP\Request('GET', '/foo', ['If-None-Match' => '"abc123"']); @@ -172,14 +148,13 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); $this->assertEquals(304, $server->httpResponse->getStatus()); $this->assertEquals(['ETag' => ['"abc123"']], $server->httpResponse->getHeaders()); - } /** * This was a test written for issue #515. */ - function testNoneMatchCorrectEtagEnsureSapiSent() { - + public function testNoneMatchCorrectEtagEnsureSapiSent() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); $server->sapi = new HTTP\SapiMock(); @@ -193,22 +168,18 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); $this->assertEquals(304, $server->httpResponse->getStatus()); $this->assertEquals([ - 'ETag' => ['"abc123"'], + 'ETag' => ['"abc123"'], 'X-Sabre-Version' => [Version::VERSION], ], $server->httpResponse->getHeaders()); $this->assertEquals(1, HTTP\SapiMock::$sent); - } - /** - */ - function testIfModifiedSinceUnModified() { - + public function testIfModifiedSinceUnModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Modified-Since' => 'Sun, 06 Nov 1994 08:49:37 GMT', ]); $server->httpResponse = new HTTP\ResponseMock(); $this->assertFalse($server->checkPreconditions($httpRequest, $server->httpResponse)); @@ -217,128 +188,96 @@ class ServerPreconditionsTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'Last-Modified' => ['Sat, 06 Apr 1985 23:30:00 GMT'], ], $server->httpResponse->getHeaders()); - } - - /** - */ - function testIfModifiedSinceModified() { - + public function testIfModifiedSinceModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Modified-Since' => 'Tue, 06 Nov 1984 08:49:37 GMT', ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfModifiedSinceInvalidDate() { - + public function testIfModifiedSinceInvalidDate() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Your mother', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Modified-Since' => 'Your mother', ]); $httpResponse = new HTTP\ResponseMock(); // Invalid dates must be ignored, so this should return true $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - */ - function testIfModifiedSinceInvalidDate2() { - + public function testIfModifiedSinceInvalidDate2() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 EST', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Sun, 06 Nov 1994 08:49:37 EST', ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - - /** - */ - function testIfUnmodifiedSinceUnModified() { - + public function testIfUnmodifiedSinceUnModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1994 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Sun, 06 Nov 1994 08:49:37 GMT', ]); $httpResponse = new HTTP\Response(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - /** - * @expectedException Sabre\DAV\Exception\PreconditionFailed + * @expectedException \Sabre\DAV\Exception\PreconditionFailed */ - function testIfUnmodifiedSinceModified() { - + public function testIfUnmodifiedSinceModified() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_UNMODIFIED_SINCE' => 'Tue, 06 Nov 1984 08:49:37 GMT', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Tue, 06 Nov 1984 08:49:37 GMT', ]); $httpResponse = new HTTP\ResponseMock(); $server->checkPreconditions($httpRequest, $httpResponse); - } - /** - */ - function testIfUnmodifiedSinceInvalidDate() { - + public function testIfUnmodifiedSinceInvalidDate() + { $root = new SimpleCollection('root', [new ServerPreconditionsNode()]); $server = new Server($root); - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1984 08:49:37 CET', - 'REQUEST_URI' => '/foo' + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'If-Unmodified-Since' => 'Sun, 06 Nov 1984 08:49:37 CET', ]); $httpResponse = new HTTP\ResponseMock(); $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse)); - } - - } -class ServerPreconditionsNode extends File { - - function getETag() { - +class ServerPreconditionsNode extends File +{ + public function getETag() + { return '"abc123"'; - } - function getLastModified() { - + public function getLastModified() + { /* my birthday & time, I believe */ return strtotime('1985-04-07 01:30 +02:00'); - } - function getName() { - + public function getName() + { return 'foo'; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php index 253200be7..462fba664 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerPropsTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; @@ -7,95 +9,93 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; require_once 'Sabre/DAV/AbstractServer.php'; -class ServerPropsTest extends AbstractServer { - - protected function getRootNode() { - +class ServerPropsTest extends AbstractServer +{ + protected function getRootNode() + { return new FSExt\Directory(SABRE_TEMPDIR); - } - function setUp() { - - if (file_exists(SABRE_TEMPDIR . '../.sabredav')) unlink(SABRE_TEMPDIR . '../.sabredav'); + public function setUp() + { + if (file_exists(SABRE_TEMPDIR.'../.sabredav')) { + unlink(SABRE_TEMPDIR.'../.sabredav'); + } parent::setUp(); - file_put_contents(SABRE_TEMPDIR . '/test2.txt', 'Test contents2'); - mkdir(SABRE_TEMPDIR . '/col'); - file_put_contents(SABRE_TEMPDIR . 'col/test.txt', 'Test contents'); - $this->server->addPlugin(new Locks\Plugin(new Locks\Backend\File(SABRE_TEMPDIR . '/.locksdb'))); - + file_put_contents(SABRE_TEMPDIR.'/test2.txt', 'Test contents2'); + mkdir(SABRE_TEMPDIR.'/col'); + file_put_contents(SABRE_TEMPDIR.'col/test.txt', 'Test contents'); + $this->server->addPlugin(new Locks\Plugin(new Locks\Backend\File(SABRE_TEMPDIR.'/.locksdb'))); } - function tearDown() { - + public function tearDown() + { parent::tearDown(); - if (file_exists(SABRE_TEMPDIR . '../.locksdb')) unlink(SABRE_TEMPDIR . '../.locksdb'); - + if (file_exists(SABRE_TEMPDIR.'../.locksdb')) { + unlink(SABRE_TEMPDIR.'../.locksdb'); + } } - private function sendRequest($body, $path = '/', $headers = ['Depth' => '0']) { - + private function sendRequest($body, $path = '/', $headers = ['Depth' => '0']) + { $request = new HTTP\Request('PROPFIND', $path, $headers, $body); $this->server->httpRequest = $request; $this->server->exec(); - } - function testPropFindEmptyBody() { - - $this->sendRequest(""); + public function testPropFindEmptyBody() + { + $this->sendRequest(''); $this->assertEquals(207, $this->response->status); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol, 2'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol, 2'], + 'Vary' => ['Brief,Prefer'], ], $this->response->getHeaders() ); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/', (string)$data, 'href element should have been /'); + $this->assertEquals('/', (string) $data, 'href element should have been /'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); $this->assertEquals(1, count($data)); - } - function testPropFindEmptyBodyFile() { - - $this->sendRequest("", '/test2.txt', []); + public function testPropFindEmptyBodyFile() + { + $this->sendRequest('', '/test2.txt', []); $this->assertEquals(207, $this->response->status); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'DAV' => ['1, 3, extended-mkcol, 2'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'DAV' => ['1, 3, extended-mkcol, 2'], + 'Vary' => ['Brief,Prefer'], ], $this->response->getHeaders() ); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/test2.txt', (string)$data, 'href element should have been /test2.txt'); + $this->assertEquals('/test2.txt', (string) $data, 'href element should have been /test2.txt'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength'); $this->assertEquals(1, count($data)); - } - function testSupportedLocks() { - + public function testSupportedLocks() + { $xml = '<?xml version="1.0"?> <d:propfind xmlns:d="DAV:"> <d:prop> @@ -105,7 +105,7 @@ class ServerPropsTest extends AbstractServer { $this->sendRequest($xml); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); @@ -128,8 +128,8 @@ class ServerPropsTest extends AbstractServer { $this->assertEquals(2, count($data), 'We expected two \'d:write\' tags'); } - function testLockDiscovery() { - + public function testLockDiscovery() + { $xml = '<?xml version="1.0"?> <d:propfind xmlns:d="DAV:"> <d:prop> @@ -139,17 +139,16 @@ class ServerPropsTest extends AbstractServer { $this->sendRequest($xml); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery'); $this->assertEquals(1, count($data), 'We expected a \'d:lockdiscovery\' tag'); - } - function testUnknownProperty() { - + public function testUnknownProperty() + { $xml = '<?xml version="1.0"?> <d:propfind xmlns:d="DAV:"> <d:prop> @@ -158,7 +157,7 @@ class ServerPropsTest extends AbstractServer { </d:propfind>'; $this->sendRequest($xml); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); $pathTests = [ @@ -170,17 +169,16 @@ class ServerPropsTest extends AbstractServer { '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni', ]; foreach ($pathTests as $test) { - $this->assertTrue(count($xml->xpath($test)) == true, 'We expected the ' . $test . ' element to appear in the response, we got: ' . $body); + $this->assertTrue(true == count($xml->xpath($test)), 'We expected the '.$test.' element to appear in the response, we got: '.$body); } $val = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); $this->assertEquals(1, count($val), $body); - $this->assertEquals('HTTP/1.1 404 Not Found', (string)$val[0]); - + $this->assertEquals('HTTP/1.1 404 Not Found', (string) $val[0]); } - function testParsePropPatchRequest() { - + public function testParsePropPatchRequest() + { $body = '<?xml version="1.0"?> <d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test"> <d:set><d:prop><s:someprop>somevalue</s:someprop></d:prop></d:set> @@ -191,11 +189,9 @@ class ServerPropsTest extends AbstractServer { $result = $this->server->xml->parse($body); $this->assertEquals([ - '{http://sabredav.org/NS/test}someprop' => 'somevalue', + '{http://sabredav.org/NS/test}someprop' => 'somevalue', '{http://sabredav.org/NS/test}someprop2' => null, '{http://sabredav.org/NS/test}someprop3' => null, ], $result->properties); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php index 81224d687..93ea083d8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerRangeTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use DateTime; @@ -12,22 +14,22 @@ use Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ServerRangeTest extends \Sabre\DAVServerTest { - +class ServerRangeTest extends \Sabre\DAVServerTest +{ protected $setupFiles = true; /** - * We need this string a lot + * We need this string a lot. */ protected $lastModified; - function setUp() { - + public function setUp() + { parent::setUp(); $this->server->createFile('files/test.txt', 'Test contents'); - $this->lastModified = HTTP\Util::toHTTPDate( - new DateTime('@' . $this->server->tree->getNodeForPath('files/test.txt')->getLastModified()) + $this->lastModified = HTTP\toDate( + new DateTime('@'.$this->server->tree->getNodeForPath('files/test.txt')->getLastModified()) ); $stream = popen('echo "Test contents"', 'r'); @@ -37,112 +39,106 @@ class ServerRangeTest extends \Sabre\DAVServerTest { ); $streamingFile->setSize(12); $this->server->tree->getNodeForPath('files')->addNode($streamingFile); - } - function testRange() { - + public function testRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-5']); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testRange */ - function testStartRange() { - + public function testStartRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=2-']); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [11], - 'Content-Range' => ['bytes 2-12/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [11], + 'Content-Range' => ['bytes 2-12/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st contents', $response->getBodyAsString()); - } /** * @depends testRange */ - function testEndRange() { - + public function testEndRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=-8']); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [8], - 'Content-Range' => ['bytes 5-12/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [8], + 'Content-Range' => ['bytes 5-12/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('contents', $response->getBodyAsString()); - } /** * @depends testRange */ - function testTooHighRange() { - + public function testTooHighRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=100-200']); $response = $this->request($request); $this->assertEquals(416, $response->getStatus()); - } /** * @depends testRange */ - function testCrazyRange() { - + public function testCrazyRange() + { $request = new HTTP\Request('GET', '/files/test.txt', ['Range' => 'bytes=8-4']); $response = $this->request($request); $this->assertEquals(416, $response->getStatus()); - } - function testNonSeekableStream() { - + public function testNonSeekableStream() + { $request = new HTTP\Request('GET', '/files/no-seeking.txt', ['Range' => 'bytes=2-5']); $response = $this->request($request); $this->assertEquals(206, $response->getStatus(), $response); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/12'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/12'], // 'ETag' => ['"' . md5('Test contents') . '"'], 'Last-Modified' => [$this->lastModified], ], @@ -150,113 +146,107 @@ class ServerRangeTest extends \Sabre\DAVServerTest { ); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testRange */ - function testIfRangeEtag() { - + public function testIfRangeEtag() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', - 'If-Range' => '"' . md5('Test contents') . '"', + 'Range' => 'bytes=2-5', + 'If-Range' => '"'.md5('Test contents').'"', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testIfRangeEtag */ - function testIfRangeEtagIncorrect() { - + public function testIfRangeEtagIncorrect() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', + 'Range' => 'bytes=2-5', 'If-Range' => '"foobar"', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(200, $response->getStatus()); $this->assertEquals('Test contents', $response->getBodyAsString()); - } /** * @depends testIfRangeEtag */ - function testIfRangeModificationDate() { - + public function testIfRangeModificationDate() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', + 'Range' => 'bytes=2-5', 'If-Range' => 'tomorrow', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [4], - 'Content-Range' => ['bytes 2-5/13'], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [4], + 'Content-Range' => ['bytes 2-5/13'], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(206, $response->getStatus()); $this->assertEquals('st c', $response->getBodyAsString()); - } /** * @depends testIfRangeModificationDate */ - function testIfRangeModificationDateModified() { - + public function testIfRangeModificationDateModified() + { $request = new HTTP\Request('GET', '/files/test.txt', [ - 'Range' => 'bytes=2-5', + 'Range' => 'bytes=2-5', 'If-Range' => '-2 years', ]); $response = $this->request($request); $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/octet-stream'], - 'Content-Length' => [13], - 'ETag' => ['"' . md5('Test contents') . '"'], - 'Last-Modified' => [$this->lastModified], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'ETag' => ['"'.md5('Test contents').'"'], + 'Last-Modified' => [$this->lastModified], ], $response->getHeaders() ); $this->assertEquals(200, $response->getStatus()); $this->assertEquals('Test contents', $response->getBodyAsString()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php index 043179a00..53153151b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php @@ -1,90 +1,74 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class ServerSimpleTest extends AbstractServer{ - - function testConstructArray() { - - $nodes = [ - new SimpleCollection('hello') - ]; - - $server = new Server($nodes); - $this->assertEquals($nodes[0], $server->tree->getNodeForPath('hello')); - - } - - /** - * @expectedException Sabre\DAV\Exception - */ - function testConstructIncorrectObj() { - +class ServerSimpleTest extends AbstractServer +{ + public function testConstructArray() + { $nodes = [ new SimpleCollection('hello'), - new \STDClass(), ]; $server = new Server($nodes); - + $this->assertEquals($nodes[0], $server->tree->getNodeForPath('hello')); } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testConstructInvalidArg() { - + public function testConstructInvalidArg() + { $server = new Server(1); - } - function testOptions() { - + public function testOptions() + { $request = new HTTP\Request('OPTIONS', '/'); $this->server->httpRequest = $request; $this->server->exec(); $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'], + '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' => [Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testOptionsUnmapped() { - + public function testOptionsUnmapped() + { $request = new HTTP\Request('OPTIONS', '/unmapped'); $this->server->httpRequest = $request; $this->server->exec(); $this->assertEquals([ - 'DAV' => ['1, 3, extended-mkcol'], - 'MS-Author-Via' => ['DAV'], - 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, MKCOL'], - 'Accept-Ranges' => ['bytes'], - 'Content-Length' => ['0'], + 'DAV' => ['1, 3, extended-mkcol'], + 'MS-Author-Via' => ['DAV'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, MKCOL'], + 'Accept-Ranges' => ['bytes'], + 'Content-Length' => ['0'], 'X-Sabre-Version' => [Version::VERSION], ], $this->response->getHeaders()); $this->assertEquals(200, $this->response->status); $this->assertEquals('', $this->response->body); - } - function testNonExistantMethod() { - + public function testNonExistantMethod() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'BLABLA', ]; @@ -94,21 +78,19 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); $this->assertEquals(501, $this->response->status); - - } - function testBaseUri() { - + public function testBaseUri() + { $serverVars = [ - 'REQUEST_URI' => '/blabla/test.txt', + 'REQUEST_URI' => '/blabla/test.txt', 'REQUEST_METHOD' => 'GET', ]; - $filename = $this->tempDir . '/test.txt'; + $filename = $this->tempDir.'/test.txt'; $request = HTTP\Sapi::createFromServerArray($serverVars); $this->server->setBaseUri('/blabla/'); @@ -118,26 +100,25 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [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)) . '"'], + 'Content-Type' => ['application/octet-stream'], + 'Content-Length' => [13], + 'Last-Modified' => [HTTP\toDate(new \DateTime('@'.filemtime($filename)))], + 'ETag' => ['"'.sha1(fileinode($filename).filesize($filename).filemtime($filename)).'"'], ], $this->response->getHeaders() ); $this->assertEquals(200, $this->response->status); $this->assertEquals('Test contents', stream_get_contents($this->response->body)); - } - function testBaseUriAddSlash() { - + public function testBaseUriAddSlash() + { $tests = [ - '/' => '/', - '/foo' => '/foo/', - '/foo/' => '/foo/', - '/foo/bar' => '/foo/bar/', + '/' => '/', + '/foo' => '/foo/', + '/foo/' => '/foo/', + '/foo/bar' => '/foo/bar/', '/foo/bar/' => '/foo/bar/', ]; @@ -145,92 +126,86 @@ class ServerSimpleTest extends AbstractServer{ $this->server->setBaseUri($test); $this->assertEquals($result, $this->server->getBaseUri()); - } - } - function testCalculateUri() { - + public function testCalculateUri() + { $uris = [ 'http://www.example.org/root/somepath', '/root/somepath', '/root/somepath/', + '//root/somepath/', + '///root///somepath///', ]; $this->server->setBaseUri('/root/'); foreach ($uris as $uri) { - $this->assertEquals('somepath', $this->server->calculateUri($uri)); - } $this->server->setBaseUri('/root'); foreach ($uris as $uri) { - $this->assertEquals('somepath', $this->server->calculateUri($uri)); - } $this->assertEquals('', $this->server->calculateUri('/root')); - } + $this->server->setBaseUri('/'); + + foreach ($uris as $uri) { + $this->assertEquals('root/somepath', $this->server->calculateUri($uri)); + } - function testCalculateUriSpecialChars() { + $this->assertEquals('', $this->server->calculateUri('')); + } + public function testCalculateUriSpecialChars() + { $uris = [ 'http://www.example.org/root/%C3%A0fo%C3%B3', '/root/%C3%A0fo%C3%B3', - '/root/%C3%A0fo%C3%B3/' + '/root/%C3%A0fo%C3%B3/', ]; $this->server->setBaseUri('/root/'); foreach ($uris as $uri) { - $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } $this->server->setBaseUri('/root'); foreach ($uris as $uri) { - $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } $this->server->setBaseUri('/'); foreach ($uris as $uri) { - $this->assertEquals("root/\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri)); - } - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCalculateUriBreakout() { - + public function testCalculateUriBreakout() + { $uri = '/path1/'; $this->server->setBaseUri('/path2/'); $this->server->calculateUri($uri); - } - /** - */ - function testGuessBaseUri() { - + public function testGuessBaseUri() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root', - 'PATH_INFO' => '/root', + 'PATH_INFO' => '/root', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -238,17 +213,17 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } /** * @depends testGuessBaseUri */ - function testGuessBaseUriPercentEncoding() { - + public function testGuessBaseUriPercentEncoding() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/dir/path2/path%20with%20spaces', - 'PATH_INFO' => '/dir/path2/path with spaces', + 'PATH_INFO' => '/dir/path2/path with spaces', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -256,7 +231,6 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } /** @@ -279,11 +253,12 @@ class ServerSimpleTest extends AbstractServer{ }*/ - function testGuessBaseUri2() { - + public function testGuessBaseUri2() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root/', - 'PATH_INFO' => '/root/', + 'PATH_INFO' => '/root/', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -291,12 +266,12 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } - function testGuessBaseUriNoPathInfo() { - + public function testGuessBaseUriNoPathInfo() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root', ]; @@ -305,32 +280,26 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/', $server->guessBaseUri()); - } - function testGuessBaseUriNoPathInfo2() { - - $serverVars = [ - 'REQUEST_URI' => '/a/b/c/test.php', - ]; - - $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); + public function testGuessBaseUriNoPathInfo2() + { + $httpRequest = new HTTP\Request('GET', '/a/b/c/test.php'); $server = new Server(); $server->httpRequest = $httpRequest; $this->assertEquals('/', $server->guessBaseUri()); - } - /** * @depends testGuessBaseUri */ - function testGuessBaseUriQueryString() { - + public function testGuessBaseUriQueryString() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root?query_string=blabla', - 'PATH_INFO' => '/root', + 'PATH_INFO' => '/root', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -338,18 +307,18 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $this->assertEquals('/index.php/', $server->guessBaseUri()); - } /** * @depends testGuessBaseUri * @expectedException \Sabre\DAV\Exception */ - function testGuessBaseUriBadConfig() { - + public function testGuessBaseUriBadConfig() + { $serverVars = [ + 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php/root/heyyy', - 'PATH_INFO' => '/root', + 'PATH_INFO' => '/root', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); @@ -357,19 +326,18 @@ class ServerSimpleTest extends AbstractServer{ $server->httpRequest = $httpRequest; $server->guessBaseUri(); - } - function testTriggerException() { - + public function testTriggerException() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'FOO', ]; $httpRequest = HTTP\Sapi::createFromServerArray($serverVars); $this->server->httpRequest = $httpRequest; - $this->server->on('beforeMethod', [$this, 'exceptionTrigger']); + $this->server->on('beforeMethod:*', [$this, 'exceptionTrigger']); $this->server->exec(); $this->assertEquals([ @@ -377,19 +345,17 @@ class ServerSimpleTest extends AbstractServer{ ], $this->response->getHeaders()); $this->assertEquals(500, $this->response->status); - } - function exceptionTrigger($request, $response) { - + public function exceptionTrigger($request, $response) + { throw new Exception('Hola'); - } - function testReportNotFound() { - + public function testReportNotFound() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'REPORT', ]; @@ -400,19 +366,18 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders() ); - $this->assertEquals(415, $this->response->status, 'We got an incorrect status back. Full response body follows: ' . $this->response->body); - + $this->assertEquals(415, $this->response->status, 'We got an incorrect status back. Full response body follows: '.$this->response->body); } - function testReportIntercepted() { - + public function testReportIntercepted() + { $serverVars = [ - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'REPORT', ]; @@ -424,52 +389,49 @@ class ServerSimpleTest extends AbstractServer{ $this->assertEquals([ 'X-Sabre-Version' => [Version::VERSION], - 'testheader' => ['testvalue'], + 'testheader' => ['testvalue'], ], $this->response->getHeaders() ); - $this->assertEquals(418, $this->response->status, 'We got an incorrect status back. Full response body follows: ' . $this->response->body); - + $this->assertEquals(418, $this->response->status, 'We got an incorrect status back. Full response body follows: '.$this->response->body); } - function reportHandler($reportName, $result, $path) { - - if ($reportName == '{http://www.rooftopsolutions.nl/NS}myreport') { + public function reportHandler($reportName, $result, $path) + { + if ('{http://www.rooftopsolutions.nl/NS}myreport' == $reportName) { $this->server->httpResponse->setStatus(418); $this->server->httpResponse->setHeader('testheader', 'testvalue'); + return false; + } else { + return; } - else return; - } - function testGetPropertiesForChildren() { - + public function testGetPropertiesForChildren() + { $result = $this->server->getPropertiesForChildren('', [ '{DAV:}getcontentlength', ]); $expected = [ 'test.txt' => ['{DAV:}getcontentlength' => 13], - 'dir/' => [], + 'dir/' => [], ]; $this->assertEquals($expected, $result); - } /** * There are certain cases where no HTTP status may be set. We need to * intercept these and set it to a default error message. */ - function testNoHTTPStatusSet() { - - $this->server->on('method:GET', function() { return false; }, 1); + public function testNoHTTPStatusSet() + { + $this->server->on('method:GET', function () { return false; }, 1); $this->server->httpRequest = new HTTP\Request('GET', '/'); $this->server->exec(); $this->assertEquals(500, $this->response->getStatus()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php index 383f8e657..cb8a4ab32 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerUpdatePropertiesTest.php @@ -1,102 +1,97 @@ <?php -namespace Sabre\DAV; - -class ServerUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testUpdatePropertiesFail() { +namespace Sabre\DAV; +class ServerUpdatePropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function testUpdatePropertiesFail() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar' + '{DAV:}foo' => 'bar', ]); $expected = [ '{DAV:}foo' => 403, ]; $this->assertEquals($expected, $result); - } - function testUpdatePropertiesProtected() { - + public function testUpdatePropertiesProtected() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); - $server->on('propPatch', function($path, PropPatch $propPatch) { - $propPatch->handleRemaining(function() { return true; }); + $server->on('propPatch', function ($path, PropPatch $propPatch) { + $propPatch->handleRemaining(function () { return true; }); }); $result = $server->updateProperties('foo', [ '{DAV:}getetag' => 'bla', - '{DAV:}foo' => 'bar' + '{DAV:}foo' => 'bar', ]); $expected = [ '{DAV:}getetag' => 403, - '{DAV:}foo' => 424, + '{DAV:}foo' => 424, ]; $this->assertEquals($expected, $result); - } - function testUpdatePropertiesEventFail() { - + public function testUpdatePropertiesEventFail() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); - $server->on('propPatch', function($path, PropPatch $propPatch) { + $server->on('propPatch', function ($path, PropPatch $propPatch) { $propPatch->setResultCode('{DAV:}foo', 404); - $propPatch->handleRemaining(function() { return true; }); + $propPatch->handleRemaining(function () { return true; }); }); $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar', + '{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla', ]); $expected = [ - '{DAV:}foo' => 404, + '{DAV:}foo' => 404, '{DAV:}foo2' => 424, ]; $this->assertEquals($expected, $result); - } - function testUpdatePropertiesEventSuccess() { - + public function testUpdatePropertiesEventSuccess() + { $tree = [ new SimpleCollection('foo'), ]; $server = new Server($tree); - $server->on('propPatch', function($path, PropPatch $propPatch) { - - $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function() { + $server->on('propPatch', function ($path, PropPatch $propPatch) { + $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function () { return [ - '{DAV:}foo' => 200, + '{DAV:}foo' => 200, '{DAV:}foo2' => 201, ]; }); - }); $result = $server->updateProperties('foo', [ - '{DAV:}foo' => 'bar', + '{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla', ]); $expected = [ - '{DAV:}foo' => 200, + '{DAV:}foo' => 200, '{DAV:}foo2' => 201, ]; $this->assertEquals($expected, $result); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php index 15ccfaf9e..6edca5ecc 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/SimpleFileTest.php @@ -1,19 +1,19 @@ <?php -namespace Sabre\DAV; - -class SimpleFileTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testAll() { +namespace Sabre\DAV; +class SimpleFileTest extends \PHPUnit\Framework\TestCase +{ + public function testAll() + { $file = new SimpleFile('filename.txt', 'contents', 'text/plain'); $this->assertEquals('filename.txt', $file->getName()); $this->assertEquals('contents', $file->get()); $this->assertEquals(8, $file->getSize()); - $this->assertEquals('"' . sha1('contents') . '"', $file->getETag()); + $this->assertEquals('"'.sha1('contents').'"', $file->getETag()); $this->assertEquals('text/plain', $file->getContentType()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php index e98fe9048..1e4b92197 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/StringUtilTest.php @@ -1,27 +1,29 @@ <?php -namespace Sabre\DAV; +declare(strict_types=1); -class StringUtilTest extends \PHPUnit_Framework_TestCase { +namespace Sabre\DAV; +class StringUtilTest extends \PHPUnit\Framework\TestCase +{ /** * @param string $haystack * @param string $needle * @param string $collation * @param string $matchType * @param string $result + * * @throws Exception\BadRequest * * @dataProvider dataset */ - function testTextMatch($haystack, $needle, $collation, $matchType, $result) { - + public function testTextMatch($haystack, $needle, $collation, $matchType, $result) + { $this->assertEquals($result, StringUtil::textMatch($haystack, $needle, $collation, $matchType)); - } - function dataset() { - + public function dataset() + { return [ ['FOOBAR', 'FOO', 'i;octet', 'contains', true], ['FOOBAR', 'foo', 'i;octet', 'contains', false], @@ -68,62 +70,54 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase { ['FOOBAR', 'BAR', 'i;unicode-casemap', 'ends-with', true], ['FOOBAR', 'bar', 'i;unicode-casemap', 'ends-with', true], ]; - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testBadCollation() { - + public function testBadCollation() + { StringUtil::textMatch('foobar', 'foo', 'blabla', 'contains'); - } - /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testBadMatchType() { - + public function testBadMatchType() + { StringUtil::textMatch('foobar', 'foo', 'i;octet', 'booh'); - } - function testEnsureUTF8_ascii() { - - $inputString = "harkema"; - $outputString = "harkema"; + public function testEnsureUTF8_ascii() + { + $inputString = 'harkema'; + $outputString = 'harkema'; $this->assertEquals( $outputString, StringUtil::ensureUTF8($inputString) ); - } - function testEnsureUTF8_latin1() { - + public function testEnsureUTF8_latin1() + { $inputString = "m\xfcnster"; - $outputString = "münster"; + $outputString = 'münster'; $this->assertEquals( $outputString, StringUtil::ensureUTF8($inputString) ); - } - function testEnsureUTF8_utf8() { - + public function testEnsureUTF8_utf8() + { $inputString = "m\xc3\xbcnster"; - $outputString = "münster"; + $outputString = 'münster'; $this->assertEquals( $outputString, StringUtil::ensureUTF8($inputString) ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php index 6acd6b077..352c8a3e7 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TemporaryFileFilterTest.php @@ -1,21 +1,22 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP; -class TemporaryFileFilterTest extends AbstractServer { - - function setUp() { - +class TemporaryFileFilterTest extends AbstractServer +{ + public function setUp() + { parent::setUp(); - $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR . '/tff'); + $plugin = new TemporaryFileFilterPlugin(SABRE_TEMPDIR.'/tff'); $this->server->addPlugin($plugin); - } - function testPutNormal() { - + public function testPutNormal() + { $request = new HTTP\Request('PUT', '/testput.txt', [], 'Testing new file'); $this->server->httpRequest = ($request); @@ -25,12 +26,11 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals(201, $this->response->status); $this->assertEquals('0', $this->response->getHeader('Content-Length')); - $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR . '/testput.txt')); - + $this->assertEquals('Testing new file', file_get_contents(SABRE_TEMPDIR.'/testput.txt')); } - function testPutTemp() { - + public function testPutTemp() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); @@ -43,12 +43,11 @@ class TemporaryFileFilterTest extends AbstractServer { 'X-Sabre-Temp' => ['true'], ], $this->response->getHeaders()); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); - + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); } - function testPutTempIfNoneMatch() { - + public function testPutTempIfNoneMatch() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', ['If-None-Match' => '*'], 'Testing new file'); @@ -61,8 +60,7 @@ class TemporaryFileFilterTest extends AbstractServer { 'X-Sabre-Temp' => ['true'], ], $this->response->getHeaders()); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); - + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testput.txt'), '._testput.txt should not exist in the regular file structure.'); $this->server->exec(); @@ -71,11 +69,10 @@ class TemporaryFileFilterTest extends AbstractServer { 'X-Sabre-Temp' => ['true'], 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - } - function testPutGet() { - + public function testPutGet() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); $this->server->httpRequest = ($request); @@ -94,19 +91,29 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals(200, $this->response->status); $this->assertEquals([ - 'X-Sabre-Temp' => ['true'], + 'X-Sabre-Temp' => ['true'], 'Content-Length' => [16], - 'Content-Type' => ['application/octet-stream'], + 'Content-Type' => ['application/octet-stream'], ], $this->response->getHeaders()); $this->assertEquals('Testing new file', stream_get_contents($this->response->body)); - } - function testLockNonExistant() { + public function testGetWithBrowserPlugin() + { + $this->server->addPlugin(new Browser\Plugin()); + $request = new HTTP\Request('GET', '/'); + + $this->server->httpRequest = $request; + $this->server->exec(); + + $this->assertEquals(200, $this->response->status); + } - mkdir(SABRE_TEMPDIR . '/locksdir'); - $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR . '/locks'); + public function testLockNonExistant() + { + mkdir(SABRE_TEMPDIR.'/locksdir'); + $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR.'/locks'); $locksPlugin = new Locks\Plugin($locksBackend); $this->server->addPlugin($locksPlugin); @@ -126,15 +133,14 @@ class TemporaryFileFilterTest extends AbstractServer { $this->assertEquals(201, $this->response->status); $this->assertEquals('application/xml; charset=utf-8', $this->response->getHeader('Content-Type')); - $this->assertTrue(preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')) === 1, 'We did not get a valid Locktoken back (' . $this->response->getHeader('Lock-Token') . ')'); + $this->assertTrue(1 === preg_match('/^<opaquelocktoken:(.*)>$/', $this->response->getHeader('Lock-Token')), 'We did not get a valid Locktoken back ('.$this->response->getHeader('Lock-Token').')'); $this->assertEquals('true', $this->response->getHeader('X-Sabre-Temp')); - $this->assertFalse(file_exists(SABRE_TEMPDIR . '/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.'); - + $this->assertFalse(file_exists(SABRE_TEMPDIR.'/._testlock.txt'), '._testlock.txt should not exist in the regular file structure.'); } - function testPutDelete() { - + public function testPutDelete() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); @@ -151,17 +157,16 @@ class TemporaryFileFilterTest extends AbstractServer { $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n" . $this->response->body); + $this->assertEquals(204, $this->response->status, "Incorrect status code received. Full body:\n".$this->response->body); $this->assertEquals([ 'X-Sabre-Temp' => ['true'], ], $this->response->getHeaders()); $this->assertEquals('', $this->response->body); - } - function testPutPropfind() { - + public function testPutPropfind() + { // mimicking an OS/X resource fork $request = new HTTP\Request('PUT', '/._testput.txt', [], 'Testing new file'); $this->server->httpRequest = $request; @@ -178,22 +183,20 @@ class TemporaryFileFilterTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Incorrect status code returned. Body: '.$this->response->body); $this->assertEquals([ 'X-Sabre-Temp' => ['true'], 'Content-Type' => ['application/xml; charset=utf-8'], ], $this->response->getHeaders()); - $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); + $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", 'xmlns\\1="urn:DAV"', $this->response->body); $xml = simplexml_load_string($body); $xml->registerXPathNamespace('d', 'urn:DAV'); list($data) = $xml->xpath('/d:multistatus/d:response/d:href'); - $this->assertEquals('/._testput.txt', (string)$data, 'href element should have been /._testput.txt'); + $this->assertEquals('/._testput.txt', (string) $data, 'href element should have been /._testput.txt'); $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype'); $this->assertEquals(1, count($data)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php index 619ac03fd..3bfe3b3b0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php @@ -1,37 +1,35 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; -class TestPlugin extends ServerPlugin { - +class TestPlugin extends ServerPlugin +{ public $beforeMethod; - function getFeatures() { - + public function getFeatures() + { return ['drinking']; - } - function getHTTPMethods($uri) { - - return ['BEER','WINE']; - + public function getHTTPMethods($uri) + { + return ['BEER', 'WINE']; } - function initialize(Server $server) { - - $server->on('beforeMethod', [$this, 'beforeMethod']); - + public function initialize(Server $server) + { + $server->on('beforeMethod:*', [$this, 'beforeMethod']); } - function beforeMethod(RequestInterface $request, ResponseInterface $response) { - + public function beforeMethod(RequestInterface $request, ResponseInterface $response) + { $this->beforeMethod = $request->getMethod(); - return true; + return true; } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php index c70d17a22..51ff5ccde 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php @@ -1,110 +1,104 @@ <?php -namespace Sabre\DAV; - -class TreeTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testNodeExists() { +namespace Sabre\DAV; +class TreeTest extends \PHPUnit\Framework\TestCase +{ + public function testNodeExists() + { $tree = new TreeMock(); $this->assertTrue($tree->nodeExists('hi')); $this->assertFalse($tree->nodeExists('hello')); - } - function testCopy() { - + public function testCopy() + { $tree = new TreeMock(); $tree->copy('hi', 'hi2'); $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); $this->assertEquals('foobar', $tree->getNodeForPath('hi/file')->get()); $this->assertEquals(['test1' => 'value'], $tree->getNodeForPath('hi/file')->getProperties([])); - } - function testCopyFile() { - + public function testCopyFile() + { $tree = new TreeMock(); $tree->copy('hi/file', 'hi/newfile'); $this->assertArrayHasKey('newfile', $tree->getNodeForPath('hi')->newFiles); } - function testCopyFile0() { - + public function testCopyFile0() + { $tree = new TreeMock(); $tree->copy('hi/file', 'hi/0'); $this->assertArrayHasKey('0', $tree->getNodeForPath('hi')->newFiles); } - function testMove() { - + public function testMove() + { $tree = new TreeMock(); $tree->move('hi', 'hi2'); $this->assertEquals('hi2', $tree->getNodeForPath('hi')->getName()); $this->assertTrue($tree->getNodeForPath('hi')->isRenamed); - } - function testDeepMove() { - + public function testDeepMove() + { $tree = new TreeMock(); $tree->move('hi/sub', 'hi2'); $this->assertArrayHasKey('hi2', $tree->getNodeForPath('')->newDirectories); $this->assertTrue($tree->getNodeForPath('hi/sub')->isDeleted); - } - function testDelete() { - + public function testDelete() + { $tree = new TreeMock(); $tree->delete('hi'); $this->assertTrue($tree->getNodeForPath('hi')->isDeleted); - } - function testGetChildren() { - + public function testGetChildren() + { $tree = new TreeMock(); $children = $tree->getChildren(''); - $this->assertEquals(2, count($children)); - $this->assertEquals('hi', $children[0]->getName()); - + $firstChild = $children->current(); + $this->assertEquals('hi', $firstChild->getName()); } - function testGetMultipleNodes() { - + public function testGetMultipleNodes() + { $tree = new TreeMock(); $result = $tree->getMultipleNodes(['hi/sub', 'hi/file']); $this->assertArrayHasKey('hi/sub', $result); $this->assertArrayHasKey('hi/file', $result); - $this->assertEquals('sub', $result['hi/sub']->getName()); + $this->assertEquals('sub', $result['hi/sub']->getName()); $this->assertEquals('file', $result['hi/file']->getName()); - } - function testGetMultipleNodes2() { + public function testGetMultipleNodes2() + { $tree = new TreeMock(); $result = $tree->getMultipleNodes(['multi/1', 'multi/2']); $this->assertArrayHasKey('multi/1', $result); $this->assertArrayHasKey('multi/2', $result); - } - } -class TreeMock extends Tree { - +class TreeMock extends Tree +{ private $nodes = []; - function __construct() { - + public function __construct() + { $file = new TreeFileTester('file'); $file->properties = ['test1' => 'value']; $file->data = 'foobar'; @@ -119,92 +113,86 @@ class TreeMock extends Tree { new TreeFileTester('1'), new TreeFileTester('2'), new TreeFileTester('3'), - ]) + ]), ]) ); - } - } -class TreeDirectoryTester extends SimpleCollection { - +class TreeDirectoryTester extends SimpleCollection +{ public $newDirectories = []; public $newFiles = []; public $isDeleted = false; public $isRenamed = false; - function createDirectory($name) { - + public function createDirectory($name) + { $this->newDirectories[$name] = true; - } - function createFile($name, $data = null) { - + public function createFile($name, $data = null) + { $this->newFiles[$name] = $data; - } - function getChild($name) { + public function getChild($name) + { + if (isset($this->newDirectories[$name])) { + return new self($name); + } + if (isset($this->newFiles[$name])) { + return new TreeFileTester($name, $this->newFiles[$name]); + } - if (isset($this->newDirectories[$name])) return new self($name); - if (isset($this->newFiles[$name])) return new TreeFileTester($name, $this->newFiles[$name]); return parent::getChild($name); - } - function childExists($name) { - - return !!$this->getChild($name); - + public function childExists($name) + { + return (bool) $this->getChild($name); } - function delete() { - + public function delete() + { $this->isDeleted = true; - } - function setName($name) { - + public function setName($name) + { $this->isRenamed = true; $this->name = $name; - } - } -class TreeFileTester extends File implements IProperties { - +class TreeFileTester extends File implements IProperties +{ public $name; public $data; public $properties; - function __construct($name, $data = null) { - + public function __construct($name, $data = null) + { $this->name = $name; - if (is_null($data)) $data = 'bla'; + if (is_null($data)) { + $data = 'bla'; + } $this->data = $data; - } - function getName() { - + public function getName() + { return $this->name; - } - function get() { - + public function get() + { return $this->data; - } - function getProperties($properties) { - + public function getProperties($properties) + { return $this->properties; - } /** @@ -217,19 +205,16 @@ class TreeFileTester extends File implements IProperties { * Read the PropPatch documentation for more information. * * @param PropPatch $propPatch - * @return void */ - function propPatch(PropPatch $propPatch) { - + public function propPatch(PropPatch $propPatch) + { $this->properties = $propPatch->getMutations(); $propPatch->setRemainingResultCode(200); - } - } -class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { - +class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet +{ /** * This method receives a list of paths in it's first argument. * It must return an array with Node objects. @@ -237,10 +222,11 @@ class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { * If any children are not found, you do not have to return them. * * @param array $paths + * * @return array */ - function getMultipleChildren(array $paths) { - + public function getMultipleChildren(array $paths) + { $result = []; foreach ($paths as $path) { try { @@ -252,7 +238,5 @@ class TreeMultiGetTester extends TreeDirectoryTester implements IMultiGet { } return $result; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php b/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php index f005ecc75..d7ef9bec9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php @@ -1,11 +1,13 @@ <?php -namespace Sabre\DAV; - -class UUIDUtilTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testValidateUUID() { +namespace Sabre\DAV; +class UUIDUtilTest extends \PHPUnit\Framework\TestCase +{ + public function testValidateUUID() + { $this->assertTrue( UUIDUtil::validateUUID('11111111-2222-3333-4444-555555555555') ); @@ -18,8 +20,5 @@ class UUIDUtilTest extends \PHPUnit_Framework_TestCase { $this->assertFalse( UUIDUtil::validateUUID('fffffffg-2222-3333-4444-555555555555') ); - - } - } |