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/Locks | |
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/Locks')
6 files changed, 252 insertions, 400 deletions
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(); - } - - } |