From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- .../tests/Sabre/CalDAV/Backend/AbstractPDOTest.php | 751 ++++++++++----------- .../tests/Sabre/CalDAV/Backend/AbstractTest.php | 142 ++-- .../sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php | 105 ++- .../tests/Sabre/CalDAV/Backend/PDOMySQLTest.php | 7 +- .../tests/Sabre/CalDAV/Backend/PDOSqliteTest.php | 7 +- .../dav/tests/Sabre/CalDAV/CalendarObjectTest.php | 156 ++--- .../tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php | 71 +- .../Sabre/CalDAV/CalendarQueryValidatorTest.php | 210 +++--- .../sabre/dav/tests/Sabre/CalDAV/CalendarTest.php | 125 ++-- .../CalDAV/ExpandEventsDTSTARTandDTENDTest.php | 37 +- .../ExpandEventsDTSTARTandDTENDbyDayTest.php | 35 +- .../Sabre/CalDAV/ExpandEventsDoubleEventsTest.php | 28 +- .../dav/tests/Sabre/CalDAV/FreeBusyReportTest.php | 82 +-- .../Sabre/CalDAV/GetEventsByTimerangeTest.php | 26 +- .../dav/tests/Sabre/CalDAV/ICSExportPluginTest.php | 144 ++-- .../sabre/dav/tests/Sabre/CalDAV/Issue166Test.php | 28 +- .../sabre/dav/tests/Sabre/CalDAV/Issue172Test.php | 51 +- .../sabre/dav/tests/Sabre/CalDAV/Issue203Test.php | 40 +- .../sabre/dav/tests/Sabre/CalDAV/Issue205Test.php | 31 +- .../sabre/dav/tests/Sabre/CalDAV/Issue211Test.php | 27 +- .../sabre/dav/tests/Sabre/CalDAV/Issue220Test.php | 30 +- .../sabre/dav/tests/Sabre/CalDAV/Issue228Test.php | 27 +- .../Sabre/CalDAV/Notifications/CollectionTest.php | 47 +- .../tests/Sabre/CalDAV/Notifications/NodeTest.php | 58 +- vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php | 535 +++++++-------- .../Sabre/CalDAV/Principal/CollectionTest.php | 12 +- .../tests/Sabre/CalDAV/Principal/ProxyReadTest.php | 69 +- .../Sabre/CalDAV/Principal/ProxyWriteTest.php | 27 +- .../dav/tests/Sabre/CalDAV/Principal/UserTest.php | 66 +- .../dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php | 17 +- .../dav/tests/Sabre/CalDAV/SharedCalendarTest.php | 56 +- .../dav/tests/Sabre/CalDAV/SharingPluginTest.php | 200 +++--- vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php | 106 ++- .../dav/tests/Sabre/CalDAV/ValidateICalTest.php | 167 +++-- .../dav/tests/Sabre/CardDAV/AbstractPluginTest.php | 14 +- .../tests/Sabre/CardDAV/AddressBookQueryTest.php | 84 ++- .../tests/Sabre/CardDAV/AddressBookRootTest.php | 16 +- .../dav/tests/Sabre/CardDAV/AddressBookTest.php | 115 ++-- .../Sabre/CardDAV/Backend/AbstractPDOTest.php | 272 ++++---- .../sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php | 116 ++-- .../tests/Sabre/CardDAV/Backend/PDOMySQLTest.php | 7 +- .../tests/Sabre/CardDAV/Backend/PDOSqliteTest.php | 7 +- vendor/sabre/dav/tests/Sabre/CardDAV/CardTest.php | 132 ++-- .../dav/tests/Sabre/CardDAV/IDirectoryTest.php | 22 +- .../sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php | 38 +- .../sabre/dav/tests/Sabre/CardDAV/PluginTest.php | 91 ++- .../Sabre/CardDAV/SogoStripContentTypeTest.php | 41 +- vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php | 31 +- .../dav/tests/Sabre/CardDAV/VCFExportTest.php | 65 +- .../dav/tests/Sabre/CardDAV/ValidateFilterTest.php | 83 ++- .../dav/tests/Sabre/CardDAV/ValidateVCardTest.php | 100 ++- .../sabre/dav/tests/Sabre/DAV/AbstractServer.php | 46 +- .../Sabre/DAV/Auth/Backend/AbstractBasicTest.php | 59 +- .../Sabre/DAV/Auth/Backend/AbstractDigestTest.php | 84 ++- .../Sabre/DAV/Auth/Backend/AbstractPDOTest.php | 23 +- .../tests/Sabre/DAV/Auth/Backend/ApacheTest.php | 39 +- .../dav/tests/Sabre/DAV/Auth/Backend/FileTest.php | 41 +- .../dav/tests/Sabre/DAV/Auth/Backend/Mock.php | 30 +- .../tests/Sabre/DAV/Auth/Backend/PDOMySQLTest.php | 7 +- .../tests/Sabre/DAV/Auth/Backend/PDOSqliteTest.php | 7 +- .../sabre/dav/tests/Sabre/DAV/Auth/PluginTest.php | 68 +- vendor/sabre/dav/tests/Sabre/DAV/BasicNodeTest.php | 195 ++---- .../Sabre/DAV/Browser/GuessContentTypeTest.php | 36 +- .../Sabre/DAV/Browser/MapGetToPropFindTest.php | 28 +- .../dav/tests/Sabre/DAV/Browser/PluginTest.php | 124 ++-- vendor/sabre/dav/tests/Sabre/DAV/ClientMock.php | 22 +- vendor/sabre/dav/tests/Sabre/DAV/ClientTest.php | 127 ++-- .../dav/tests/Sabre/DAV/Exception/LockedTest.php | 16 +- .../Sabre/DAV/Exception/PaymentRequiredTest.php | 12 +- vendor/sabre/dav/tests/Sabre/DAV/ExceptionTest.php | 21 +- .../sabre/dav/tests/Sabre/DAV/FSExt/FileTest.php | 101 ++- .../sabre/dav/tests/Sabre/DAV/FSExt/ServerTest.php | 162 ++--- .../dav/tests/Sabre/DAV/HTTPPreferParsingTest.php | 175 +++-- .../sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php | 70 +- vendor/sabre/dav/tests/Sabre/DAV/HttpPutTest.php | 111 ++- vendor/sabre/dav/tests/Sabre/DAV/Issue33Test.php | 65 +- .../tests/Sabre/DAV/Locks/Backend/AbstractTest.php | 55 +- .../dav/tests/Sabre/DAV/Locks/Backend/FileTest.php | 21 +- .../tests/Sabre/DAV/Locks/Backend/PDOMySQLTest.php | 7 +- .../dav/tests/Sabre/DAV/Locks/Backend/PDOTest.php | 12 +- .../sabre/dav/tests/Sabre/DAV/Locks/MSWordTest.php | 60 +- .../sabre/dav/tests/Sabre/DAV/Locks/PluginTest.php | 497 +++++--------- .../sabre/dav/tests/Sabre/DAV/Mock/Collection.php | 73 +- vendor/sabre/dav/tests/Sabre/DAV/Mock/File.php | 84 +-- .../sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php | 36 +- .../sabre/dav/tests/Sabre/DAV/ObjectTreeTest.php | 102 ++- .../dav/tests/Sabre/DAV/PartialUpdate/FileMock.php | 79 +-- .../tests/Sabre/DAV/PartialUpdate/PluginTest.php | 73 +- .../Sabre/DAV/PartialUpdate/SpecificationTest.php | 40 +- .../sabre/dav/tests/Sabre/DAV/ServerEventsTest.php | 68 +- .../sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php | 151 ++--- .../sabre/dav/tests/Sabre/DAV/ServerPluginTest.php | 73 +- .../dav/tests/Sabre/DAV/ServerPreconditionTest.php | 211 ++---- .../sabre/dav/tests/Sabre/DAV/ServerPropsTest.php | 108 ++- .../sabre/dav/tests/Sabre/DAV/ServerRangeTest.php | 150 ++-- .../sabre/dav/tests/Sabre/DAV/ServerSimpleTest.php | 262 +++---- .../tests/Sabre/DAV/ServerUpdatePropertiesTest.php | 57 +- .../sabre/dav/tests/Sabre/DAV/SimpleFileTest.php | 14 +- .../sabre/dav/tests/Sabre/DAV/StringUtilTest.php | 56 +- .../tests/Sabre/DAV/TemporaryFileFilterTest.php | 85 +-- vendor/sabre/dav/tests/Sabre/DAV/TestPlugin.php | 32 +- vendor/sabre/dav/tests/Sabre/DAV/TreeTest.php | 162 ++--- vendor/sabre/dav/tests/Sabre/DAV/UUIDUtilTest.php | 13 +- .../sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php | 86 ++- .../dav/tests/Sabre/DAVACL/AllowAccessTest.php | 88 ++- .../dav/tests/Sabre/DAVACL/BlockAccessTest.php | 131 ++-- .../Sabre/DAVACL/Exception/AceConflictTest.php | 18 +- .../Exception/NeedPrivilegesExceptionTest.php | 28 +- .../Sabre/DAVACL/Exception/NoAbstractTest.php | 18 +- .../Exception/NotRecognizedPrincipalTest.php | 18 +- .../DAVACL/Exception/NotSupportedPrivilegeTest.php | 18 +- .../tests/Sabre/DAVACL/ExpandPropertiesTest.php | 185 +++-- .../sabre/dav/tests/Sabre/DAVACL/MockACLNode.php | 42 +- .../sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php | 46 +- .../dav/tests/Sabre/DAVACL/PluginAdminTest.php | 28 +- .../tests/Sabre/DAVACL/PluginPropertiesTest.php | 118 ++-- .../Sabre/DAVACL/PluginUpdatePropertiesTest.php | 37 +- .../DAVACL/PrincipalBackend/AbstractPDOTest.php | 107 ++- .../tests/Sabre/DAVACL/PrincipalBackend/Mock.php | 107 ++- .../Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php | 7 +- .../DAVACL/PrincipalBackend/PDOSqliteTest.php | 7 +- .../tests/Sabre/DAVACL/PrincipalCollectionTest.php | 28 +- .../Sabre/DAVACL/PrincipalPropertySearchTest.php | 170 +++-- .../DAVACL/PrincipalSearchPropertySetTest.php | 62 +- .../sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php | 112 ++- .../dav/tests/Sabre/DAVACL/SimplePluginTest.php | 122 ++-- vendor/sabre/dav/tests/Sabre/DAVServerTest.php | 70 +- vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php | 9 +- vendor/sabre/dav/tests/Sabre/TestUtil.php | 55 +- vendor/sabre/dav/tests/bootstrap.php | 49 +- 130 files changed, 4900 insertions(+), 5870 deletions(-) (limited to 'vendor/sabre/dav/tests') diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php index 406dbe0e8..80de750dc 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php @@ -1,5 +1,7 @@ dropTables([ 'calendarobjects', 'calendars', @@ -26,72 +28,66 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->createSchema('calendars'); $this->pdo = $this->getDb(); - } - function testConstruct() { - + public function testConstruct() + { $backend = new PDO($this->pdo); $this->assertTrue($backend instanceof PDO); - } /** * @depends testConstruct */ - function testGetCalendarsForUserNoCalendars() { - + public function testGetCalendarsForUserNoCalendars() + { $backend = new PDO($this->pdo); $calendars = $backend->getCalendarsForUser('principals/user2'); $this->assertEquals([], $calendars); - } /** * @depends testConstruct */ - function testCreateCalendarAndFetch() { - + public function testCreateCalendarAndFetch() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', - '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), + '{DAV:}displayname' => 'Hello!', + '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]); $calendars = $backend->getCalendarsForUser('principals/user2'); $elementCheck = [ - 'uri' => 'somerandomid', - '{DAV:}displayname' => 'Hello!', - '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', + 'uri' => 'somerandomid', + '{DAV:}displayname' => 'Hello!', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, ]; $this->assertInternalType('array', $calendars); $this->assertEquals(1, count($calendars)); foreach ($elementCheck as $name => $value) { - $this->assertArrayHasKey($name, $calendars[0]); $this->assertEquals($value, $calendars[0][$name]); - } - } /** * @depends testConstruct */ - function testUpdateCalendarAndFetch() { - + public function testUpdateCalendarAndFetch() + { $backend = new PDO($this->pdo); //Creating a new calendar $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); $propPatch = new PropPatch([ - '{DAV:}displayname' => 'myCalendar', + '{DAV:}displayname' => 'myCalendar', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]); @@ -107,12 +103,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Checking if all the information is still correct $elementCheck = [ - 'id' => $newId, - 'uri' => 'somerandomid', - '{DAV:}displayname' => 'myCalendar', - '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '', - '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/2', + 'id' => $newId, + 'uri' => 'somerandomid', + '{DAV:}displayname' => 'myCalendar', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '', + '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/2', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]; @@ -120,40 +116,36 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(1, count($calendars)); foreach ($elementCheck as $name => $value) { - $this->assertArrayHasKey($name, $calendars[0]); $this->assertEquals($value, $calendars[0][$name]); - } - } /** * @depends testConstruct * @expectedException \InvalidArgumentException */ - function testUpdateCalendarBadId() { - + public function testUpdateCalendarBadId() + { $backend = new PDO($this->pdo); //Creating a new calendar $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); $propPatch = new PropPatch([ - '{DAV:}displayname' => 'myCalendar', + '{DAV:}displayname' => 'myCalendar', '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), ]); // Updating the calendar $backend->updateCalendar('raaaa', $propPatch); - } /** * @depends testUpdateCalendarAndFetch */ - function testUpdateCalendarUnknownProperty() { - + public function testUpdateCalendarUnknownProperty() + { $backend = new PDO($this->pdo); //Creating a new calendar @@ -161,7 +153,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $propPatch = new PropPatch([ '{DAV:}displayname' => 'myCalendar', - '{DAV:}yourmom' => 'wittycomment', + '{DAV:}yourmom' => 'wittycomment', ]); // Updating the calendar @@ -170,63 +162,59 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Verifying the result of the update $this->assertEquals([ - '{DAV:}yourmom' => 403, + '{DAV:}yourmom' => 403, '{DAV:}displayname' => 424, ], $propPatch->getResult()); - } /** * @depends testCreateCalendarAndFetch */ - function testDeleteCalendar() { - + public function testDeleteCalendar() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', + '{DAV:}displayname' => 'Hello!', ]); $backend->deleteCalendar($returnedId); $calendars = $backend->getCalendarsForUser('principals/user2'); $this->assertEquals([], $calendars); - } /** * @depends testCreateCalendarAndFetch * @expectedException \InvalidArgumentException */ - function testDeleteCalendarBadID() { - + public function testDeleteCalendarBadID() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', + '{DAV:}displayname' => 'Hello!', ]); $backend->deleteCalendar('bad-id'); - } /** * @depends testCreateCalendarAndFetch * @expectedException \Sabre\DAV\Exception */ - function testCreateCalendarIncorrectComponentSet() {; - + public function testCreateCalendarIncorrectComponentSet() + { $backend = new PDO($this->pdo); //Creating a new calendar $newId = $backend->createCalendar('principals/user2', 'somerandomid', [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => 'blabla', ]); - } - function testCreateCalendarObject() { - + public function testCreateCalendarObject() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -242,17 +230,17 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('20120101'), - 'lastoccurence' => strtotime('20120101') + (3600 * 24), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('20120101') + (3600 * 24), + 'componenttype' => 'VEVENT', ], $row); - } - function testGetMultipleObjects() { + public function testGetMultipleObjects() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -263,18 +251,18 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $check = [ [ - 'id' => 1, - 'etag' => '"' . md5($object) . '"', - 'uri' => 'id-1', - 'size' => strlen($object), + 'id' => 1, + 'etag' => '"'.md5($object).'"', + 'uri' => 'id-1', + 'size' => strlen($object), 'calendardata' => $object, 'lastmodified' => null, ], [ - 'id' => 2, - 'etag' => '"' . md5($object) . '"', - 'uri' => 'id-2', - 'size' => strlen($object), + 'id' => 2, + 'etag' => '"'.md5($object).'"', + 'uri' => 'id-2', + 'size' => strlen($object), 'calendardata' => $object, 'lastmodified' => null, ], @@ -283,62 +271,54 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getMultipleCalendarObjects($returnedId, ['id-1', 'id-2']); foreach ($check as $index => $props) { - foreach ($props as $key => $expected) { - $actual = $result[$index][$key]; switch ($key) { - case 'lastmodified' : + case 'lastmodified': $this->assertInternalType('int', $actual); break; - case 'calendardata' : + case 'calendardata': if (is_resource($actual)) { $actual = stream_get_contents($actual); } // no break intentional - default : + default: $this->assertEquals($expected, $actual); - } - } - } - } /** * @depends testGetMultipleObjects * @expectedException \InvalidArgumentException */ - function testGetMultipleObjectsBadId() { - + public function testGetMultipleObjectsBadId() + { $backend = new PDO($this->pdo); $backend->getMultipleCalendarObjects('bad-id', ['foo-bar']); - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest * @depends testCreateCalendarObject */ - function testCreateCalendarObjectNoComponent() { - + public function testCreateCalendarObjectNoComponent() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); $object = "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nEND:VCALENDAR\r\n"; $backend->createCalendarObject($returnedId, 'random-id', $object); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectDuration() { - + public function testCreateCalendarObjectDuration() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -354,37 +334,34 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('20120101'), - 'lastoccurence' => strtotime('20120101') + (3600 * 48), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('20120101') + (3600 * 48), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject * @expectedException \InvalidArgumentException */ - function testCreateCalendarObjectBadId() { - + public function testCreateCalendarObjectBadId() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; $backend->createCalendarObject('bad-id', 'random-id', $object); - } - /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectNoDTEND() { - + public function testCreateCalendarObjectNoDTEND() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -399,21 +376,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 10:00:00'), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('2012-01-01 10:00:00'), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectWithDTEND() { - + public function testCreateCalendarObjectWithDTEND() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -428,21 +404,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 11:00:00'), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('2012-01-01 11:00:00'), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectInfiniteRecurrence() { - + public function testCreateCalendarObjectInfiniteRecurrence() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -457,21 +432,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime(PDO::MAX_DATE), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime(PDO::MAX_DATE), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectEndingRecurrence() { - + public function testCreateCalendarObjectEndingRecurrence() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -486,21 +460,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999), - 'componenttype' => 'VEVENT', + 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999), + 'componenttype' => 'VEVENT', ], $row); - } /** * @depends testCreateCalendarObject */ - function testCreateCalendarObjectTask() { - + public function testCreateCalendarObjectTask() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -515,21 +488,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, + 'etag' => md5($object), + 'size' => strlen($object), + 'calendardata' => $object, 'firstoccurence' => null, - 'lastoccurence' => null, - 'componenttype' => 'VTODO', + 'lastoccurence' => null, + 'componenttype' => 'VTODO', ], $row); - } /** * @depends testCreateCalendarObject */ - function testGetCalendarObjects() { - + public function testGetCalendarObjects() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -543,36 +515,33 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('random-id', $data['uri']); $this->assertEquals(strlen($object), $data['size']); - } /** * @depends testGetCalendarObjects * @expectedException \InvalidArgumentException */ - function testGetCalendarObjectsBadId() { - + public function testGetCalendarObjectsBadId() + { $backend = new PDO($this->pdo); $backend->getCalendarObjects('bad-id'); - } /** * @depends testGetCalendarObjects * @expectedException \InvalidArgumentException */ - function testGetCalendarObjectBadId() { - + public function testGetCalendarObjectBadId() + { $backend = new PDO($this->pdo); $backend->getCalendarObject('bad-id', 'foo-bar'); - } /** * @depends testCreateCalendarObject */ - function testGetCalendarObjectByUID() { - + public function testGetCalendarObjectByUID() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -586,14 +555,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { 'somerandomid/random-id', $backend->getCalendarObjectByUID('principals/user2', 'foo') ); - } /** * @depends testCreateCalendarObject */ - function testUpdateCalendarObject() { - + public function testUpdateCalendarObject() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -610,26 +578,23 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($object2, $data['calendardata']); $this->assertEquals('random-id', $data['uri']); - - } /** * @depends testUpdateCalendarObject * @expectedException \InvalidArgumentException */ - function testUpdateCalendarObjectBadId() { - + public function testUpdateCalendarObjectBadId() + { $backend = new PDO($this->pdo); $backend->updateCalendarObject('bad-id', 'object-id', 'objectdata'); - } /** * @depends testCreateCalendarObject */ - function testDeleteCalendarObject() { - + public function testDeleteCalendarObject() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); @@ -639,222 +604,215 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $data = $backend->getCalendarObject($returnedId, 'random-id'); $this->assertNull($data); - } /** * @depends testDeleteCalendarObject * @expectedException \InvalidArgumentException */ - function testDeleteCalendarObjectBadId() { - + public function testDeleteCalendarObjectBadId() + { $backend = new PDO($this->pdo); $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; $backend->createCalendarObject($returnedId, 'random-id', $object); $backend->deleteCalendarObject('bad-id', 'random-id'); - } - function testCalendarQueryNoResult() { - + public function testCalendarQueryNoResult() + { $abstract = new PDO($this->pdo); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ ], $abstract->calendarQuery([1, 1], $filters)); - } /** * @expectedException \InvalidArgumentException * @depends testCalendarQueryNoResult */ - function testCalendarQueryBadId() { - + public function testCalendarQueryBadId() + { $abstract = new PDO($this->pdo); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $abstract->calendarQuery('bad-id', $filters); - } - function testCalendarQueryTodo() { - + public function testCalendarQueryTodo() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VTODO', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VTODO', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ - "todo", + 'todo', ], $backend->calendarQuery([1, 1], $filters)); - } - function testCalendarQueryTodoNotMatch() { + public function testCalendarQueryTodoNotMatch() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VTODO', + 'name' => 'VTODO', 'comp-filters' => [], 'prop-filters' => [ [ - 'name' => 'summary', - 'text-match' => null, - 'time-range' => null, - 'param-filters' => [], + 'name' => 'summary', + 'text-match' => null, + 'time-range' => null, + 'param-filters' => [], 'is-not-defined' => false, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ ], $backend->calendarQuery([1, 1], $filters)); - } - function testCalendarQueryNoFilter() { - + public function testCalendarQueryNoFilter() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VCALENDAR', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $result = $backend->calendarQuery([1, 1], $filters); $this->assertTrue(in_array('todo', $result)); $this->assertTrue(in_array('event', $result)); - } - function testCalendarQueryTimeRange() { - + public function testCalendarQueryTimeRange() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('20120103'), - 'end' => new \DateTime('20120104'), + 'end' => new \DateTime('20120104'), ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ - "event2", + 'event2', ], $backend->calendarQuery([1, 1], $filters)); - } - function testCalendarQueryTimeRangeNoEnd() { + public function testCalendarQueryTimeRangeNoEnd() + { $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], "todo", "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], "event2", "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); + $backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('20120102'), - 'end' => null, + 'end' => null, ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ - "event2", + 'event2', ], $backend->calendarQuery([1, 1], $filters)); - } - function testGetChanges() { - + public function testGetChanges() + { $backend = new PDO($this->pdo); $id = $backend->createCalendar( 'principals/user1', @@ -865,37 +823,37 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'syncToken' => 1, - 'modified' => [], - 'deleted' => [], - 'added' => [], + 'modified' => [], + 'deleted' => [], + 'added' => [], ], $result); $currentToken = $result['syncToken']; $dummyTodo = "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"; - $backend->createCalendarObject($id, "todo1.ics", $dummyTodo); - $backend->createCalendarObject($id, "todo2.ics", $dummyTodo); - $backend->createCalendarObject($id, "todo3.ics", $dummyTodo); - $backend->updateCalendarObject($id, "todo1.ics", $dummyTodo); - $backend->deleteCalendarObject($id, "todo2.ics"); + $backend->createCalendarObject($id, 'todo1.ics', $dummyTodo); + $backend->createCalendarObject($id, 'todo2.ics', $dummyTodo); + $backend->createCalendarObject($id, 'todo3.ics', $dummyTodo); + $backend->updateCalendarObject($id, 'todo1.ics', $dummyTodo); + $backend->deleteCalendarObject($id, 'todo2.ics'); $result = $backend->getChangesForCalendar($id, $currentToken, 1); $this->assertEquals([ 'syncToken' => 6, - 'modified' => ["todo1.ics"], - 'deleted' => ["todo2.ics"], - 'added' => ["todo3.ics"], + 'modified' => ['todo1.ics'], + 'deleted' => ['todo2.ics'], + 'added' => ['todo3.ics'], ], $result); $result = $backend->getChangesForCalendar($id, null, 1); $this->assertEquals([ 'syncToken' => 6, - 'modified' => [], - 'deleted' => [], - 'added' => ["todo1.ics", "todo3.ics"], + 'modified' => [], + 'deleted' => [], + 'added' => ['todo1.ics', 'todo3.ics'], ], $result); } @@ -903,8 +861,8 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { * @depends testGetChanges * @expectedException \InvalidArgumentException */ - function testGetChangesBadId() { - + public function testGetChangesBadId() + { $backend = new PDO($this->pdo); $id = $backend->createCalendar( 'principals/user1', @@ -912,16 +870,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { [] ); $backend->getChangesForCalendar('bad-id', null, 1); - } - function testCreateSubscriptions() { - + public function testCreateSubscriptions() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -944,29 +901,27 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { foreach ($expected as $k => $v) { $this->assertEquals($subs[0][$k], $expected[$k]); } - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateSubscriptionFail() { - + public function testCreateSubscriptionFail() + { $props = [ ]; $backend = new PDO($this->pdo); $backend->createSubscription('principals/user1', 'sub1', $props); - } - function testUpdateSubscriptions() { - + public function testUpdateSubscriptions() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -976,7 +931,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createSubscription('principals/user1', 'sub1', $props); $newProps = [ - '{DAV:}displayname' => 'new displayname', + '{DAV:}displayname' => 'new displayname', '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), ]; @@ -1000,16 +955,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { foreach ($expected as $k => $v) { $this->assertEquals($subs[0][$k], $expected[$k]); } - } - function testUpdateSubscriptionsFail() { - + public function testUpdateSubscriptionsFail() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -1019,29 +973,28 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createSubscription('principals/user1', 'sub1', $props); $propPatch = new DAV\PropPatch([ - '{DAV:}displayname' => 'new displayname', + '{DAV:}displayname' => 'new displayname', '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), - '{DAV:}unknown' => 'foo', + '{DAV:}unknown' => 'foo', ]); $backend->updateSubscription(1, $propPatch); $propPatch->commit(); $this->assertEquals([ - '{DAV:}unknown' => 403, - '{DAV:}displayname' => 424, + '{DAV:}unknown' => 403, + '{DAV:}displayname' => 424, '{http://calendarserver.org/ns/}source' => 424, ], $propPatch->getResult()); - } - function testDeleteSubscriptions() { - + public function testDeleteSubscriptions() + { $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', + '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), + '{DAV:}displayname' => 'cal', + '{http://apple.com/ns/ical/}refreshrate' => 'P1W', + '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, @@ -1051,7 +1004,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend->createSubscription('principals/user1', 'sub1', $props); $newProps = [ - '{DAV:}displayname' => 'new displayname', + '{DAV:}displayname' => 'new displayname', '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), ]; @@ -1061,8 +1014,8 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(0, count($subs)); } - function testSchedulingMethods() { - + public function testSchedulingMethods() + { $backend = new PDO($this->pdo); $calData = "BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"; @@ -1075,9 +1028,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ 'calendardata' => $calData, - 'uri' => 'schedule1.ics', - 'etag' => '"' . md5($calData) . '"', - 'size' => strlen($calData) + 'uri' => 'schedule1.ics', + 'etag' => '"'.md5($calData).'"', + 'size' => strlen($calData), ]; $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics'); @@ -1104,11 +1057,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics'); $this->assertNull($result); - } - function testGetInvites() { - + public function testGetInvites() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1118,23 +1070,22 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getInvites($calendar['id']); $expected = [ new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]) + ]), ]; $this->assertEquals($expected, $result); - } /** * @depends testGetInvites * @expectedException \InvalidArgumentException */ - function testGetInvitesBadId() { - + public function testGetInvitesBadId() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1142,14 +1093,13 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $backend->getInvites('bad-id'); - } /** * @depends testCreateCalendarAndFetch */ - function testUpdateInvites() { - + public function testUpdateInvites() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1157,9 +1107,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]); @@ -1168,12 +1118,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]) + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]), ] ); @@ -1181,26 +1131,26 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ $ownerSharee, new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => [ + 'properties' => [ '{DAV:}displayname' => 'User 2', ], - ]) + ]), ]; $this->assertEquals($expected, $result); // Checking calendar_instances too $expectedCalendar = [ - 'id' => [1,2], - 'principaluri' => 'principals/user2', + 'id' => [1, 2], + 'principaluri' => 'principals/user2', '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', - '{http://sabredav.org/ns}sync-token' => '1', - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'read-only' => true, - 'share-resource-uri' => '/ns/share/1', + '{http://sabredav.org/ns}sync-token' => '1', + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'read-only' => true, + 'share-resource-uri' => '/ns/share/1', ]; $calendars = $backend->getCalendarsForUser('principals/user2'); @@ -1208,21 +1158,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( $v, $calendars[0][$k], - "Key " . $k . " in calendars array did not have the expected value." + 'Key '.$k.' in calendars array did not have the expected value.' ); } - // Updating an invite $backend->updateInvites( $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]) + ]), ] ); @@ -1230,14 +1179,14 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ $ownerSharee, new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => [ + 'properties' => [ '{DAV:}displayname' => 'User 2', ], - ]) + ]), ]; $this->assertEquals($expected, $result); @@ -1246,15 +1195,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', + 'href' => 'mailto:user@example.org', 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, - ]) + ]), ] ); $result = $backend->getInvites($calendar['id']); $expected = [ - $ownerSharee + $ownerSharee, ]; $this->assertEquals($expected, $result); @@ -1263,45 +1212,43 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'principals/user2', + 'href' => 'principals/user2', 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, - ]) + ]), ] ); $result = $backend->getInvites($calendar['id']); $expected = [ new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]), ]; $this->assertEquals($expected, $result); - } /** * @depends testUpdateInvites * @expectedException \InvalidArgumentException */ - function testUpdateInvitesBadId() { - + public function testUpdateInvitesBadId() + { $backend = new PDO($this->pdo); // Add a new invite $backend->updateInvites( 'bad-id', [] ); - } /** * @depends testUpdateInvites */ - function testUpdateInvitesNoPrincipal() { - + public function testUpdateInvitesNoPrincipal() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1309,9 +1256,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]); @@ -1320,12 +1267,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => null, - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => null, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]) + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]), ] ); @@ -1333,24 +1280,23 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ $ownerSharee, new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => null, - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => null, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_INVALID, - 'properties' => [ + 'properties' => [ '{DAV:}displayname' => 'User 2', ], - ]) + ]), ]; $this->assertEquals($expected, $result, null, 0.0, 10, true); // Last argument is $canonicalize = true, which allows us to compare, ignoring the order, because it's different between MySQL and Sqlite. - } /** * @depends testUpdateInvites */ - function testDeleteSharedCalendar() { - + public function testDeleteSharedCalendar() + { $backend = new PDO($this->pdo); // creating a new calendar @@ -1358,9 +1304,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar = $backend->getCalendarsForUser('principals/user1')[0]; $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]); @@ -1369,23 +1315,23 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $calendar['id'], [ new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'href' => 'mailto:user@example.org', + 'principal' => 'principals/user2', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]) + 'properties' => ['{DAV:}displayname' => 'User 2'], + ]), ] ); $expectedCalendar = [ - 'id' => [1,2], - 'principaluri' => 'principals/user2', + 'id' => [1, 2], + 'principaluri' => 'principals/user2', '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', - '{http://sabredav.org/ns}sync-token' => '1', - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'read-only' => true, - 'share-resource-uri' => '/ns/share/1', + '{http://sabredav.org/ns}sync-token' => '1', + 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, + 'read-only' => true, + 'share-resource-uri' => '/ns/share/1', ]; $calendars = $backend->getCalendarsForUser('principals/user2'); @@ -1393,7 +1339,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( $v, $calendars[0][$k], - "Key " . $k . " in calendars array did not have the expected value." + 'Key '.$k.' in calendars array did not have the expected value.' ); } @@ -1408,24 +1354,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->getInvites($calendar['id']); $expected = [ new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, + 'href' => 'principals/user1', + 'principal' => 'principals/user1', + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, ]), ]; $this->assertEquals($expected, $result); - } /** * @expectedException \Sabre\DAV\Exception\NotImplemented */ - function testSetPublishStatus() { - + public function testSetPublishStatus() + { $backend = new PDO($this->pdo); $backend->setPublishStatus([1, 1], true); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php index 7f642efc9..166de1dab 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php @@ -1,14 +1,16 @@ 'anything']); @@ -16,36 +18,34 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $result = $propPatch->commit(); $this->assertFalse($result); - } - function testCalendarQuery() { - + public function testCalendarQuery() + { $abstract = new AbstractMock(); $filters = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $this->assertEquals([ 'event1.ics', ], $abstract->calendarQuery(1, $filters)); - } - function testGetCalendarObjectByUID() { - + public function testGetCalendarObjectByUID() + { $abstract = new AbstractMock(); $this->assertNull( $abstract->getCalendarObjectByUID('principal1', 'zim') @@ -60,11 +60,10 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $this->assertNull( $abstract->getCalendarObjectByUID('principal1', 'shared') ); - } - function testGetMultipleCalendarObjects() { - + public function testGetMultipleCalendarObjects() + { $abstract = new AbstractMock(); $result = $abstract->getMultipleCalendarObjects(1, [ 'event1.ics', @@ -73,106 +72,113 @@ class AbstractTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', + 'id' => 1, + 'calendarid' => 1, + 'uri' => 'event1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", ], [ - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', + 'id' => 2, + 'calendarid' => 1, + 'uri' => 'task1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", ], ]; $this->assertEquals($expected, $result); - - } - } -class AbstractMock extends AbstractBackend { - - function getCalendarsForUser($principalUri) { - +class AbstractMock extends AbstractBackend +{ + public function getCalendarsForUser($principalUri) + { return [ [ - 'id' => 1, + 'id' => 1, 'principaluri' => 'principal1', - 'uri' => 'cal1', + 'uri' => 'cal1', ], [ - 'id' => 2, - 'principaluri' => 'principal1', + 'id' => 2, + 'principaluri' => 'principal1', '{http://sabredav.org/ns}owner-principal' => 'principal2', - 'uri' => 'cal1', + 'uri' => 'cal1', ], ]; + } + + public function createCalendar($principalUri, $calendarUri, array $properties) + { + } + public function deleteCalendar($calendarId) + { } - function createCalendar($principalUri, $calendarUri, array $properties) { } - function deleteCalendar($calendarId) { } - function getCalendarObjects($calendarId) { + public function getCalendarObjects($calendarId) + { switch ($calendarId) { case 1: return [ [ - 'id' => 1, + 'id' => 1, 'calendarid' => 1, - 'uri' => 'event1.ics', + 'uri' => 'event1.ics', ], [ - 'id' => 2, + 'id' => 2, 'calendarid' => 1, - 'uri' => 'task1.ics', + 'uri' => 'task1.ics', ], ]; case 2: return [ [ - 'id' => 3, + 'id' => 3, 'calendarid' => 2, - 'uri' => 'shared-event.ics', - ] + 'uri' => 'shared-event.ics', + ], ]; } - } - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { switch ($objectUri) { - - case 'event1.ics' : + case 'event1.ics': return [ - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', + 'id' => 1, + 'calendarid' => 1, + 'uri' => 'event1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", ]; - case 'task1.ics' : + case 'task1.ics': return [ - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', + 'id' => 2, + 'calendarid' => 1, + 'uri' => 'task1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", ]; - case 'shared-event.ics' : + case 'shared-event.ics': return [ - 'id' => 3, - 'calendarid' => 2, - 'uri' => 'event1.ics', + 'id' => 3, + 'calendarid' => 2, + 'uri' => 'event1.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:shared\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", ]; - } + } + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { } - function createCalendarObject($calendarId, $objectUri, $calendarData) { } - function updateCalendarObject($calendarId, $objectUri, $calendarData) { } - function deleteCalendarObject($calendarId, $objectUri) { } + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { + } + + public function deleteCalendarObject($calendarId, $objectUri) + { + } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php index cc665cd8f..9f18eeb72 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php @@ -1,17 +1,19 @@ calendars = $calendars; $this->calendarData = $calendarData; - } /** @@ -38,10 +39,11 @@ class Mock extends AbstractBackend { * common one is '{DAV:}displayname'. * * @param string $principalUri + * * @return array */ - function getCalendarsForUser($principalUri) { - + public function getCalendarsForUser($principalUri) + { $r = []; foreach ($this->calendars as $row) { if ($row['principaluri'] == $principalUri) { @@ -50,7 +52,6 @@ class Mock extends AbstractBackend { } return $r; - } /** @@ -64,21 +65,21 @@ class Mock extends AbstractBackend { * * @param string $principalUri * @param string $calendarUri - * @param array $properties + * @param array $properties + * * @return string|int */ - function createCalendar($principalUri, $calendarUri, array $properties) { - + public function createCalendar($principalUri, $calendarUri, array $properties) + { $id = DAV\UUIDUtil::getUUID(); $this->calendars[] = array_merge([ - 'id' => $id, - 'principaluri' => $principalUri, - 'uri' => $calendarUri, - '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), + 'id' => $id, + 'principaluri' => $principalUri, + 'uri' => $calendarUri, + '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), ], $properties); return $id; - } /** @@ -93,16 +94,13 @@ class Mock extends AbstractBackend { * * Read the PropPatch documentation for more info and examples. * - * @param mixed $calendarId + * @param mixed $calendarId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) { - - $propPatch->handleRemaining(function($props) use ($calendarId) { - + public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) + { + $propPatch->handleRemaining(function ($props) use ($calendarId) { foreach ($this->calendars as $k => $calendar) { - if ($calendar['id'] === $calendarId) { foreach ($props as $propName => $propValue) { if (is_null($propValue)) { @@ -111,30 +109,25 @@ class Mock extends AbstractBackend { $this->calendars[$k][$propName] = $propValue; } } - return true; + return true; } - } - }); - } /** - * Delete a calendar and all it's objects + * Delete a calendar and all it's objects. * * @param string $calendarId - * @return void */ - function deleteCalendar($calendarId) { - + public function deleteCalendar($calendarId) + { foreach ($this->calendars as $k => $calendar) { if ($calendar['id'] === $calendarId) { unset($this->calendars[$k]); } } - } /** @@ -157,12 +150,14 @@ class Mock extends AbstractBackend { * calendardata. * * @param string $calendarId + * * @return array */ - function getCalendarObjects($calendarId) { - - if (!isset($this->calendarData[$calendarId])) + public function getCalendarObjects($calendarId) + { + if (!isset($this->calendarData[$calendarId])) { return []; + } $objects = $this->calendarData[$calendarId]; @@ -171,8 +166,8 @@ class Mock extends AbstractBackend { $object['uri'] = $uri; $object['lastmodified'] = null; } - return $objects; + return $objects; } /** @@ -187,12 +182,13 @@ class Mock extends AbstractBackend { * * This method must return null if the object did not exist. * - * @param mixed $calendarId + * @param mixed $calendarId * @param string $objectUri + * * @return array|null */ - function getCalendarObject($calendarId, $objectUri) { - + public function getCalendarObject($calendarId, $objectUri) + { if (!isset($this->calendarData[$calendarId][$objectUri])) { return null; } @@ -200,8 +196,8 @@ class Mock extends AbstractBackend { $object['calendarid'] = $calendarId; $object['uri'] = $objectUri; $object['lastmodified'] = null; - return $object; + return $object; } /** @@ -210,17 +206,16 @@ class Mock extends AbstractBackend { * @param string $calendarId * @param string $objectUri * @param string $calendarData - * @return void */ - function createCalendarObject($calendarId, $objectUri, $calendarData) { - + public function createCalendarObject($calendarId, $objectUri, $calendarData) + { $this->calendarData[$calendarId][$objectUri] = [ 'calendardata' => $calendarData, - 'calendarid' => $calendarId, - 'uri' => $objectUri, + 'calendarid' => $calendarId, + 'uri' => $objectUri, ]; - return '"' . md5($calendarData) . '"'; + return '"'.md5($calendarData).'"'; } /** @@ -229,17 +224,16 @@ class Mock extends AbstractBackend { * @param string $calendarId * @param string $objectUri * @param string $calendarData - * @return void */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) { - + public function updateCalendarObject($calendarId, $objectUri, $calendarData) + { $this->calendarData[$calendarId][$objectUri] = [ 'calendardata' => $calendarData, - 'calendarid' => $calendarId, - 'uri' => $objectUri, + 'calendarid' => $calendarId, + 'uri' => $objectUri, ]; - return '"' . md5($calendarData) . '"'; + return '"'.md5($calendarData).'"'; } /** @@ -247,12 +241,9 @@ class Mock extends AbstractBackend { * * @param string $calendarId * @param string $objectUri - * @return void */ - function deleteCalendarObject($calendarId, $objectUri) { - + public function deleteCalendarObject($calendarId, $objectUri) + { unset($this->calendarData[$calendarId][$objectUri]); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php index e068ff1e7..66388def4 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ backend = TestUtil::getBackend(); $calendars = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals(2, count($calendars)); $this->calendar = new Calendar($this->backend, $calendars[0]); - } - function teardown() { - + public function teardown() + { unset($this->calendar); unset($this->backend); - } - function testSetup() { - + public function testSetup() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -42,54 +42,50 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $this->assertInternalType('string', $children[0]->get()); $this->assertInternalType('string', $children[0]->getETag()); $this->assertEquals('text/calendar; charset=utf-8', $children[0]->getContentType()); - } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ - function testInvalidArg1() { - + public function testInvalidArg1() + { $obj = new CalendarObject( new Backend\Mock([], []), [], [] ); - } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ - function testInvalidArg2() { - + public function testInvalidArg2() + { $obj = new CalendarObject( new Backend\Mock([], []), [], ['calendarid' => '1'] ); - } /** * @depends testSetup */ - function testPut() { - + public function testPut() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $newData = TestUtil::getTestCalendarData(); $children[0]->put($newData); $this->assertEquals($newData, $children[0]->get()); - } /** * @depends testSetup */ - function testPutStream() { - + public function testPutStream() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $newData = TestUtil::getTestCalendarData(); @@ -99,15 +95,13 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { rewind($stream); $children[0]->put($stream); $this->assertEquals($newData, $children[0]->get()); - } - /** * @depends testSetup */ - function testDelete() { - + public function testDelete() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -116,14 +110,13 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $children2 = $this->calendar->getChildren(); $this->assertEquals(count($children) - 1, count($children2)); - } /** * @depends testSetup */ - function testGetLastModified() { - + public function testGetLastModified() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -131,14 +124,13 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $lastMod = $obj->getLastModified(); $this->assertTrue(is_int($lastMod) || ctype_digit($lastMod) || is_null($lastMod)); - } /** * @depends testSetup */ - function testGetSize() { - + public function testGetSize() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); @@ -146,31 +138,28 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $size = $obj->getSize(); $this->assertInternalType('int', $size); - } - function testGetOwner() { - + public function testGetOwner() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; $this->assertEquals('principals/user1', $obj->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; $this->assertNull($obj->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}read', @@ -204,11 +193,10 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { $obj = $children[0]; $this->assertEquals($expected, $obj->getACL()); - } - function testDefaultACL() { - + public function testDefaultACL() + { $backend = new Backend\Mock([], []); $calendarObject = new CalendarObject($backend, ['principaluri' => 'principals/user1'], ['calendarid' => 1, 'uri' => 'foo']); $expected = [ @@ -229,31 +217,28 @@ class CalendarObjectTest extends \PHPUnit_Framework_TestCase { ], ]; $this->assertEquals($expected, $calendarObject->getACL()); - - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; $obj->setACL([]); - } - function testGet() { - + public function testGet() + { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof CalendarObject); $obj = $children[0]; - $expected = "BEGIN:VCALENDAR + $expected = 'BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Apple Inc.//iCal 4.0.1//EN CALSCALE:GREGORIAN @@ -284,100 +269,91 @@ DTEND;TZID=Asia/Seoul:20100223T070000 ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com SEQUENCE:2 END:VEVENT -END:VCALENDAR"; - - +END:VCALENDAR'; $this->assertEquals($expected, $obj->get()); - } - function testGetRefetch() { - + public function testGetRefetch() + { $backend = new Backend\Mock([], [ 1 => [ 'foo' => [ 'calendardata' => 'foo', - 'uri' => 'foo' + 'uri' => 'foo', ], - ] + ], ]); $obj = new CalendarObject($backend, ['id' => 1], ['uri' => 'foo']); $this->assertEquals('foo', $obj->get()); - } - function testGetEtag1() { - + public function testGetEtag1() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'etag' => 'bar', - 'calendarid' => 1 + 'uri' => 'foo', + 'etag' => 'bar', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals('bar', $obj->getETag()); - } - function testGetEtag2() { - + public function testGetEtag2() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 + 'uri' => 'foo', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); - $this->assertEquals('"' . md5('foo') . '"', $obj->getETag()); - + $this->assertEquals('"'.md5('foo').'"', $obj->getETag()); } - function testGetSupportedPrivilegesSet() { - + public function testGetSupportedPrivilegesSet() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 + 'uri' => 'foo', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertNull($obj->getSupportedPrivilegeSet()); - } - function testGetSize1() { - + public function testGetSize1() + { $objectInfo = [ 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1 + 'uri' => 'foo', + 'calendarid' => 1, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals(3, $obj->getSize()); - } - function testGetSize2() { - + public function testGetSize2() + { $objectInfo = [ - 'uri' => 'foo', + 'uri' => 'foo', 'calendarid' => 1, - 'size' => 4, + 'size' => 4, ]; $backend = new Backend\Mock([], []); $obj = new CalendarObject($backend, [], $objectInfo); $this->assertEquals(4, $obj->getSize()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php index ca06d8ffa..660832ba4 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php @@ -1,17 +1,19 @@ createComponent('VEVENT'); @@ -23,29 +25,28 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $valarm->TRIGGER = '-P15D'; $vevent->add($valarm); - $vcalendar->add($vevent); $filter = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'prop-filters' => [], - 'comp-filters' => [], - 'time-range' => [ + 'prop-filters' => [], + 'comp-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2012-05-10'), - 'end' => new \DateTime('2012-05-20'), + 'end' => new \DateTime('2012-05-20'), ], ], ], @@ -73,8 +74,8 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($validator->validate($vcalendar, $filter)); } - function testAlarmWayBefore() { - + public function testAlarmWayBefore() + { $vcalendar = new VObject\Component\VCalendar(); $vevent = $vcalendar->createComponent('VEVENT'); @@ -88,25 +89,25 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $vcalendar->add($vevent); $filter = [ - 'name' => 'VCALENDAR', + 'name' => 'VCALENDAR', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ + 'time-range' => null, + 'prop-filters' => [], + 'comp-filters' => [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'prop-filters' => [], - 'comp-filters' => [], - 'time-range' => [ + 'prop-filters' => [], + 'comp-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-12-10'), - 'end' => new \DateTime('2011-12-20'), + 'end' => new \DateTime('2011-12-20'), ], ], ], @@ -116,7 +117,5 @@ class CalendarQueryVAlarmTest extends \PHPUnit_Framework_TestCase { $validator = new CalendarQueryValidator(); $this->assertTrue($validator->validate($vcalendar, $filter)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php index f3305163b..9dc8ce188 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php @@ -1,13 +1,15 @@ assertFalse($validator->validate($vcal, ['name' => 'VFOO'])); - } /** * @param string $icalObject - * @param array $filters - * @param int $outcome + * @param array $filters + * @param int $outcome * @dataProvider provider */ - function testValid($icalObject, $filters, $outcome) { - + public function testValid($icalObject, $filters, $outcome) + { $validator = new CalendarQueryValidator(); // Wrapping filter in a VCALENDAR component filter, as this is always // there anyway. $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [$filters], - 'prop-filters' => [], + 'name' => 'VCALENDAR', + 'comp-filters' => [$filters], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $vObject = VObject\Reader::read($icalObject); switch ($outcome) { - case 0 : + case 0: $this->assertFalse($validator->validate($vObject, $filters)); break; - case 1 : + case 1: $this->assertTrue($validator->validate($vObject, $filters)); break; - case -1 : + case -1: try { $validator->validate($vObject, $filters); $this->fail('This test was supposed to fail'); @@ -62,13 +63,11 @@ ICS; $this->assertTrue(true); } break; - } - } - function provider() { - + public function provider() + { $blob1 = << 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $filter2 = $filter1; $filter2['name'] = 'VTODO'; @@ -415,21 +412,21 @@ yow; $filter5 = $filter1; $filter5['comp-filters'] = [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => null, + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => null, ], ]; $filter6 = $filter1; $filter6['prop-filters'] = [ [ - 'name' => 'SUMMARY', + 'name' => 'SUMMARY', 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => null, - 'text-match' => null, + 'param-filters' => [], + 'time-range' => null, + 'text-match' => null, ], ]; $filter7 = $filter6; @@ -448,13 +445,13 @@ yow; $filter11 = $filter1; $filter11['prop-filters'] = [ [ - 'name' => 'DTSTART', + 'name' => 'DTSTART', 'is-not-defined' => false, - 'param-filters' => [ + 'param-filters' => [ [ - 'name' => 'VALUE', + 'name' => 'VALUE', 'is-not-defined' => false, - 'text-match' => null, + 'text-match' => null, ], ], 'time-range' => null, @@ -474,8 +471,8 @@ yow; // Param text filter $filter15 = $filter11; $filter15['prop-filters'][0]['param-filters'][0]['text-match'] = [ - 'collation' => 'i;ascii-casemap', - 'value' => 'dAtE', + 'collation' => 'i;ascii-casemap', + 'value' => 'dAtE', 'negate-condition' => false, ]; $filter16 = $filter15; @@ -492,13 +489,13 @@ yow; $filter19 = $filter5; $filter19['comp-filters'][0]['prop-filters'] = [ [ - 'name' => 'action', + 'name' => 'action', 'is-not-defined' => false, - 'time-range' => null, - 'param-filters' => [], - 'text-match' => [ - 'collation' => 'i;ascii-casemap', - 'value' => 'display', + 'time-range' => null, + 'param-filters' => [], + 'text-match' => [ + 'collation' => 'i;ascii-casemap', + 'value' => 'display', 'negate-condition' => false, ], ], @@ -506,13 +503,13 @@ yow; // Time range $filter20 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), ], ]; // Time range, no end date @@ -527,102 +524,102 @@ yow; $filter23 = $filter20; $filter23['time-range'] = [ 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), ]; // Time range $filter24 = [ - 'name' => 'VTODO', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VTODO', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), ], ]; // Time range, other dates (1 month in the future) $filter25 = $filter24; $filter25['time-range'] = [ 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), ]; $filter26 = $filter24; $filter26['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), ]; // Time range for VJOURNAL $filter27 = [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VJOURNAL', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), ], ]; $filter28 = $filter27; $filter28['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), ]; // Time range for VFREEBUSY $filter29 = [ - 'name' => 'VFREEBUSY', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VFREEBUSY', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), ], ]; // Time range filter on property $filter30 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'comp-filters' => [], 'prop-filters' => [ [ - 'name' => 'DTSTART', + 'name' => 'DTSTART', 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => [ + 'param-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), ], 'text-match' => null, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; // Time range for alarm $filter31 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'prop-filters' => [], 'comp-filters' => [ [ - 'name' => 'VALARM', + 'name' => 'VALARM', 'is-not-defined' => false, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => [ + 'comp-filters' => [], + 'prop-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 11:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 11:15:00', new \DateTimeZone('GMT')), ], 'text-match' => null, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $filter32 = $filter31; $filter32['comp-filters'][0]['time-range'] = [ 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), ]; $filter33 = $filter31; @@ -636,55 +633,54 @@ yow; // Time range filter on non-datetime property $filter37 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'comp-filters' => [], 'prop-filters' => [ [ - 'name' => 'SUMMARY', + 'name' => 'SUMMARY', 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => [ + 'param-filters' => [], + 'time-range' => [ 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), + 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), ], 'text-match' => null, ], ], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $filter38 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-07-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-08-01 00:00:00', new \DateTimeZone('UTC')), - ] + 'end' => new \DateTime('2012-08-01 00:00:00', new \DateTimeZone('UTC')), + ], ]; $filter39 = [ - 'name' => 'VEVENT', + 'name' => 'VEVENT', 'comp-filters' => [ [ - 'name' => 'VALARM', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VALARM', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-09-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-10-01 00:00:00', new \DateTimeZone('UTC')), - ] + 'end' => new \DateTime('2012-10-01 00:00:00', new \DateTimeZone('UTC')), + ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; return [ - // Component check [$blob1, $filter1, 1], @@ -823,7 +819,5 @@ yow; // Event in timerange, but filtered alarm is in the far future (88). [$blob34, $filter39, 0], ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php index df85b6ded..7d6414a80 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php @@ -1,13 +1,15 @@ backend = TestUtil::getBackend(); $this->calendars = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals(2, count($this->calendars)); $this->calendar = new Calendar($this->backend, $this->calendars[0]); - - } - function teardown() { - + public function teardown() + { unset($this->backend); - } - function testSimple() { - + public function testSimple() + { $this->assertEquals($this->calendars[0]['uri'], $this->calendar->getName()); - } /** * @depends testSimple */ - function testUpdateProperties() { - + public function testUpdateProperties() + { $propPatch = new PropPatch([ '{DAV:}displayname' => 'NewName', ]); @@ -61,87 +59,80 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { $calendars2 = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals('NewName', $calendars2[0]['{DAV:}displayname']); - } /** * @depends testSimple */ - function testGetProperties() { - + public function testGetProperties() + { $question = [ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set', ]; $result = $this->calendar->getProperties($question); - foreach ($question as $q) $this->assertArrayHasKey($q, $result); + foreach ($question as $q) { + $this->assertArrayHasKey($q, $result); + } $this->assertEquals(['VEVENT', 'VTODO'], $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue()); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound * @depends testSimple */ - function testGetChildNotFound() { - + public function testGetChildNotFound() + { $this->calendar->getChild('randomname'); - } /** * @depends testSimple */ - function testGetChildren() { - + public function testGetChildren() + { $children = $this->calendar->getChildren(); $this->assertEquals(1, count($children)); $this->assertTrue($children[0] instanceof CalendarObject); - } /** * @depends testGetChildren */ - function testChildExists() { - + public function testChildExists() + { $this->assertFalse($this->calendar->childExists('foo')); $children = $this->calendar->getChildren(); $this->assertTrue($this->calendar->childExists($children[0]->getName())); } - - /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $this->calendar->createDirectory('hello'); - } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testSetName() { - + public function testSetName() + { $this->calendar->setName('hello'); - } - function testGetLastModified() { - + public function testGetLastModified() + { $this->assertNull($this->calendar->getLastModified()); - } - function testCreateFile() { - + public function testCreateFile() + { $file = fopen('php://memory', 'r+'); fwrite($file, TestUtil::getTestCalendarData()); rewind($file); @@ -150,11 +141,10 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { $file = $this->calendar->getChild('hello'); $this->assertTrue($file instanceof CalendarObject); - } - function testCreateFileNoSupportedComponents() { - + public function testCreateFileNoSupportedComponents() + { $file = fopen('php://memory', 'r+'); fwrite($file, TestUtil::getTestCalendarData()); rewind($file); @@ -164,31 +154,28 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { $file = $calendar->getChild('hello'); $this->assertTrue($file instanceof CalendarObject); - } - function testDelete() { - + public function testDelete() + { $this->calendar->delete(); $calendars = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals(1, count($calendars)); } - function testGetOwner() { - + public function testGetOwner() + { $this->assertEquals('principals/user1', $this->calendar->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $this->assertNull($this->calendar->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}read', @@ -206,7 +193,7 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ], @@ -222,35 +209,29 @@ class CalendarTest extends \PHPUnit_Framework_TestCase { ], ]; $this->assertEquals($expected, $this->calendar->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $this->calendar->setACL([]); - } - function testGetSyncToken() { - + public function testGetSyncToken() + { $this->assertNull($this->calendar->getSyncToken()); - } - function testGetSyncTokenNoSyncSupport() { - + public function testGetSyncTokenNoSyncSupport() + { $calendar = new Calendar(new Backend\Mock([], []), []); $this->assertNull($calendar->getSyncToken()); - } - function testGetChanges() { - + public function testGetChanges() + { $this->assertNull($this->calendar->getChanges(1, 1)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php index 9a3d47828..49252744d 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php @@ -1,29 +1,31 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -52,13 +54,13 @@ END:VCALENDAR ], ]; - function testExpand() { - + public function testExpand() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -91,7 +93,7 @@ END:VCALENDAR try { $vObject = VObject\Reader::read($body); } catch (VObject\ParseException $e) { - $this->fail('Could not parse object. Error:' . $e->getMessage() . ' full object: ' . $response->getBodyAsString()); + $this->fail('Could not parse object. Error:'.$e->getMessage().' full object: '.$response->getBodyAsString()); } // check if DTSTARTs and DTENDs are correct @@ -99,15 +101,14 @@ END:VCALENDAR /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children() as $child) { /** @var $child Sabre\VObject\Property */ - if ($child->name == 'DTSTART') { + if ('DTSTART' == $child->name) { // DTSTART has to be one of three valid values - $this->assertContains($child->getValue(), ['20120207T171500Z', '20120208T171500Z', '20120209T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue()); - } elseif ($child->name == 'DTEND') { + $this->assertContains($child->getValue(), ['20120207T171500Z', '20120208T171500Z', '20120209T171500Z'], 'DTSTART is not a valid value: '.$child->getValue()); + } elseif ('DTEND' == $child->name) { // DTEND has to be one of three valid values - $this->assertContains($child->getValue(), ['20120207T181500Z', '20120208T181500Z', '20120209T181500Z'], 'DTEND is not a valid value: ' . $child->getValue()); + $this->assertContains($child->getValue(), ['20120207T181500Z', '20120208T181500Z', '20120209T181500Z'], 'DTEND is not a valid value: '.$child->getValue()); } } } } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php index efc49673f..3a982fcfa 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php @@ -1,28 +1,30 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -43,13 +45,13 @@ END:VCALENDAR ], ]; - function testExpandRecurringByDayEvent() { - + public function testExpandRecurringByDayEvent() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -88,15 +90,14 @@ END:VCALENDAR /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children() as $child) { /** @var $child Sabre\VObject\Property */ - if ($child->name == 'DTSTART') { + if ('DTSTART' == $child->name) { // DTSTART has to be one of two valid values - $this->assertContains($child->getValue(), ['20120214T171500Z', '20120216T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue()); - } elseif ($child->name == 'DTEND') { + $this->assertContains($child->getValue(), ['20120214T171500Z', '20120216T171500Z'], 'DTSTART is not a valid value: '.$child->getValue()); + } elseif ('DTEND' == $child->name) { // DTEND has to be one of two valid values - $this->assertContains($child->getValue(), ['20120214T181500Z', '20120216T181500Z'], 'DTEND is not a valid value: ' . $child->getValue()); + $this->assertContains($child->getValue(), ['20120214T181500Z', '20120216T181500Z'], 'DTEND is not a valid value: '.$child->getValue()); } } } } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php index 3a22e03d4..90897f1c5 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php @@ -1,5 +1,7 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -54,13 +56,13 @@ END:VCALENDAR ], ]; - function testExpand() { - + public function testExpand() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -93,11 +95,9 @@ END:VCALENDAR $vObject = VObject\Reader::read($body); // We only expect 3 events - $this->assertEquals(3, count($vObject->VEVENT), 'We got 6 events instead of 3. Output: ' . $body); + $this->assertEquals(3, count($vObject->VEVENT), 'We got 6 events instead of 3. Output: '.$body); // TZID should be gone $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID'])); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php index 7604c7f4c..3d4b36313 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php @@ -1,15 +1,14 @@ [ 'obj1' => [ - 'calendarid' => 1, - 'uri' => 'event1.ics', + 'calendarid' => 1, + 'uri' => 'event1.ics', 'calendardata' => $obj1, ], 'obj2' => [ - 'calendarid' => 1, - 'uri' => 'event2.ics', - 'calendardata' => $obj2 + 'calendarid' => 1, + 'uri' => 'event2.ics', + 'calendardata' => $obj2, ], 'obj3' => [ - 'calendarid' => 1, - 'uri' => 'event3.ics', - 'calendardata' => $obj3 - ] + 'calendarid' => 1, + 'uri' => 'event3.ics', + 'calendardata' => $obj3, + ], ], ]; - $caldavBackend = new Backend\Mock([], $calendarData); $calendar = new Calendar($caldavBackend, [ - 'id' => 1, - 'uri' => 'calendar', - 'principaluri' => 'principals/user1', - '{' . Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", + 'id' => 1, + 'uri' => 'calendar', + 'principaluri' => 'principals/user1', + '{'.Plugin::NS_CALDAV.'}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", ]); $this->server = new DAV\Server([$calendar]); - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/calendar', - ]); + $request = new HTTP\Request('GET', '/calendar'); $this->server->httpRequest = $request; $this->server->httpResponse = new HTTP\ResponseMock(); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); - } - function testFreeBusyReport() { - + public function testFreeBusyReport() + { $reportXML = << @@ -108,17 +103,16 @@ XML; $this->assertEquals(200, $this->server->httpResponse->status); $this->assertEquals('text/calendar', $this->server->httpResponse->getHeader('Content-Type')); - $this->assertTrue(strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY') !== false); - $this->assertTrue(strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z') !== false); - $this->assertTrue(strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z') !== false); - + $this->assertTrue(false !== strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY')); + $this->assertTrue(false !== strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z')); + $this->assertTrue(false !== strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z')); } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testFreeBusyReportNoTimeRange() { - + public function testFreeBusyReportNoTimeRange() + { $reportXML = << @@ -126,17 +120,14 @@ XML; XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); - } /** - * @expectedException Sabre\DAV\Exception\NotImplemented + * @expectedException \Sabre\DAV\Exception\NotImplemented */ - function testFreeBusyReportWrongNode() { - - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/', - ]); + public function testFreeBusyReportWrongNode() + { + $request = new HTTP\Request('REPORT', '/'); $this->server->httpRequest = $request; $reportXML = <<server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report, null); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testFreeBusyReportNoACLPlugin() { - + public function testFreeBusyReportNoACLPlugin() + { $this->server = new DAV\Server(); + $this->server->httpRequest = new HTTP\Request('REPORT', '/'); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); @@ -169,6 +160,5 @@ XML; $report = $this->server->xml->parse($reportXML, null, $rootElem); $this->plugin->report($rootElem, $report, null); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php index 5fd8d29a1..6cb2b609e 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php @@ -1,27 +1,29 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -45,14 +47,14 @@ END:VCALENDAR ], ]; - function testQueryTimerange() { - + public function testQueryTimerange() + { $request = new HTTP\Request( 'REPORT', '/calendars/user1/calendar1', [ 'Content-Type' => 'application/xml', - 'Depth' => '1', + 'Depth' => '1', ] ); @@ -75,8 +77,6 @@ END:VCALENDAR $response = $this->request($request); - $this->assertTrue(strpos($response->body, 'BEGIN:VCALENDAR') !== false); - + $this->assertTrue(false !== strpos($response->body, 'BEGIN:VCALENDAR')); } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php index 75412577e..c139e5b5c 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php @@ -1,5 +1,7 @@ icsExportPlugin = new ICSExportPlugin(); $this->server->addPlugin( @@ -25,7 +27,7 @@ class ICSExportPluginTest extends \Sabre\DAVServerTest { 'principals/admin', 'UUID-123467', [ - '{DAV:}displayname' => 'Hello!', + '{DAV:}displayname' => 'Hello!', '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', ] ); @@ -56,23 +58,20 @@ END:VTODO END:VCALENDAR ICS ); - - } - function testInit() { - + public function testInit() + { $this->assertEquals( $this->icsExportPlugin, $this->server->getPlugin('ics-export') ); $this->assertEquals($this->icsExportPlugin, $this->server->getPlugin('ics-export')); $this->assertEquals('ics-export', $this->icsExportPlugin->getPluginInfo()['name']); - } - function testBeforeMethod() { - + public function testBeforeMethod() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export' @@ -89,15 +88,15 @@ ICS $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); - $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertTrue(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - $this->assertEquals("Hello!", $obj->{"X-WR-CALNAME"}); - $this->assertEquals("#AA0000FF", $obj->{"X-APPLE-CALENDAR-COLOR"}); - + $this->assertEquals('Hello!', $obj->{'X-WR-CALNAME'}); + $this->assertEquals('#AA0000FF', $obj->{'X-APPLE-CALENDAR-COLOR'}); } - function testBeforeMethodNoVersion() { + public function testBeforeMethodNoVersion() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export' @@ -115,25 +114,23 @@ ICS $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); - $this->assertFalse(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertFalse(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - } - function testBeforeMethodNoExport() { - + public function testBeforeMethodNoExport() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467' ); $response = new HTTP\Response(); $this->assertNull($this->icsExportPlugin->httpGet($request, $response)); - } - function testACLIntegrationBlocked() { - + public function testACLIntegrationBlocked() + { $aclPlugin = new DAVACL\Plugin(); $aclPlugin->allowUnauthenticatedAccess = false; $this->server->addPlugin( @@ -146,11 +143,10 @@ ICS ); $this->request($request, 403); - } - function testACLIntegrationNotBlocked() { - + public function testACLIntegrationNotBlocked() + { $aclPlugin = new DAVACL\Plugin(); $aclPlugin->allowUnauthenticatedAccess = false; $this->server->addPlugin( @@ -176,34 +172,31 @@ ICS $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); - $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION) !== false); + $this->assertTrue(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - } - function testBadStartParam() { - + public function testBadStartParam() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&start=foo' ); $this->request($request, 400); - } - function testBadEndParam() { - + public function testBadEndParam() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&end=foo' ); $this->request($request, 400); - } - function testFilterStartEnd() { - + public function testFilterStartEnd() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&start=1&end=2' @@ -212,23 +205,21 @@ ICS $obj = VObject\Reader::read($response->getBody()); - $this->assertEquals(0, count($obj->VTIMEZONE)); - $this->assertEquals(0, count($obj->VEVENT)); - + $this->assertNull($obj->VTIMEZONE); + $this->assertNull($obj->VEVENT); } - function testExpandNoStart() { - + public function testExpandNoStart() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&expand=1&end=2' ); $this->request($request, 400); - } - function testExpand() { - + public function testExpand() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&start=1&end=2000000000&expand=1' @@ -237,13 +228,12 @@ ICS $obj = VObject\Reader::read($response->getBody()); - $this->assertEquals(0, count($obj->VTIMEZONE)); + $this->assertNull($obj->VTIMEZONE); $this->assertEquals(1, count($obj->VEVENT)); - } - function testJCal() { - + public function testJCal() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export', @@ -252,11 +242,10 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - } - function testJCalInUrl() { - + public function testJCalInUrl() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&accept=jcal' @@ -264,11 +253,10 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - } - function testNegotiateDefault() { - + public function testNegotiateDefault() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export', @@ -277,11 +265,10 @@ ICS $response = $this->request($request, 200); $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - } - function testFilterComponentVEVENT() { - + public function testFilterComponentVEVENT() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&componentType=VEVENT' @@ -292,12 +279,11 @@ ICS $obj = VObject\Reader::read($response->body); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); - $this->assertEquals(0, count($obj->VTODO)); - + $this->assertNull($obj->VTODO); } - function testFilterComponentVTODO() { - + public function testFilterComponentVTODO() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&componentType=VTODO' @@ -307,25 +293,23 @@ ICS $obj = VObject\Reader::read($response->body); - $this->assertEquals(0, count($obj->VTIMEZONE)); - $this->assertEquals(0, count($obj->VEVENT)); + $this->assertNull($obj->VTIMEZONE); + $this->assertNull($obj->VEVENT); $this->assertEquals(1, count($obj->VTODO)); - } - function testFilterComponentBadComponent() { - + public function testFilterComponentBadComponent() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export&componentType=VVOODOO' ); $response = $this->request($request, 400); - } - function testContentDisposition() { - + public function testContentDisposition() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export' @@ -334,14 +318,13 @@ ICS $response = $this->request($request, 200); $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="UUID-123467-' . date('Y-m-d') . '.ics"', + 'attachment; filename="UUID-123467-'.date('Y-m-d').'.ics"', $response->getHeader('Content-Disposition') ); - } - function testContentDispositionJson() { - + public function testContentDispositionJson() + { $request = new HTTP\Request( 'GET', '/calendars/admin/UUID-123467?export', @@ -351,19 +334,18 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="UUID-123467-' . date('Y-m-d') . '.json"', + 'attachment; filename="UUID-123467-'.date('Y-m-d').'.json"', $response->getHeader('Content-Disposition') ); - } - function testContentDispositionBadChars() { - + public function testContentDispositionBadChars() + { $this->caldavBackend->createCalendar( 'principals/admin', 'UUID-b_ad"(ch)ars', [ - '{DAV:}displayname' => 'Test bad characters', + '{DAV:}displayname' => 'Test bad characters', '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', ] ); @@ -377,10 +359,8 @@ ICS $response = $this->request($request, 200); $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="UUID-b_adchars-' . date('Y-m-d') . '.json"', + 'attachment; filename="UUID-b_adchars-'.date('Y-m-d').'.json"', $response->getHeader('Content-Disposition') ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php index a1a9b7c04..02d39fe84 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php @@ -1,13 +1,15 @@ 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2011-12-01'), - 'end' => new \DateTime('2012-02-01'), + 'end' => new \DateTime('2012-02-01'), ], ], ], - 'prop-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => null, + 'time-range' => null, ]; $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input, $filters)); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php index e2b85c2bc..83120fe6a 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php @@ -1,13 +1,16 @@ 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), + 'end' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), ], ], ], @@ -39,7 +42,8 @@ HI; } // Pacific Standard Time, translates to America/Los_Angeles (GMT-8 in January) - function testOutlookTimezoneName() { + public function testOutlookTimezoneName() + { $input = << 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), + 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), ], ], ], @@ -86,7 +90,8 @@ HI; } // X-LIC-LOCATION, translates to America/Los_Angeles (GMT-8 in January) - function testLibICalLocationName() { + public function testLibICalLocationName() + { $input = << 'VCALENDAR', + 'name' => 'VCALENDAR', 'comp-filters' => [ [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], + 'name' => 'VEVENT', + 'comp-filters' => [], + 'prop-filters' => [], 'is-not-defined' => false, - 'time-range' => [ + 'time-range' => [ 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), + 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), ], ], ], diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php index 369e9a70c..0700024cf 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php @@ -1,28 +1,30 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -56,13 +58,13 @@ END:VCALENDAR ], ]; - function testIssue203() { - + public function testIssue203() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -96,24 +98,22 @@ END:VCALENDAR $this->assertEquals(2, count($vObject->VEVENT)); - $expectedEvents = [ [ 'DTSTART' => '20120326T135200Z', - 'DTEND' => '20120326T145200Z', + 'DTEND' => '20120326T145200Z', 'SUMMARY' => 'original summary', ], [ - 'DTSTART' => '20120328T135200Z', - 'DTEND' => '20120328T145200Z', - 'SUMMARY' => 'overwritten summary', + 'DTSTART' => '20120328T135200Z', + 'DTEND' => '20120328T145200Z', + 'SUMMARY' => 'overwritten summary', 'RECURRENCE-ID' => '20120327T135200Z', - ] + ], ]; // try to match agains $expectedEvents array foreach ($expectedEvents as $expectedEvent) { - $matching = false; foreach ($vObject->VEVENT as $vevent) { @@ -131,7 +131,7 @@ END:VCALENDAR break; } - $this->assertTrue($matching, 'Did not find the following event in the response: ' . var_export($expectedEvent, true)); + $this->assertTrue($matching, 'Did not find the following event in the response: '.var_export($expectedEvent, true)); } } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php index ce40a90b0..60c944d1d 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php @@ -1,28 +1,30 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -49,13 +51,13 @@ END:VCALENDAR ], ]; - function testIssue205() { - + public function testIssue205() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -79,8 +81,8 @@ END:VCALENDAR $response = $this->request($request); - $this->assertFalse(strpos($response->body, 'Exception'), 'Exception occurred: ' . $response->body); - $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: ' . $response->body); + $this->assertFalse(strpos($response->body, 'Exception'), 'Exception occurred: '.$response->body); + $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: '.$response->body); // Everts super awesome xml parser. $body = substr( @@ -93,6 +95,5 @@ END:VCALENDAR $vObject = VObject\Reader::read($body); $this->assertEquals(1, count($vObject->VEVENT)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php index 950629fd8..10c9af50c 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php @@ -1,27 +1,29 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -53,13 +55,13 @@ END:VCALENDAR ], ]; - function testIssue211() { - + public function testIssue211() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -84,6 +86,5 @@ END:VCALENDAR // if this assert is reached, the endless loop is gone // There should be no matching events $this->assertFalse(strpos('BEGIN:VEVENT', $response->body)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php index c3c0b5b48..46f5ca205 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php @@ -1,27 +1,29 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -63,13 +65,13 @@ END:VCALENDAR ], ]; - function testIssue220() { - + public function testIssue220() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -91,8 +93,8 @@ END:VCALENDAR $response = $this->request($request); - $this->assertFalse(strpos($response->body, 'PHPUnit_Framework_Error_Warning'), 'Error Warning occurred: ' . $response->body); - $this->assertFalse(strpos($response->body, 'Invalid argument supplied for foreach()'), 'Invalid argument supplied for foreach(): ' . $response->body); + $this->assertFalse(strpos($response->body, 'PHPUnit_Framework_Error_Warning'), 'Error Warning occurred: '.$response->body); + $this->assertFalse(strpos($response->body, 'Invalid argument supplied for foreach()'), 'Invalid argument supplied for foreach(): '.$response->body); $this->assertEquals(207, $response->status); } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php index d0783701d..a8b855ca3 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php @@ -1,27 +1,29 @@ 1, - 'name' => 'Calendar', + 'id' => 1, + 'name' => 'Calendar', 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ] + 'uri' => 'calendar1', + ], ]; protected $caldavCalendarObjects = [ @@ -43,13 +45,13 @@ END:VCALENDAR ], ]; - function testIssue228() { - + public function testIssue228() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'REPORT', + 'REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', - 'REQUEST_URI' => '/calendars/user1/calendar1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', ]); $request->setBody(' @@ -74,6 +76,5 @@ END:VCALENDAR // We must check if absolutely nothing was returned from this query. $this->assertFalse(strpos($response->body, 'BEGIN:VCALENDAR')); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php index 6585f85c3..eceb0b87f 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php @@ -1,58 +1,56 @@ principalUri = 'principals/user1'; $this->notification = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ 'principals/user1' => [ - $this->notification - ] + $this->notification, + ], ]); return new Collection($this->caldavBackend, $this->principalUri); - } - function testGetChildren() { - + public function testGetChildren() + { $col = $this->getInstance(); $this->assertEquals('notifications', $col->getName()); $this->assertEquals([ - new Node($this->caldavBackend, $this->principalUri, $this->notification) + new Node($this->caldavBackend, $this->principalUri, $this->notification), ], $col->getChildren()); - } - function testGetOwner() { - + public function testGetOwner() + { $col = $this->getInstance(); $this->assertEquals('principals/user1', $col->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $col = $this->getInstance(); $this->assertNull($col->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $col = $this->getInstance(); $expected = [ [ @@ -63,23 +61,20 @@ class CollectionTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $col->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $col = $this->getInstance(); $col->setACL([]); - } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $col = $this->getInstance(); $this->assertNull($col->getSupportedPrivilegeSet()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php index 6c6e02da8..cb19ef962 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php @@ -1,69 +1,66 @@ systemStatus = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ 'principals/user1' => [ - $this->systemStatus - ] + $this->systemStatus, + ], ]); $node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus); - return $node; + return $node; } - function testGetId() { - + public function testGetId() + { $node = $this->getInstance(); - $this->assertEquals($this->systemStatus->getId() . '.xml', $node->getName()); - + $this->assertEquals($this->systemStatus->getId().'.xml', $node->getName()); } - function testGetEtag() { - + public function testGetEtag() + { $node = $this->getInstance(); $this->assertEquals('"1"', $node->getETag()); - } - function testGetNotificationType() { - + public function testGetNotificationType() + { $node = $this->getInstance(); $this->assertEquals($this->systemStatus, $node->getNotificationType()); - } - function testDelete() { - + public function testDelete() + { $node = $this->getInstance(); $node->delete(); $this->assertEquals([], $this->caldavBackend->getNotificationsForPrincipal('principals/user1')); - } - function testGetGroup() { - + public function testGetGroup() + { $node = $this->getInstance(); $this->assertNull($node->getGroup()); - } - function testGetACL() { - + public function testGetACL() + { $node = $this->getInstance(); $expected = [ [ @@ -74,23 +71,20 @@ class NodeTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $node->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - + public function testSetACL() + { $node = $this->getInstance(); $node->setACL([]); - } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $node = $this->getInstance(); $this->assertNull($node->getSupportedPrivilegeSet()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php index 859f6aa0c..711cc0ac7 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php @@ -1,5 +1,7 @@ caldavBackend = new Backend\Mock([ [ - 'id' => 1, - 'uri' => 'UUID-123467', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'user1 calendar', - $caldavNS . 'calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), + 'id' => 1, + 'uri' => 'UUID-123467', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'user1 calendar', + $caldavNS.'calendar-description' => 'Calendar description', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + $caldavNS.'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), ], [ - 'id' => 2, - 'uri' => 'UUID-123468', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'user1 calendar2', - $caldavNS . 'calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), - ] + 'id' => 2, + 'uri' => 'UUID-123468', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'user1 calendar2', + $caldavNS.'calendar-description' => 'Calendar description', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + $caldavNS.'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), + ], ], [ 1 => [ 'UUID-2345' => [ 'calendardata' => TestUtil::getTestCalendarData(), - ] - ] + ], + ], ]); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', ['principals/user1']); @@ -89,41 +91,45 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->setPrincipal('principals/user1'); $authPlugin = new DAV\Auth\Plugin($authBackend); - $authPlugin->beforeMethod(new \Sabre\HTTP\Request(), new \Sabre\HTTP\Response()); + $authPlugin->beforeMethod(new \Sabre\HTTP\Request('GET', '/'), new \Sabre\HTTP\Response()); $this->server->addPlugin($authPlugin); // This forces a login - $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; - } - function testSimple() { - + public function testSimple() + { $this->assertEquals(['MKCALENDAR'], $this->plugin->getHTTPMethods('calendars/user1/randomnewcalendar')); $this->assertEquals(['calendar-access', 'calendar-proxy'], $this->plugin->getFeatures()); $this->assertEquals( 'caldav', $this->plugin->getPluginInfo()['name'] ); - } - function testUnknownMethodPassThrough() { - + public function testUnknownMethodPassThrough() + { $request = new HTTP\Request('MKBREAKFAST', '/'); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(501, $this->response->status, 'Incorrect status returned. Full response body:' . $this->response->body); - + $this->assertEquals(501, $this->response->status, 'Incorrect status returned. Full response body:'.$this->response->body); } - function testReportPassThrough() { + public function testGetWithoutContentType() + { + $request = new HTTP\Request('GET', '/'); + $this->plugin->httpAfterGet($request, $this->response); + $this->assertTrue(true); + } + public function testReportPassThrough() + { $request = new HTTP\Request('REPORT', '/', ['Content-Type' => 'application/xml']); $request->setBody(''); @@ -131,11 +137,10 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(415, $this->response->status); - } - function testMkCalendarBadLocation() { - + public function testMkCalendarBadLocation() + { $request = new HTTP\Request('MKCALENDAR', '/blabla'); $body = ' @@ -181,11 +186,10 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(403, $this->response->status); - } - function testMkCalendarNoParentNode() { - + public function testMkCalendarNoParentNode() + { $request = new HTTP\Request('MKCALENDAR', '/doesntexist/calendar'); $body = ' @@ -231,14 +235,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(409, $this->response->status); - } - function testMkCalendarExistingCalendar() { - + public function testMkCalendarExistingCalendar() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'MKCALENDAR', - 'REQUEST_URI' => '/calendars/user1/UUID-123467', + 'REQUEST_URI' => '/calendars/user1/UUID-123467', ]); $body = ' @@ -284,11 +287,10 @@ class PluginTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(405, $this->response->status); - } - function testMkCalendarSucceed() { - + public function testMkCalendarSucceed() + { $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR'); $timezone = 'BEGIN:VCALENDAR @@ -325,7 +327,7 @@ END:VCALENDAR'; - + '; @@ -334,89 +336,87 @@ END:VCALENDAR'; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: ' . $this->response->body); + $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: '.$this->response->body); $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); $this->assertEquals(3, count($calendars)); $newCalendar = null; foreach ($calendars as $calendar) { - if ($calendar['uri'] === 'NEWCALENDAR') { + if ('NEWCALENDAR' === $calendar['uri']) { $newCalendar = $calendar; break; - } + } } $this->assertInternalType('array', $newCalendar); $keys = [ - 'uri' => 'NEWCALENDAR', - 'id' => null, - '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone, - '{DAV:}displayname' => 'Lisa\'s Events', + 'uri' => 'NEWCALENDAR', + 'id' => null, + '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.', + '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone, + '{DAV:}displayname' => 'Lisa\'s Events', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, ]; foreach ($keys as $key => $value) { - $this->assertArrayHasKey($key, $newCalendar); - if (is_null($value)) continue; + if (is_null($value)) { + continue; + } $this->assertEquals($value, $newCalendar[$key]); - } $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet); $this->assertEquals(['VEVENT'], $newCalendar[$sccs]->getValue()); - } - function testMkCalendarEmptyBodySucceed() { - + public function testMkCalendarEmptyBodySucceed() + { $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR'); $request->setBody(''); $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: ' . $this->response->body); + $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: '.$this->response->body); $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); $this->assertEquals(3, count($calendars)); $newCalendar = null; foreach ($calendars as $calendar) { - if ($calendar['uri'] === 'NEWCALENDAR') { + if ('NEWCALENDAR' === $calendar['uri']) { $newCalendar = $calendar; break; - } + } } $this->assertInternalType('array', $newCalendar); $keys = [ - 'uri' => 'NEWCALENDAR', - 'id' => null, + 'uri' => 'NEWCALENDAR', + 'id' => null, '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, ]; foreach ($keys as $key => $value) { - $this->assertArrayHasKey($key, $newCalendar); - if (is_null($value)) continue; + if (is_null($value)) { + continue; + } $this->assertEquals($value, $newCalendar[$key]); - } $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet); $this->assertEquals(['VEVENT', 'VTODO'], $newCalendar[$sccs]->getValue()); - } - function testMkCalendarBadXml() { - + public function testMkCalendarBadXml() + { $request = new HTTP\Request('MKCALENDAR', '/blabla'); $body = 'This is not xml'; @@ -425,26 +425,24 @@ END:VCALENDAR'; $this->server->exec(); $this->assertEquals(400, $this->response->status); - } - function testPrincipalProperties() { - + public function testPrincipalProperties() + { $httpRequest = new HTTP\Request('FOO', '/blabla', ['Host' => 'sabredav.org']); $this->server->httpRequest = $httpRequest; $props = $this->server->getPropertiesForPath('/principals/user1', [ - '{' . Plugin::NS_CALDAV . '}calendar-home-set', - '{' . Plugin::NS_CALENDARSERVER . '}calendar-proxy-read-for', - '{' . Plugin::NS_CALENDARSERVER . '}calendar-proxy-write-for', - '{' . Plugin::NS_CALENDARSERVER . '}notification-URL', - '{' . Plugin::NS_CALENDARSERVER . '}email-address-set', + '{'.Plugin::NS_CALDAV.'}calendar-home-set', + '{'.Plugin::NS_CALENDARSERVER.'}calendar-proxy-read-for', + '{'.Plugin::NS_CALENDARSERVER.'}calendar-proxy-write-for', + '{'.Plugin::NS_CALENDARSERVER.'}notification-URL', + '{'.Plugin::NS_CALENDARSERVER.'}email-address-set', ]); $this->assertArrayHasKey(0, $props); $this->assertArrayHasKey(200, $props[0]); - $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-home-set', $props[0][200]); $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-home-set']; $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop); @@ -460,15 +458,14 @@ END:VCALENDAR'; $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop); $this->assertEquals(['principals/admin/'], $prop->getHrefs()); - $this->assertArrayHasKey('{' . Plugin::NS_CALENDARSERVER . '}email-address-set', $props[0][200]); - $prop = $props[0][200]['{' . Plugin::NS_CALENDARSERVER . '}email-address-set']; + $this->assertArrayHasKey('{'.Plugin::NS_CALENDARSERVER.'}email-address-set', $props[0][200]); + $prop = $props[0][200]['{'.Plugin::NS_CALENDARSERVER.'}email-address-set']; $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\EmailAddressSet', $prop); $this->assertEquals(['user1.sabredav@sabredav.org'], $prop->getValue()); - } - function testSupportedReportSetPropertyNonCalendar() { - + public function testSupportedReportSetPropertyNonCalendar() + { $props = $this->server->getPropertiesForPath('/calendars/user1', [ '{DAV:}supported-report-set', ]); @@ -487,14 +484,13 @@ END:VCALENDAR'; '{DAV:}principal-search-property-set', ]; $this->assertEquals($value, $prop->getValue()); - } /** * @depends testSupportedReportSetPropertyNonCalendar */ - function testSupportedReportSetProperty() { - + public function testSupportedReportSetProperty() + { $props = $this->server->getPropertiesForPath('/calendars/user1/UUID-123467', [ '{DAV:}supported-report-set', ]); @@ -513,14 +509,13 @@ END:VCALENDAR'; '{DAV:}expand-property', '{DAV:}principal-match', '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set' + '{DAV:}principal-search-property-set', ]; $this->assertEquals($value, $prop->getValue()); - } - function testSupportedReportSetUserCalendars() { - + public function testSupportedReportSetUserCalendars() + { $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); $props = $this->server->getPropertiesForPath('/calendars/user1', [ @@ -542,22 +537,21 @@ END:VCALENDAR'; '{DAV:}principal-search-property-set', ]; $this->assertEquals($value, $prop->getValue()); - } /** * @depends testSupportedReportSetProperty */ - function testCalendarMultiGetReport() { - + public function testCalendarMultiGetReport() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - '' . - '/calendars/user1/UUID-123467/UUID-2345' . + ''. + ''. + ''. + ' '. + ' '. + ''. + '/calendars/user1/UUID-123467/UUID-2345'. ''; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -587,24 +581,23 @@ END:VCALENDAR'; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportExpand() { - + public function testCalendarMultiGetReportExpand() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '/calendars/user1/UUID-123467/UUID-2345' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + '/calendars/user1/UUID-123467/UUID-2345'. ''; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -613,7 +606,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -640,29 +633,28 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReport() { - + public function testCalendarQueryReport() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '' . - ' ' . - ' ' . - ' ' . - '' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + ''. + ' '. + ' '. + ' '. + ''. ''; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', ['Depth' => '1']); @@ -671,7 +663,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -698,33 +690,32 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReportWindowsPhone() { - + public function testCalendarQueryReportWindowsPhone() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '' . - ' ' . - ' ' . - ' ' . - '' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + ''. + ' '. + ' '. + ' '. + ''. ''; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [ - 'Depth' => '0', + 'Depth' => '0', 'User-Agent' => 'MSFT-WP/8.10.14219 (gzip)', ]); @@ -733,7 +724,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -760,29 +751,28 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReportBadDepth() { - + public function testCalendarQueryReportBadDepth() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '' . - ' ' . - ' ' . - ' ' . - '' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + ''. + ' '. + ' '. + ' '. + ''. ''; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [ @@ -793,26 +783,25 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); } /** * @depends testCalendarQueryReport */ - function testCalendarQueryReportNoCalData() { - + public function testCalendarQueryReportNoCalData() + { $body = - '' . - '' . - '' . - ' ' . - '' . - '' . - ' ' . - ' ' . - ' ' . - '' . + ''. + ''. + ''. + ' '. + ''. + ''. + ' '. + ' '. + ' '. + ''. ''; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467', [ @@ -823,7 +812,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expected = << @@ -841,21 +830,20 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testCalendarQueryReport */ - function testCalendarQueryReportNoFilters() { - + public function testCalendarQueryReportNoFilters() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - '' . + ''. + ''. + ''. + ' '. + ' '. + ''. ''; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467'); @@ -864,30 +852,29 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReport1Object() { - + public function testCalendarQueryReport1Object() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '' . - ' ' . - ' ' . - ' ' . - '' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + ''. + ' '. + ' '. + ' '. + ''. ''; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467/UUID-2345', ['Depth' => '0']); @@ -896,7 +883,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expectedIcal = TestUtil::getTestCalendarData(); $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); @@ -923,26 +910,25 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } /** * @depends testSupportedReportSetProperty * @depends testCalendarMultiGetReport */ - function testCalendarQueryReport1ObjectNoCalData() { - + public function testCalendarQueryReport1ObjectNoCalData() + { $body = - '' . - '' . - '' . - ' ' . - '' . - '' . - ' ' . - ' ' . - ' ' . - '' . + ''. + ''. + ''. + ' '. + ''. + ''. + ' '. + ' '. + ' '. + ''. ''; $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467/UUID-2345', ['Depth' => '0']); @@ -951,7 +937,7 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body); + $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->body); $expected = << @@ -969,34 +955,32 @@ XML; XML; $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString()); - } - function testHTMLActionsPanel() { - + public function testHTMLActionsPanel() + { $output = ''; $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('calendars/user1'), &$output]); $this->assertFalse($r); - $this->assertTrue(!!strpos($output, 'Display name')); - + $this->assertTrue((bool) strpos($output, 'Display name')); } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportNoEnd() { - + public function testCalendarMultiGetReportNoEnd() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '/calendars/user1/UUID-123467/UUID-2345' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + '/calendars/user1/UUID-123467/UUID-2345'. ''; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -1005,25 +989,24 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportNoStart() { - + public function testCalendarMultiGetReportNoStart() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '/calendars/user1/UUID-123467/UUID-2345' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + '/calendars/user1/UUID-123467/UUID-2345'. ''; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -1032,25 +1015,24 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); } /** * @depends testCalendarMultiGetReport */ - function testCalendarMultiGetReportEndBeforeStart() { - + public function testCalendarMultiGetReportEndBeforeStart() + { $body = - '' . - '' . - '' . - ' ' . - ' ' . - ' ' . - ' ' . - '' . - '/calendars/user1/UUID-123467/UUID-2345' . + ''. + ''. + ''. + ' '. + ' '. + ' '. + ' '. + ''. + '/calendars/user1/UUID-123467/UUID-2345'. ''; $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); @@ -1059,28 +1041,25 @@ XML; $this->server->httpRequest = $request; $this->server->exec(); - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: ' . $this->response->body); - + $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->body); } /** * @depends testSupportedReportSetPropertyNonCalendar */ - function testCalendarProperties() { - + public function testCalendarProperties() + { $ns = '{urn:ietf:params:xml:ns:caldav}'; $props = $this->server->getProperties('calendars/user1/UUID-123467', [ - $ns . 'max-resource-size', - $ns . 'supported-calendar-data', - $ns . 'supported-collation-set', + $ns.'max-resource-size', + $ns.'supported-calendar-data', + $ns.'supported-collation-set', ]); $this->assertEquals([ - $ns . 'max-resource-size' => 10000000, - $ns . 'supported-calendar-data' => new Xml\Property\SupportedCalendarData(), - $ns . 'supported-collation-set' => new Xml\Property\SupportedCollationSet(), + $ns.'max-resource-size' => 10000000, + $ns.'supported-calendar-data' => new Xml\Property\SupportedCalendarData(), + $ns.'supported-collation-set' => new Xml\Property\SupportedCollationSet(), ], $props); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php index 23c248825..277de0664 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php @@ -1,20 +1,20 @@ getChildForPrincipal([ 'uri' => 'principals/admin', ]); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\User', $r); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php index fe07f0131..8036635b2 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php @@ -1,102 +1,95 @@ 'principal/user', ]); $this->backend = $backend; - return $principal; - } - - function testGetName() { + return $principal; + } + public function testGetName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-read', $i->getName()); - } - function testGetDisplayName() { + public function testGetDisplayName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-read', $i->getDisplayName()); - } - function testGetLastModified() { - + public function testGetLastModified() + { $i = $this->getInstance(); $this->assertNull($i->getLastModified()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testDelete() { - + public function testDelete() + { $i = $this->getInstance(); $i->delete(); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetName() { - + public function testSetName() + { $i = $this->getInstance(); $i->setName('foo'); - } - function testGetAlternateUriSet() { - + public function testGetAlternateUriSet() + { $i = $this->getInstance(); $this->assertEquals([], $i->getAlternateUriSet()); - } - function testGetPrincipalUri() { - + public function testGetPrincipalUri() + { $i = $this->getInstance(); $this->assertEquals('principal/user/calendar-proxy-read', $i->getPrincipalUrl()); - } - function testGetGroupMemberSet() { - + public function testGetGroupMemberSet() + { $i = $this->getInstance(); $this->assertEquals([], $i->getGroupMemberSet()); - } - function testGetGroupMembership() { - + public function testGetGroupMembership() + { $i = $this->getInstance(); $this->assertEquals([], $i->getGroupMembership()); - } - function testSetGroupMemberSet() { - + public function testSetGroupMemberSet() + { $i = $this->getInstance(); $i->setGroupMemberSet(['principals/foo']); $expected = [ - $i->getPrincipalUrl() => ['principals/foo'] + $i->getPrincipalUrl() => ['principals/foo'], ]; $this->assertEquals($expected, $this->backend->groupMembers); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php index 6cdb9b30e..df1715ee5 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php @@ -1,40 +1,39 @@ 'principal/user', ]); $this->backend = $backend; - return $principal; + return $principal; } - function testGetName() { - + public function testGetName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-write', $i->getName()); - } - function testGetDisplayName() { + public function testGetDisplayName() + { $i = $this->getInstance(); $this->assertEquals('calendar-proxy-write', $i->getDisplayName()); - } - function testGetPrincipalUri() { - + public function testGetPrincipalUri() + { $i = $this->getInstance(); $this->assertEquals('principal/user/calendar-proxy-write', $i->getPrincipalUrl()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php index 420bb3b1a..2c690c65d 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php @@ -1,13 +1,15 @@ addPrincipal([ 'uri' => 'principals/user/calendar-proxy-read', @@ -18,89 +20,81 @@ class UserTest extends \PHPUnit_Framework_TestCase { $backend->addPrincipal([ 'uri' => 'principals/user/random', ]); + return new User($backend, [ 'uri' => 'principals/user', ]); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateFile() { - + public function testCreateFile() + { $u = $this->getInstance(); $u->createFile('test'); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $u = $this->getInstance(); $u->createDirectory('test'); - } - function testGetChildProxyRead() { - + public function testGetChildProxyRead() + { $u = $this->getInstance(); $child = $u->getChild('calendar-proxy-read'); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $child); - } - function testGetChildProxyWrite() { - + public function testGetChildProxyWrite() + { $u = $this->getInstance(); $child = $u->getChild('calendar-proxy-write'); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $child); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChildNotFound() { - + public function testGetChildNotFound() + { $u = $this->getInstance(); $child = $u->getChild('foo'); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChildNotFound2() { - + public function testGetChildNotFound2() + { $u = $this->getInstance(); $child = $u->getChild('random'); - } - function testGetChildren() { - + public function testGetChildren() + { $u = $this->getInstance(); $children = $u->getChildren(); $this->assertEquals(2, count($children)); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $children[0]); $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $children[1]); - } - function testChildExist() { - + public function testChildExist() + { $u = $this->getInstance(); $this->assertTrue($u->childExists('calendar-proxy-read')); $this->assertTrue($u->childExists('calendar-proxy-write')); $this->assertFalse($u->childExists('foo')); - } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}all', @@ -121,7 +115,5 @@ class UserTest extends \PHPUnit_Framework_TestCase { $u = $this->getInstance(); $this->assertEquals($expected, $u->getACL()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php index 04d4b1237..df70fe7ec 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php @@ -1,14 +1,15 @@ assertEquals('outbox', $outbox->getName()); $this->assertEquals([], $outbox->getChildren()); @@ -17,7 +18,7 @@ class OutboxTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', 'principal' => 'principals/user1', 'protected' => true, ], @@ -27,7 +28,7 @@ class OutboxTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], [ - 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send', + 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', 'principal' => 'principals/user1/calendar-proxy-write', 'protected' => true, ], @@ -42,7 +43,5 @@ class OutboxTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $outbox->getACL()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php index f71c19523..735bbef41 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php @@ -1,24 +1,26 @@ 1, + 'id' => 1, '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original', - '{http://sabredav.org/ns}owner-principal' => 'principals/owner', - '{http://sabredav.org/ns}read-only' => false, - 'share-access' => Sharing\Plugin::ACCESS_READWRITE, - 'principaluri' => 'principals/sharee', + '{http://sabredav.org/ns}owner-principal' => 'principals/owner', + '{http://sabredav.org/ns}read-only' => false, + 'share-access' => Sharing\Plugin::ACCESS_READWRITE, + 'principaluri' => 'principals/sharee', ]; } @@ -35,11 +37,10 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { $this->backend->updateInvites(1, [$sharee]); return new SharedCalendar($this->backend, $props); - } - function testGetInvites() { - + public function testGetInvites() + { $sharee = new Sharee(); $sharee->href = 'mailto:removeme@example.org'; $sharee->properties['{DAV:}displayname'] = 'To be removed'; @@ -50,15 +51,15 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { [$sharee], $this->getInstance()->getInvites() ); - } - function testGetOwner() { + public function testGetOwner() + { $this->assertEquals('principals/sharee', $this->getInstance()->getOwner()); } - function testGetACL() { - + public function testGetACL() + { $expected = [ [ 'privilege' => '{DAV:}write', @@ -96,18 +97,17 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], [ - 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy', + 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true, ], ]; $this->assertEquals($expected, $this->getInstance()->getACL()); - } - function testGetChildACL() { - + public function testGetChildACL() + { $expected = [ [ 'privilege' => '{DAV:}write', @@ -134,19 +134,17 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { 'principal' => 'principals/sharee/calendar-proxy-read', 'protected' => true, ], - ]; $this->assertEquals($expected, $this->getInstance()->getChildACL()); - } - function testUpdateInvites() { - + public function testUpdateInvites() + { $instance = $this->getInstance(); $newSharees = [ new Sharee(), - new Sharee() + new Sharee(), ]; $newSharees[0]->href = 'mailto:test@example.org'; $newSharees[0]->properties['{DAV:}displayname'] = 'Foo Bar'; @@ -159,18 +157,16 @@ class SharedCalendarTest extends \PHPUnit_Framework_TestCase { $instance->updateInvites($newSharees); $expected = [ - clone $newSharees[0] + clone $newSharees[0], ]; $expected[0]->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE; $this->assertEquals($expected, $instance->getInvites()); - } - function testPublish() { - + public function testPublish() + { $instance = $this->getInstance(); $this->assertNull($instance->setPublishStatus(true)); $this->assertNull($instance->setPublishStatus(false)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php index 9589176a3..57732cd06 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php @@ -1,36 +1,38 @@ caldavCalendars = [ [ 'principaluri' => 'principals/user1', - 'id' => 1, - 'uri' => 'cal1', + 'id' => 1, + 'uri' => 'cal1', ], [ 'principaluri' => 'principals/user1', - 'id' => 2, - 'uri' => 'cal2', + 'id' => 2, + 'uri' => 'cal2', 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, ], [ 'principaluri' => 'principals/user1', - 'id' => 3, - 'uri' => 'cal3', + 'id' => 3, + 'uri' => 'cal3', ], ]; @@ -38,86 +40,79 @@ class SharingPluginTest extends \Sabre\DAVServerTest { // Making the logged in user an admin, for full access: $this->aclPlugin->adminPrincipals[] = 'principals/user2'; - } - function testSimple() { - + public function testSimple() + { $this->assertInstanceOf('Sabre\\CalDAV\\SharingPlugin', $this->server->getPlugin('caldav-sharing')); $this->assertEquals( 'caldav-sharing', $this->caldavSharingPlugin->getPluginInfo()['name'] ); - } /** * @expectedException \LogicException */ - function testSetupWithoutCoreSharingPlugin() { - + public function testSetupWithoutCoreSharingPlugin() + { $server = new DAV\Server(); $server->addPlugin( new SharingPlugin() ); - } - function testGetFeatures() { - + public function testGetFeatures() + { $this->assertEquals(['calendarserver-sharing'], $this->caldavSharingPlugin->getFeatures()); - } - function testBeforeGetShareableCalendar() { - + public function testBeforeGetShareableCalendar() + { // Forcing the server to authenticate: - $this->authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $this->authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $props = $this->server->getProperties('calendars/user1/cal1', [ - '{' . Plugin::NS_CALENDARSERVER . '}invite', - '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes', + '{'.Plugin::NS_CALENDARSERVER.'}invite', + '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', ]); - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']); - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']); - + $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']); + $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes']); } - function testBeforeGetSharedCalendar() { - + public function testBeforeGetSharedCalendar() + { $props = $this->server->getProperties('calendars/user1/cal2', [ - '{' . Plugin::NS_CALENDARSERVER . '}shared-url', - '{' . Plugin::NS_CALENDARSERVER . '}invite', + '{'.Plugin::NS_CALENDARSERVER.'}shared-url', + '{'.Plugin::NS_CALENDARSERVER.'}invite', ]); - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']); + $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']); //$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']); - } - function testUpdateResourceType() { - + public function testUpdateResourceType() + { $this->caldavBackend->updateInvites(1, [ new Sharee([ 'href' => 'mailto:joe@example.org', - ]) + ]), ] ); $result = $this->server->updateProperties('calendars/user1/cal1', [ - '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection']) + '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection']), ]); $this->assertEquals([ - '{DAV:}resourcetype' => 200 + '{DAV:}resourcetype' => 200, ], $result); $this->assertEquals(0, count($this->caldavBackend->getInvites(1))); - } - function testUpdatePropertiesPassThru() { - + public function testUpdatePropertiesPassThru() + { $result = $this->server->updateProperties('calendars/user1/cal3', [ '{DAV:}foo' => 'bar', ]); @@ -125,52 +120,48 @@ class SharingPluginTest extends \Sabre\DAVServerTest { $this->assertEquals([ '{DAV:}foo' => 200, ], $result); - } - function testUnknownMethodNoPOST() { - + public function testUnknownMethodNoPOST() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/', + 'REQUEST_URI' => '/', ]); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } - function testUnknownMethodNoXML() { - + public function testUnknownMethodNoXML() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/', - 'CONTENT_TYPE' => 'text/plain', + 'REQUEST_URI' => '/', + 'CONTENT_TYPE' => 'text/plain', ]); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } - function testUnknownMethodNoNode() { - + public function testUnknownMethodNoNode() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/foo', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/foo', + 'CONTENT_TYPE' => 'text/xml', ]); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } - function testShareRequest() { - + public function testShareRequest() + { $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); $xml = <<assertEquals( [ new Sharee([ - 'href' => 'mailto:joe@example.org', + 'href' => 'mailto:joe@example.org', 'properties' => [ '{DAV:}displayname' => 'Joe Shmoe', ], - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, - 'comment' => '', + 'comment' => '', ]), ], $this->caldavBackend->getInvites(1) @@ -214,11 +205,10 @@ RRR; $this->assertTrue( $props['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared-owner') ); - } - function testShareRequestNoShareableCalendar() { - + public function testShareRequestNoShareableCalendar() + { $request = new HTTP\Request( 'POST', '/calendars/user1/cal2', @@ -226,7 +216,7 @@ RRR; ); $xml = ' - + mailto:joe@example.org Joe Shmoe @@ -241,19 +231,18 @@ RRR; $request->setBody($xml); $response = $this->request($request, 403); - } - function testInviteReply() { - + public function testInviteReply() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/calendars/user1', + 'CONTENT_TYPE' => 'text/xml', ]); $xml = ' - + /principals/owner @@ -262,37 +251,35 @@ RRR; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(200, $response->status, $response->body); - } - function testInviteBadXML() { - + public function testInviteBadXML() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/calendars/user1', + 'CONTENT_TYPE' => 'text/xml', ]); $xml = ' - + '; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(400, $response->status, $response->body); - } - function testInviteWrongUrl() { - + public function testInviteWrongUrl() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal1', - 'CONTENT_TYPE' => 'text/xml', + 'REQUEST_URI' => '/calendars/user1/cal1', + 'CONTENT_TYPE' => 'text/xml', ]); $xml = ' - + /principals/owner '; @@ -303,27 +290,33 @@ RRR; // If the plugin did not handle this request, it must ensure that the // body is still accessible by other plugins. $this->assertEquals($xml, $request->getBody(true)); - } - function testPublish() { + public function testPostWithoutContentType() + { + $request = new HTTP\Request('POST', '/'); + $response = new HTTP\ResponseMock(); + + $this->caldavSharingPlugin->httpPost($request, $response); + $this->assertTrue(true); + } + public function testPublish() + { $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); $xml = ' - + '; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(202, $response->status, $response->body); - } - - function testUnpublish() { - + public function testUnpublish() + { $request = new HTTP\Request( 'POST', '/calendars/user1/cal1', @@ -331,18 +324,17 @@ RRR; ); $xml = ' - + '; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(200, $response->status, $response->body); - } - function testPublishWrongUrl() { - + public function testPublishWrongUrl() + { $request = new HTTP\Request( 'POST', '/calendars/user1', @@ -350,34 +342,31 @@ RRR; ); $xml = ' - + '; $request->setBody($xml); $this->request($request, 501); - } - function testUnpublishWrongUrl() { - + public function testUnpublishWrongUrl() + { $request = new HTTP\Request( 'POST', '/calendars/user1', ['Content-Type' => 'text/xml'] ); $xml = ' - + '; $request->setBody($xml); $this->request($request, 501); - } - function testUnknownXmlDoc() { - - + public function testUnknownXmlDoc() + { $request = new HTTP\Request( 'POST', '/calendars/user1/cal2', @@ -385,12 +374,11 @@ RRR; ); $xml = ' -'; +'; $request->setBody($xml); $response = $this->request($request); $this->assertEquals(501, $response->status, $response->body); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php index 673d39c0a..72b5080af 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php @@ -1,39 +1,41 @@ createCalendar( 'principals/user1', 'UUID-123467', [ - '{DAV:}displayname' => 'user1 calendar', + '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', ] ); $backend->createCalendar( 'principals/user1', 'UUID-123468', [ - '{DAV:}displayname' => 'user1 calendar2', + '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', + '{http://apple.com/ns/ical/}calendar-order' => '1', + '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', ] ); $backend->createCalendarObject($calendarId, 'UUID-2345', self::getTestCalendarData()); - return $backend; + return $backend; } - static function getTestCalendarData($type = 1) { - + public static function getTestCalendarData($type = 1) + { $calendarData = 'BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Apple Inc.//iCal 4.0.1//EN @@ -62,108 +64,104 @@ SUMMARY:Something here DTSTAMP:20100228T130202Z'; switch ($type) { - case 1 : + case 1: $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\n"; break; - case 2 : + case 2: $calendarData .= "\nDTSTART:20100223T060000\nDTEND:20100223T070000\n"; break; - case 3 : + case 3: $calendarData .= "\nDTSTART;VALUE=DATE:20100223\nDTEND;VALUE=DATE:20100223\n"; break; - case 4 : + case 4: $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:PT1H\n"; break; - case 5 : + case 5: $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:-P5D\n"; break; - case 6 : + case 6: $calendarData .= "\nDTSTART;VALUE=DATE:20100223\n"; break; - case 7 : + case 7: $calendarData .= "\nDTSTART;VALUE=DATETIME:20100223T060000\n"; break; // No DTSTART, so intentionally broken - case 'X' : + case 'X': $calendarData .= "\n"; break; } - $calendarData .= 'ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com SEQUENCE:2 END:VEVENT END:VCALENDAR'; return $calendarData; - } - static function getTestTODO($type = 'due') { - + public static function getTestTODO($type = 'due') + { switch ($type) { - - case 'due' : - $extra = "DUE:20100104T000000Z"; + case 'due': + $extra = 'DUE:20100104T000000Z'; break; - case 'due2' : - $extra = "DUE:20060104T000000Z"; + case 'due2': + $extra = 'DUE:20060104T000000Z'; break; - case 'due_date' : - $extra = "DUE;VALUE=DATE:20060104"; + case 'due_date': + $extra = 'DUE;VALUE=DATE:20060104'; break; - case 'due_tz' : - $extra = "DUE;TZID=Asia/Seoul:20060104T000000Z"; + case 'due_tz': + $extra = 'DUE;TZID=Asia/Seoul:20060104T000000Z'; break; - case 'due_dtstart' : + case 'due_dtstart': $extra = "DTSTART:20050223T060000Z\nDUE:20060104T000000Z"; break; - case 'due_dtstart2' : + case 'due_dtstart2': $extra = "DTSTART:20090223T060000Z\nDUE:20100104T000000Z"; break; - case 'dtstart' : + case 'dtstart': $extra = 'DTSTART:20100223T060000Z'; break; - case 'dtstart2' : + case 'dtstart2': $extra = 'DTSTART:20060223T060000Z'; break; - case 'dtstart_date' : + case 'dtstart_date': $extra = 'DTSTART;VALUE=DATE:20100223'; break; - case 'dtstart_tz' : + case 'dtstart_tz': $extra = 'DTSTART;TZID=Asia/Seoul:20100223T060000Z'; break; - case 'dtstart_duration' : + case 'dtstart_duration': $extra = "DTSTART:20061023T060000Z\nDURATION:PT1H"; break; - case 'dtstart_duration2' : + case 'dtstart_duration2': $extra = "DTSTART:20101023T060000Z\nDURATION:PT1H"; break; - case 'completed' : + case 'completed': $extra = 'COMPLETED:20060601T000000Z'; break; - case 'completed2' : + case 'completed2': $extra = 'COMPLETED:20090601T000000Z'; break; - case 'created' : + case 'created': $extra = 'CREATED:20060601T000000Z'; break; - case 'created2' : + case 'created2': $extra = 'CREATED:20090601T000000Z'; break; - case 'completedcreated' : + case 'completedcreated': $extra = "CREATED:20060601T000000Z\nCOMPLETED:20070101T000000Z"; break; - case 'completedcreated2' : + case 'completedcreated2': $extra = "CREATED:20090601T000000Z\nCOMPLETED:20100101T000000Z"; break; - case 'notime' : + case 'notime': $extra = 'X-FILLER:oh hello'; break; - default : - throw new Exception('Unknown type: ' . $type); - + default: + throw new Exception('Unknown type: '.$type); } $todo = 'BEGIN:VCALENDAR @@ -171,7 +169,7 @@ VERSION:2.0 PRODID:-//Example Corp.//CalDAV Client//EN BEGIN:VTODO DTSTAMP:20060205T235335Z -' . $extra . ' +'.$extra.' STATUS:NEEDS-ACTION SUMMARY:Task #1 UID:DDDEEB7915FA61233B861457@example.com @@ -183,7 +181,5 @@ END:VTODO END:VCALENDAR'; return $todo; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php index 629df90c1..e6d1edace 100644 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php @@ -1,5 +1,7 @@ 'calendar1', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar1', + 'id' => 'calendar1', + 'principaluri' => 'principals/admin', + 'uri' => 'calendar1', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO', 'VJOURNAL']), ], [ - 'id' => 'calendar2', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar2', + 'id' => 'calendar2', + 'principaluri' => 'principals/admin', + 'uri' => 'calendar2', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VJOURNAL']), - ] + ], ]; $this->calBackend = new Backend\Mock($calendars, []); @@ -52,33 +54,30 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase { $response = new HTTP\ResponseMock(); $this->server->httpResponse = $response; - } - function request(HTTP\Request $request) { - + public function request(HTTP\Request $request) + { $this->server->httpRequest = $request; $this->server->exec(); return $this->server->httpResponse; - } - function testCreateFile() { - + public function testCreateFile() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $response = $this->request($request); $this->assertEquals(415, $response->status); - } - function testCreateFileValid() { - + public function testCreateFileValid() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -101,26 +100,25 @@ ICS; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"' . md5($ics) . '"'], + 'Content-Length' => ['0'], + 'ETag' => ['"'.md5($ics).'"'], ], $response->getHeaders()); $expected = [ - 'uri' => 'blabla.ics', + 'uri' => 'blabla.ics', 'calendardata' => $ics, - 'calendarid' => 'calendar1', + 'calendarid' => 'calendar1', 'lastmodified' => null, ]; $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - function testCreateFileNoVersion() { - + public function testCreateFileNoVersion() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -142,12 +140,11 @@ ICS; $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileNoVersionFixed() { - + public function testCreateFileNoVersionFixed() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -169,10 +166,10 @@ ICS; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], + 'X-Sabre-Version' => [DAV\Version::VERSION], + 'Content-Length' => ['0'], 'X-Sabre-Ew-Gross' => ['iCalendar validation warning: VERSION MUST appear exactly once in a VCALENDAR component'], ], $response->getHeaders()); @@ -190,18 +187,17 @@ END:VCALENDAR\r ICS; $expected = [ - 'uri' => 'blabla.ics', + 'uri' => 'blabla.ics', 'calendardata' => $ics, - 'calendarid' => 'calendar1', + 'calendarid' => 'calendar1', 'lastmodified' => null, ]; $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - function testCreateFileNoComponents() { - + public function testCreateFileNoComponents() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics', @@ -217,96 +213,89 @@ ICS; $request->setBody($ics); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileNoUID() { - + public function testCreateFileNoUID() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileVCard() { - + public function testCreateFileVCard() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFile2Components() { - + public function testCreateFile2Components() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VJOURNAL\r\nUID:foo\r\nEND:VJOURNAL\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFile2UIDS() { - + public function testCreateFile2UIDS() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VEVENT\r\nUID:bar\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testCreateFileWrongComponent() { - + public function testCreateFileWrongComponent() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VFREEBUSY\r\nUID:foo\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testUpdateFile() { - + public function testUpdateFile() + { $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', ]); $response = $this->request($request); $this->assertEquals(415, $response->status); - } - function testUpdateFileParsableBody() { - + public function testUpdateFileParsableBody() + { $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); $request = new HTTP\Request( 'PUT', @@ -330,43 +319,40 @@ ICS; $this->assertEquals(204, $response->status); $expected = [ - 'uri' => 'blabla.ics', + 'uri' => 'blabla.ics', 'calendardata' => $ics, - 'calendarid' => 'calendar1', + 'calendarid' => 'calendar1', 'lastmodified' => null, ]; $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - function testCreateFileInvalidComponent() { - + public function testCreateFileInvalidComponent() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testUpdateFileInvalidComponent() { - + public function testUpdateFileInvalidComponent() + { $this->calBackend->createCalendarObject('calendar2', 'blabla.ics', 'foo'); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', + 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', ]); $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } /** @@ -376,8 +362,8 @@ ICS; * More importantly. If any transformation happens, the etag must no longer * be returned by the server. */ - function testCreateFileModified() { - + public function testCreateFileModified() + { $request = new HTTP\Request( 'PUT', '/calendars/admin/calendar1/blabla.ics' @@ -399,8 +385,7 @@ ICS; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $this->assertNull($response->getHeader('ETag')); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php index 552e2ba77..c945e2c58 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AbstractPluginTest.php @@ -1,13 +1,15 @@ backend = new Backend\Mock(); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $tree = [ new AddressBookRoot($principalBackend, $this->backend), - new DAVACL\PrincipalCollection($principalBackend) + new DAVACL\PrincipalCollection($principalBackend), ]; $this->plugin = new Plugin(); @@ -37,7 +39,5 @@ abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase { $this->server->sapi = new HTTP\SapiMock(); $this->server->addPlugin($this->plugin); $this->server->debugExceptions = true; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php index f8da38a16..6e7e13106 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookQueryTest.php @@ -1,5 +1,7 @@ server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -47,21 +49,19 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', ], ], '/addressbooks/user1/book1/card2' => [ 404 => [ '{DAV:}getetag' => null, ], - ] + ], ], $result); - - } - function testQueryDepth0() { - + public function testQueryDepth0() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1/card1', @@ -87,7 +87,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -97,16 +97,14 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', ], ], ], $result); - - } - function testQueryNoMatch() { - + public function testQueryNoMatch() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1', @@ -132,7 +130,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -140,15 +138,14 @@ class AddressBookQueryTest extends AbstractPluginTest { $result = $client->parseMultiStatus($response->body); $this->assertEquals([], $result); - } - function testQueryLimit() { - + public function testQueryLimit() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', - 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/addressbooks/user1/book1', + 'HTTP_DEPTH' => '1', ]); $request->setBody( @@ -171,7 +168,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -181,16 +178,14 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', ], ], ], $result); - - } - function testJson() { - + public function testJson() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1/card1', @@ -214,7 +209,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -226,16 +221,15 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', - '{urn:ietf:params:xml:ns:carddav}address-data' => '["vcard",[["version",{},"text","4.0"],["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject ' . $vobjVersion . '\/\/EN"],["uid",{},"text","12345"]]]', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', + '{urn:ietf:params:xml:ns:carddav}address-data' => '["vcard",[["version",{},"text","4.0"],["prodid",{},"text","-\/\/Sabre\/\/Sabre VObject '.$vobjVersion.'\/\/EN"],["uid",{},"text","12345"]]]', ], ], ], $result); - } - function testVCard4() { - + public function testVCard4() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1/card1', @@ -259,7 +253,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -271,16 +265,15 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:-//Sabre//Sabre VObject $vobjVersion//EN\r\nUID:12345\r\nEND:VCARD\r\n", ], ], ], $result); - } - function testAddressBookDepth0() { - + public function testAddressBookDepth0() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book1', @@ -304,11 +297,11 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(415, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(415, $response->status, 'Incorrect status code. Full response body:'.$response->body); } - function testAddressBookProperties() { - + public function testAddressBookProperties() + { $request = new HTTP\Request( 'REPORT', '/addressbooks/user1/book3', @@ -335,7 +328,7 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -345,11 +338,10 @@ class AddressBookQueryTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book3/card3' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nFN:Test-Card\nEMAIL;TYPE=home:bar@example.org\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nFN:Test-Card\nEMAIL;TYPE=home:bar@example.org\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:3.0\r\nUID:12345\r\nFN:Test-Card\r\nEND:VCARD\r\n", ], ], ], $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php index fc20480f2..c4aff2712 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookRootTest.php @@ -1,22 +1,23 @@ assertEquals('addressbooks', $root->getName()); - } - function testGetChildForPrincipal() { - + public function testGetChildForPrincipal() + { $pBackend = new DAVACL\PrincipalBackend\Mock(); $cBackend = new Backend\Mock(); $root = new AddressBookRoot($pBackend, $cBackend); @@ -26,6 +27,5 @@ class AddressBookRootTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\CardDAV\\AddressBookHome', $children[0]); $this->assertEquals('user1', $children[0]->getName()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php index 1f0064dd3..879816803 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/AddressBookTest.php @@ -1,11 +1,13 @@ backend = new Backend\Mock(); $this->ab = new AddressBook( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', '{DAV:}displayname' => 'd-name', - 'principaluri' => 'principals/user1', + 'principaluri' => 'principals/user1', ] ); - } - function testGetName() { - + public function testGetName() + { $this->assertEquals('book1', $this->ab->getName()); - } - function testGetChild() { - + public function testGetChild() + { $card = $this->ab->getChild('card1'); $this->assertInstanceOf('Sabre\\CardDAV\\Card', $card); $this->assertEquals('card1', $card->getName()); - } /** - * @expectedException Sabre\DAV\Exception\NotFound + * @expectedException \Sabre\DAV\Exception\NotFound */ - function testGetChildNotFound() { - + public function testGetChildNotFound() + { $card = $this->ab->getChild('card3'); - } - function testGetChildren() { - + public function testGetChildren() + { $cards = $this->ab->getChildren(); $this->assertEquals(2, count($cards)); $this->assertEquals('card1', $cards[0]->getName()); $this->assertEquals('card2', $cards[1]->getName()); - } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testCreateDirectory() { - + public function testCreateDirectory() + { $this->ab->createDirectory('name'); - } - function testCreateFile() { - + public function testCreateFile() + { $file = fopen('php://memory', 'r+'); fwrite($file, 'foo'); rewind($file); $this->ab->createFile('card2', $file); $this->assertEquals('foo', $this->backend->cards['foo']['card2']); - } - function testDelete() { - + public function testDelete() + { $this->ab->delete(); $this->assertEquals(1, count($this->backend->addressBooks)); - } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testSetName() { - + public function testSetName() + { $this->ab->setName('foo'); - } - function testGetLastModified() { - + public function testGetLastModified() + { $this->assertNull($this->ab->getLastModified()); - } - function testUpdateProperties() { - + public function testUpdateProperties() + { $propPatch = new PropPatch([ '{DAV:}displayname' => 'barrr', ]); @@ -113,20 +105,18 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($propPatch->commit()); $this->assertEquals('barrr', $this->backend->addressBooks[0]['{DAV:}displayname']); - } - function testGetProperties() { - + public function testGetProperties() + { $props = $this->ab->getProperties(['{DAV:}displayname']); $this->assertEquals([ '{DAV:}displayname' => 'd-name', ], $props); - } - function testACLMethods() { - + public function testACLMethods() + { $this->assertEquals('principals/user1', $this->ab->getOwner()); $this->assertNull($this->ab->getGroup()); $this->assertEquals([ @@ -136,39 +126,35 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $this->ab->getACL()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - - $this->ab->setACL([]); - + public function testSetACL() + { + $this->ab->setACL([]); } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $this->assertNull( $this->ab->getSupportedPrivilegeSet() ); - } - function testGetSyncTokenNoSyncSupport() { - + public function testGetSyncTokenNoSyncSupport() + { $this->assertNull($this->ab->getSyncToken()); - } - function testGetChangesNoSyncSupport() { + public function testGetChangesNoSyncSupport() + { $this->assertNull($this->ab->getChanges(1, null)); - } - function testGetSyncToken() { - + public function testGetSyncToken() + { $this->driver = 'sqlite'; $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']); $this->createSchema('addressbooks'); @@ -179,8 +165,8 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(2, $ab->getSyncToken()); } - function testGetSyncToken2() { - + public function testGetSyncToken2() + { $this->driver = 'sqlite'; $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']); $this->createSchema('addressbooks'); @@ -190,5 +176,4 @@ class AddressBookTest extends \PHPUnit_Framework_TestCase { $ab = new AddressBook($backend, ['id' => 1, '{http://sabredav.org/ns}sync-token' => 2]); $this->assertEquals(2, $ab->getSyncToken()); } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php index f62bfb1ae..e5bd088fc 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/AbstractPDOTest.php @@ -1,12 +1,14 @@ dropTables([ 'addressbooks', 'cards', @@ -26,36 +28,34 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->backend = new PDO($pdo); $pdo->exec("INSERT INTO addressbooks (principaluri, displayname, uri, description, synctoken) VALUES ('principals/user1', 'book1', 'book1', 'addressbook 1', 1)"); - $pdo->exec("INSERT INTO cards (addressbookid, carddata, uri, lastmodified, etag, size) VALUES (1, 'card1', 'card1', 0, '" . md5('card1') . "', 5)"); - + $pdo->exec("INSERT INTO cards (addressbookid, carddata, uri, lastmodified, etag, size) VALUES (1, 'card1', 'card1', 0, '".md5('card1')."', 5)"); } - function testGetAddressBooksForUser() { - + public function testGetAddressBooksForUser() + { $result = $this->backend->getAddressBooksForUser('principals/user1'); $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $this->assertEquals($expected, $result); - } - function testUpdateAddressBookInvalidProp() { - + public function testUpdateAddressBookInvalidProp() + { $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', - '{DAV:}foo' => 'bar', + '{DAV:}displayname' => 'updated', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', + '{DAV:}foo' => 'bar', ]); $this->backend->updateAddressBook(1, $propPatch); @@ -67,22 +67,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $this->assertEquals($expected, $result); - } - function testUpdateAddressBookNoProps() { - + public function testUpdateAddressBookNoProps() + { $propPatch = new PropPatch([ ]); @@ -94,26 +93,24 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $this->assertEquals($expected, $result); - - } - function testUpdateAddressBookSuccess() { - + public function testUpdateAddressBookSuccess() + { $propPatch = new PropPatch([ - '{DAV:}displayname' => 'updated', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', + '{DAV:}displayname' => 'updated', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', ]); $this->backend->updateAddressBook(1, $propPatch); @@ -125,101 +122,95 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'updated', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'updated', - '{http://calendarserver.org/ns/}getctag' => 2, - '{http://sabredav.org/ns}sync-token' => 2 - ] + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'updated', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'updated', + '{http://calendarserver.org/ns/}getctag' => 2, + '{http://sabredav.org/ns}sync-token' => 2, + ], ]; $this->assertEquals($expected, $result); - - } - function testDeleteAddressBook() { - + public function testDeleteAddressBook() + { $this->backend->deleteAddressBook(1); $this->assertEquals([], $this->backend->getAddressBooksForUser('principals/user1')); - } /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testCreateAddressBookUnsupportedProp() { - + public function testCreateAddressBookUnsupportedProp() + { $this->backend->createAddressBook('principals/user1', 'book2', [ '{DAV:}foo' => 'bar', ]); - } - function testCreateAddressBookSuccess() { - + public function testCreateAddressBookSuccess() + { $this->backend->createAddressBook('principals/user1', 'book2', [ - '{DAV:}displayname' => 'book2', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2', + '{DAV:}displayname' => 'book2', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 2', ]); $expected = [ [ - 'id' => 1, - 'uri' => 'book1', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book1', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 1', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, + 'id' => 1, + 'uri' => 'book1', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book1', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 1', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, ], [ - 'id' => 2, - 'uri' => 'book2', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'book2', - '{' . CardDAV\Plugin::NS_CARDDAV . '}addressbook-description' => 'addressbook 2', - '{http://calendarserver.org/ns/}getctag' => 1, - '{http://sabredav.org/ns}sync-token' => 1, - ] + 'id' => 2, + 'uri' => 'book2', + 'principaluri' => 'principals/user1', + '{DAV:}displayname' => 'book2', + '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => 'addressbook 2', + '{http://calendarserver.org/ns/}getctag' => 1, + '{http://sabredav.org/ns}sync-token' => 1, + ], ]; $result = $this->backend->getAddressBooksForUser('principals/user1'); $this->assertEquals($expected, $result); - } - function testGetCards() { - + public function testGetCards() + { $result = $this->backend->getCards(1); $expected = [ [ - 'id' => 1, - 'uri' => 'card1', + 'id' => 1, + 'uri' => 'card1', 'lastmodified' => 0, - 'etag' => '"' . md5('card1') . '"', - 'size' => 5 - ] + 'etag' => '"'.md5('card1').'"', + 'size' => 5, + ], ]; $this->assertEquals($expected, $result); - } - function testGetCard() { - + public function testGetCard() + { $result = $this->backend->getCard(1, 'card1'); $expected = [ - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', 'lastmodified' => 0, - 'etag' => '"' . md5('card1') . '"', - 'size' => 5 + 'etag' => '"'.md5('card1').'"', + 'size' => 5, ]; if (is_resource($result['carddata'])) { @@ -227,16 +218,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { } $this->assertEquals($expected, $result); - } /** * @depends testGetCard */ - function testCreateCard() { - + public function testCreateCard() + { $result = $this->backend->createCard(1, 'card2', 'data2'); - $this->assertEquals('"' . md5('data2') . '"', $result); + $this->assertEquals('"'.md5('data2').'"', $result); $result = $this->backend->getCard(1, 'card2'); $this->assertEquals(2, $result['id']); $this->assertEquals('card2', $result['uri']); @@ -244,33 +234,32 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result['carddata'] = stream_get_contents($result['carddata']); } $this->assertEquals('data2', $result['carddata']); - } /** * @depends testCreateCard */ - function testGetMultiple() { - + public function testGetMultiple() + { $result = $this->backend->createCard(1, 'card2', 'data2'); $result = $this->backend->createCard(1, 'card3', 'data3'); $check = [ [ - 'id' => 1, - 'uri' => 'card1', - 'carddata' => 'card1', + 'id' => 1, + 'uri' => 'card1', + 'carddata' => 'card1', 'lastmodified' => 0, ], [ - 'id' => 2, - 'uri' => 'card2', - 'carddata' => 'data2', + 'id' => 2, + 'uri' => 'card2', + 'carddata' => 'data2', 'lastmodified' => time(), ], [ - 'id' => 3, - 'uri' => 'card3', - 'carddata' => 'data3', + 'id' => 3, + 'uri' => 'card3', + 'carddata' => 'data3', 'lastmodified' => time(), ], ]; @@ -278,40 +267,34 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $this->backend->getMultipleCards(1, ['card1', 'card2', 'card3']); foreach ($check as $index => $node) { - foreach ($node as $k => $v) { - $expected = $v; $actual = $result[$index][$k]; switch ($k) { - case 'lastmodified' : + case 'lastmodified': $this->assertInternalType('int', $actual); break; - case 'carddata' : + case 'carddata': if (is_resource($actual)) { $actual = stream_get_contents($actual); } - // No break intended. - default : + // no break intended. + default: $this->assertEquals($expected, $actual); break; } - } - } - - } /** * @depends testGetCard */ - function testUpdateCard() { - + public function testUpdateCard() + { $result = $this->backend->updateCard(1, 'card1', 'newdata'); - $this->assertEquals('"' . md5('newdata') . '"', $result); + $this->assertEquals('"'.md5('newdata').'"', $result); $result = $this->backend->getCard(1, 'card1'); $this->assertEquals(1, $result['id']); @@ -319,22 +302,20 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result['carddata'] = stream_get_contents($result['carddata']); } $this->assertEquals('newdata', $result['carddata']); - } /** * @depends testGetCard */ - function testDeleteCard() { - + public function testDeleteCard() + { $this->backend->deleteCard(1, 'card1'); $result = $this->backend->getCard(1, 'card1'); $this->assertFalse($result); - } - function testGetChanges() { - + public function testGetChanges() + { $backend = $this->backend; $id = $backend->createAddressBook( 'principals/user1', @@ -345,29 +326,28 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'syncToken' => 1, - "added" => [], - 'modified' => [], - 'deleted' => [], + 'added' => [], + 'modified' => [], + 'deleted' => [], ], $result); $currentToken = $result['syncToken']; $dummyCard = "BEGIN:VCARD\r\nEND:VCARD\r\n"; - $backend->createCard($id, "card1.ics", $dummyCard); - $backend->createCard($id, "card2.ics", $dummyCard); - $backend->createCard($id, "card3.ics", $dummyCard); - $backend->updateCard($id, "card1.ics", $dummyCard); - $backend->deleteCard($id, "card2.ics"); + $backend->createCard($id, 'card1.ics', $dummyCard); + $backend->createCard($id, 'card2.ics', $dummyCard); + $backend->createCard($id, 'card3.ics', $dummyCard); + $backend->updateCard($id, 'card1.ics', $dummyCard); + $backend->deleteCard($id, 'card2.ics'); $result = $backend->getChangesForAddressBook($id, $currentToken, 1); $this->assertEquals([ 'syncToken' => 6, - 'modified' => ["card1.ics"], - 'deleted' => ["card2.ics"], - "added" => ["card3.ics"], + 'modified' => ['card1.ics'], + 'deleted' => ['card2.ics'], + 'added' => ['card3.ics'], ], $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php index 8638dc74a..f7e20fbfb 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/Mock.php @@ -1,29 +1,31 @@ addressBooks = $addressBooks; $this->cards = $cards; if (is_null($this->addressBooks)) { $this->addressBooks = [ [ - 'id' => 'foo', - 'uri' => 'book1', - 'principaluri' => 'principals/user1', + 'id' => 'foo', + 'uri' => 'book1', + 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'd-name', ], [ - 'id' => 'bar', - 'uri' => 'book3', - 'principaluri' => 'principals/user1', + 'id' => 'bar', + 'uri' => 'book3', + 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'd-name', ], ]; @@ -41,20 +43,18 @@ class Mock extends AbstractBackend { ], ]; } - } - - function getAddressBooksForUser($principalUri) { - + public function getAddressBooksForUser($principalUri) + { $books = []; foreach ($this->addressBooks as $book) { if ($book['principaluri'] === $principalUri) { $books[] = $book; } } - return $books; + return $books; } /** @@ -69,45 +69,43 @@ class Mock extends AbstractBackend { * * Read the PropPatch documentation for more info and examples. * - * @param string $addressBookId + * @param string $addressBookId * @param \Sabre\DAV\PropPatch $propPatch - * @return void */ - function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) { - + public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) + { foreach ($this->addressBooks as &$book) { - if ($book['id'] !== $addressBookId) + if ($book['id'] !== $addressBookId) { continue; + } - $propPatch->handleRemaining(function($mutations) use (&$book) { + $propPatch->handleRemaining(function ($mutations) use (&$book) { foreach ($mutations as $key => $value) { $book[$key] = $value; } + return true; }); - } - } - function createAddressBook($principalUri, $url, array $properties) { - + public function createAddressBook($principalUri, $url, array $properties) + { $this->addressBooks[] = array_merge($properties, [ - 'id' => $url, - 'uri' => $url, + 'id' => $url, + 'uri' => $url, 'principaluri' => $principalUri, ]); - } - function deleteAddressBook($addressBookId) { - + public function deleteAddressBook($addressBookId) + { foreach ($this->addressBooks as $key => $value) { - if ($value['id'] === $addressBookId) + if ($value['id'] === $addressBookId) { unset($this->addressBooks[$key]); + } } unset($this->cards[$addressBookId]); - } /** @@ -127,28 +125,29 @@ class Mock extends AbstractBackend { * This may speed up certain requests, especially with large cards. * * @param mixed $addressBookId + * * @return array */ - function getCards($addressBookId) { - + public function getCards($addressBookId) + { $cards = []; foreach ($this->cards[$addressBookId] as $uri => $data) { if (is_resource($data)) { $cards[] = [ - 'uri' => $uri, + 'uri' => $uri, 'carddata' => $data, ]; } else { $cards[] = [ - 'uri' => $uri, + 'uri' => $uri, 'carddata' => $data, - 'etag' => '"' . md5($data) . '"', - 'size' => strlen($data) + 'etag' => '"'.md5($data).'"', + 'size' => strlen($data), ]; } } - return $cards; + return $cards; } /** @@ -159,24 +158,25 @@ class Mock extends AbstractBackend { * * If the card does not exist, you must return false. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri + * * @return array */ - function getCard($addressBookId, $cardUri) { - + public function getCard($addressBookId, $cardUri) + { if (!isset($this->cards[$addressBookId][$cardUri])) { return false; } $data = $this->cards[$addressBookId][$cardUri]; + return [ - 'uri' => $cardUri, + 'uri' => $cardUri, 'carddata' => $data, - 'etag' => '"' . md5($data) . '"', - 'size' => strlen($data) + 'etag' => '"'.md5($data).'"', + 'size' => strlen($data), ]; - } /** @@ -199,19 +199,20 @@ class Mock extends AbstractBackend { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function createCard($addressBookId, $cardUri, $cardData) { - + public function createCard($addressBookId, $cardUri, $cardData) + { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); } $this->cards[$addressBookId][$cardUri] = $cardData; - return '"' . md5($cardData) . '"'; + return '"'.md5($cardData).'"'; } /** @@ -234,25 +235,24 @@ class Mock extends AbstractBackend { * * If you don't return an ETag, you can just return null. * - * @param mixed $addressBookId + * @param mixed $addressBookId * @param string $cardUri * @param string $cardData + * * @return string|null */ - function updateCard($addressBookId, $cardUri, $cardData) { - + public function updateCard($addressBookId, $cardUri, $cardData) + { if (is_resource($cardData)) { $cardData = stream_get_contents($cardData); } $this->cards[$addressBookId][$cardUri] = $cardData; - return '"' . md5($cardData) . '"'; + return '"'.md5($cardData).'"'; } - function deleteCard($addressBookId, $cardUri) { - + public function deleteCard($addressBookId, $cardUri) + { unset($this->cards[$addressBookId][$cardUri]); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php index c1b0e274e..718eec6be 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php @@ -1,9 +1,10 @@ backend = new Backend\Mock(); $this->card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', + 'carddata' => 'card', ] ); - } - function testGet() { - + public function testGet() + { $result = $this->card->get(); $this->assertEquals('card', $result); - } - function testGet2() { + public function testGet2() + { $this->card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', ] ); $result = $this->card->get(); $this->assertEquals("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", $result); - } - /** * @depends testGet */ - function testPut() { - + public function testPut() + { $file = fopen('php://memory', 'r+'); fwrite($file, 'newdata'); rewind($file); $this->card->put($file); $result = $this->card->get(); $this->assertEquals('newdata', $result); - } - - function testDelete() { - + public function testDelete() + { $this->card->delete(); $this->assertEquals(1, count($this->backend->cards['foo'])); - } - function testGetContentType() { - + public function testGetContentType() + { $this->assertEquals('text/vcard; charset=utf-8', $this->card->getContentType()); - } - function testGetETag() { - - $this->assertEquals('"' . md5('card') . '"', $this->card->getETag()); - + public function testGetETag() + { + $this->assertEquals('"'.md5('card').'"', $this->card->getETag()); } - function testGetETag2() { - + public function testGetETag2() + { $card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', - 'etag' => '"blabla"', + 'carddata' => 'card', + 'etag' => '"blabla"', ] ); $this->assertEquals('"blabla"', $card->getETag()); - } - function testGetLastModified() { - + public function testGetLastModified() + { $this->assertEquals(null, $this->card->getLastModified()); - } - function testGetSize() { - + public function testGetSize() + { $this->assertEquals(4, $this->card->getSize()); $this->assertEquals(4, $this->card->getSize()); - } - function testGetSize2() { - + public function testGetSize2() + { $card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'etag' => '"blabla"', - 'size' => 4, + 'etag' => '"blabla"', + 'size' => 4, ] ); $this->assertEquals(4, $card->getSize()); - } - function testACLMethods() { - + public function testACLMethods() + { $this->assertEquals('principals/user1', $this->card->getOwner()); $this->assertNull($this->card->getGroup()); $this->assertEquals([ @@ -156,22 +146,22 @@ class CardTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $this->card->getACL()); - } - function testOverrideACL() { + public function testOverrideACL() + { $card = new Card( $this->backend, [ - 'uri' => 'book1', - 'id' => 'foo', + 'uri' => 'book1', + 'id' => 'foo', 'principaluri' => 'principals/user1', ], [ - 'uri' => 'card1', + 'uri' => 'card1', 'addressbookid' => 'foo', - 'carddata' => 'card', - 'acl' => [ + 'carddata' => 'card', + 'acl' => [ [ 'privilege' => '{DAV:}read', 'principal' => 'principals/user1', @@ -187,24 +177,20 @@ class CardTest extends \PHPUnit_Framework_TestCase { 'protected' => true, ], ], $card->getACL()); - } /** - * @expectedException Sabre\DAV\Exception\Forbidden + * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACL() { - - $this->card->setACL([]); - + public function testSetACL() + { + $this->card->setACL([]); } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $this->assertNull( $this->card->getSupportedPrivilegeSet() ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php index 4796a131f..760749f6c 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/IDirectoryTest.php @@ -1,15 +1,17 @@ addPlugin($plugin); $props = $server->getProperties('directory', ['{DAV:}resourcetype']); - $this->assertTrue($props['{DAV:}resourcetype']->is('{' . Plugin::NS_CARDDAV . '}directory')); - + $this->assertTrue($props['{DAV:}resourcetype']->is('{'.Plugin::NS_CARDDAV.'}directory')); } - } -class DirectoryMock extends DAV\SimpleCollection implements IDirectory { - - - +class DirectoryMock extends DAV\SimpleCollection implements IDirectory +{ } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php index 2d57c6ae7..4e3276ed3 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/MultiGetTest.php @@ -1,5 +1,7 @@ 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', + 'REQUEST_URI' => '/addressbooks/user1/book1', ]); $request->setBody( @@ -34,7 +36,7 @@ class MultiGetTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); @@ -44,19 +46,18 @@ class MultiGetTest extends AbstractPluginTest { $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", - ] - ] + ], + ], ], $result); - } - function testMultiGetVCard4() { - + public function testMultiGetVCard4() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'REPORT', - 'REQUEST_URI' => '/addressbooks/user1/book1', + 'REQUEST_URI' => '/addressbooks/user1/book1', ]); $request->setBody( @@ -77,23 +78,22 @@ class MultiGetTest extends AbstractPluginTest { $this->server->exec(); - $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:' . $response->body); + $this->assertEquals(207, $response->status, 'Incorrect status code. Full response body:'.$response->body); // using the client for parsing $client = new DAV\Client(['baseUri' => '/']); $result = $client->parseMultiStatus($response->body); - $prodId = "PRODID:-//Sabre//Sabre VObject " . \Sabre\VObject\Version::VERSION . "//EN"; + $prodId = 'PRODID:-//Sabre//Sabre VObject '.\Sabre\VObject\Version::VERSION.'//EN'; $this->assertEquals([ '/addressbooks/user1/book1/card1' => [ 200 => [ - '{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', + '{DAV:}getetag' => '"'.md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD").'"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\r\nVERSION:4.0\r\n$prodId\r\nUID:12345\r\nEND:VCARD\r\n", - ] - ] + ], + ], ], $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php index 6962e7830..b5a68dc48 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php @@ -1,102 +1,101 @@ assertEquals('{' . Plugin::NS_CARDDAV . '}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']); +class PluginTest extends AbstractPluginTest +{ + public function testConstruct() + { + $this->assertEquals('{'.Plugin::NS_CARDDAV.'}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']); $this->assertTrue(in_array('addressbook', $this->plugin->getFeatures())); $this->assertEquals('carddav', $this->plugin->getPluginInfo()['name']); - } - function testSupportedReportSet() { - + public function testSupportedReportSet() + { $this->assertEquals([ - '{' . Plugin::NS_CARDDAV . '}addressbook-multiget', - '{' . Plugin::NS_CARDDAV . '}addressbook-query', + '{'.Plugin::NS_CARDDAV.'}addressbook-multiget', + '{'.Plugin::NS_CARDDAV.'}addressbook-query', ], $this->plugin->getSupportedReportSet('addressbooks/user1/book1')); - } - function testSupportedReportSetEmpty() { - + public function testSupportedReportSetEmpty() + { $this->assertEquals([ ], $this->plugin->getSupportedReportSet('')); - } - function testAddressBookHomeSet() { - - $result = $this->server->getProperties('principals/user1', ['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']); + public function testAddressBookHomeSet() + { + $result = $this->server->getProperties('principals/user1', ['{'.Plugin::NS_CARDDAV.'}addressbook-home-set']); $this->assertEquals(1, count($result)); - $this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set'])); - $this->assertEquals('addressbooks/user1/', $result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']->getHref()); - + $this->assertTrue(isset($result['{'.Plugin::NS_CARDDAV.'}addressbook-home-set'])); + $this->assertEquals('addressbooks/user1/', $result['{'.Plugin::NS_CARDDAV.'}addressbook-home-set']->getHref()); } - function testDirectoryGateway() { - - $result = $this->server->getProperties('principals/user1', ['{' . Plugin::NS_CARDDAV . '}directory-gateway']); + public function testDirectoryGateway() + { + $result = $this->server->getProperties('principals/user1', ['{'.Plugin::NS_CARDDAV.'}directory-gateway']); $this->assertEquals(1, count($result)); - $this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}directory-gateway'])); - $this->assertEquals(['directory'], $result['{' . Plugin::NS_CARDDAV . '}directory-gateway']->getHrefs()); - + $this->assertTrue(isset($result['{'.Plugin::NS_CARDDAV.'}directory-gateway'])); + $this->assertEquals(['directory'], $result['{'.Plugin::NS_CARDDAV.'}directory-gateway']->getHrefs()); } - function testReportPassThrough() { - + public function testReportPassThrough() + { $this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument(), '')); - } - function testHTMLActionsPanel() { - + public function testHTMLActionsPanel() + { $output = ''; $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('addressbooks/user1'), &$output]); $this->assertFalse($r); - $this->assertTrue(!!strpos($output, 'Display name')); - + $this->assertTrue((bool) strpos($output, 'Display name')); } - function testAddressbookPluginProperties() { - - $ns = '{' . Plugin::NS_CARDDAV . '}'; + public function testAddressbookPluginProperties() + { + $ns = '{'.Plugin::NS_CARDDAV.'}'; $propFind = new DAV\PropFind('addressbooks/user1/book1', [ - $ns . 'supported-address-data', - $ns . 'supported-collation-set', + $ns.'supported-address-data', + $ns.'supported-collation-set', ]); $node = $this->server->tree->getNodeForPath('addressbooks/user1/book1'); $this->plugin->propFindEarly($propFind, $node); $this->assertInstanceOf( 'Sabre\\CardDAV\\Xml\\Property\\SupportedAddressData', - $propFind->get($ns . 'supported-address-data') + $propFind->get($ns.'supported-address-data') ); $this->assertInstanceOf( 'Sabre\\CardDAV\\Xml\\Property\\SupportedCollationSet', - $propFind->get($ns . 'supported-collation-set') + $propFind->get($ns.'supported-collation-set') ); - - } - function testGetTransform() { - - $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept: application/vcard+json']); + public function testGetTransform() + { + $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept' => 'application/vcard+json']); $response = new \Sabre\HTTP\ResponseMock(); $this->server->invokeMethod($request, $response); $this->assertEquals(200, $response->getStatus()); - } + public function testGetWithoutContentType() + { + $request = new \Sabre\HTTP\Request('GET', '/'); + $response = new \Sabre\HTTP\ResponseMock(); + $this->plugin->httpAfterGet($request, $response); + $this->assertTrue(true); + } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php index d4bc48098..8d045569c 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/SogoStripContentTypeTest.php @@ -1,17 +1,19 @@ 1, - 'uri' => 'book1', + 'id' => 1, + 'uri' => 'book1', 'principaluri' => 'principals/user1', ], ]; @@ -21,27 +23,27 @@ class SogoStripContentTypeTest extends \Sabre\DAVServerTest { ], ]; - function testDontStrip() { - + public function testDontStrip() + { $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); $this->assertEquals([ - '{DAV:}getcontenttype' => 'text/vcard; charset=utf-8' + '{DAV:}getcontenttype' => 'text/vcard; charset=utf-8', ], $result); - } - function testStrip() { - $this->server->httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', + public function testStrip() + { + $this->server->httpRequest = new HTTP\Request('GET', '/', [ + 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', ]); $result = $this->server->getProperties('addressbooks/user1/book1/card1.vcf', ['{DAV:}getcontenttype']); $this->assertEquals([ - '{DAV:}getcontenttype' => 'text/x-vcard' + '{DAV:}getcontenttype' => 'text/x-vcard', ], $result); - } - function testDontTouchOtherMimeTypes() { + public function testDontTouchOtherMimeTypes() + { $this->server->httpRequest = new HTTP\Request('GET', '/addressbooks/user1/book1/card1.vcf', [ 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', ]); @@ -50,7 +52,16 @@ class SogoStripContentTypeTest extends \Sabre\DAVServerTest { $propFind->set('{DAV:}getcontenttype', 'text/plain'); $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo')); $this->assertEquals('text/plain', $propFind->get('{DAV:}getcontenttype')); - } + public function testStripWithoutGetContentType() + { + $this->server->httpRequest = new HTTP\Request('GET', '/addressbooks/user1/book1/card1.vcf', [ + 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 Lightning/1.2.1', + ]); + + $propFind = new PropFind('hello', ['{DAV:}getcontenttype']); + $this->carddavPlugin->propFindLate($propFind, new \Sabre\DAV\SimpleCollection('foo')); + $this->assertEquals(null, $propFind->get('{DAV:}getcontenttype')); // Property not present + } } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php index ec8a3501e..0bdf07df5 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/TestUtil.php @@ -1,18 +1,20 @@ 'user1 addressbook', + '{DAV:}displayname' => 'user1 addressbook', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description', ] ); @@ -29,22 +31,23 @@ class TestUtil { 'principals/user1', 'UUID-123468', [ - '{DAV:}displayname' => 'user1 addressbook2', + '{DAV:}displayname' => 'user1 addressbook2', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description', ] ); $backend->createCard($addressbookId, 'UUID-2345', self::getTestCardData()); - return $pdo; + return $pdo; } - static function deleteSQLiteDB() { + public static function deleteSQLiteDB() + { $sqliteTest = new Backend\PDOSqliteTest(); $pdo = $sqliteTest->tearDown(); } - static function getTestCardData() { - + public static function getTestCardData() + { $addressbookData = 'BEGIN:VCARD VERSION:3.0 PRODID:-//Acme Inc.//RoadRunner 1.0//EN @@ -56,7 +59,5 @@ REV:2012-06-20T07:00:39+00:00 END:VCARD'; return $addressbookData; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php index 82d82fadd..d8acc3c14 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/VCFExportTest.php @@ -1,43 +1,44 @@ 'book1', - 'uri' => 'book1', + 'id' => 'book1', + 'uri' => 'book1', 'principaluri' => 'principals/user1', - ] + ], ]; protected $carddavCards = [ 'book1' => [ - "card1" => "BEGIN:VCARD\r\nFN:Person1\r\nEND:VCARD\r\n", - "card2" => "BEGIN:VCARD\r\nFN:Person2\r\nEND:VCARD", - "card3" => "BEGIN:VCARD\r\nFN:Person3\r\nEND:VCARD\r\n", - "card4" => "BEGIN:VCARD\nFN:Person4\nEND:VCARD\n", - ] + 'card1' => "BEGIN:VCARD\r\nFN:Person1\r\nEND:VCARD\r\n", + 'card2' => "BEGIN:VCARD\r\nFN:Person2\r\nEND:VCARD", + 'card3' => "BEGIN:VCARD\r\nFN:Person3\r\nEND:VCARD\r\n", + 'card4' => "BEGIN:VCARD\nFN:Person4\nEND:VCARD\n", + ], ]; - function setUp() { - + public function setUp() + { parent::setUp(); $plugin = new VCFExportPlugin(); $this->server->addPlugin( $plugin ); - } - function testSimple() { - + public function testSimple() + { $plugin = $this->server->getPlugin('vcf-export'); $this->assertInstanceOf('Sabre\\CardDAV\\VCFExportPlugin', $plugin); @@ -45,21 +46,20 @@ class VCFExportTest extends \Sabre\DAVServerTest { 'vcf-export', $plugin->getPluginInfo()['name'] ); - } - function testExport() { - + public function testExport() + { $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_URI' => '/addressbooks/user1/book1?export', - 'QUERY_STRING' => 'export', + 'REQUEST_URI' => '/addressbooks/user1/book1?export', + 'QUERY_STRING' => 'export', 'REQUEST_METHOD' => 'GET', ]); $response = $this->request($request); $this->assertEquals(200, $response->status, $response->body); - $expected = "BEGIN:VCARD + $expected = 'BEGIN:VCARD FN:Person1 END:VCARD BEGIN:VCARD @@ -71,26 +71,24 @@ END:VCARD BEGIN:VCARD FN:Person4 END:VCARD -"; +'; // We actually expected windows line endings $expected = str_replace("\n", "\r\n", $expected); $this->assertEquals($expected, $response->body); - } - function testBrowserIntegration() { - + public function testBrowserIntegration() + { $plugin = $this->server->getPlugin('vcf-export'); $actions = ''; $addressbook = new AddressBook($this->carddavBackend, []); $this->server->emit('browserButtonActions', ['/foo', $addressbook, &$actions]); $this->assertContains('/foo?export', $actions); - } - function testContentDisposition() { - + public function testContentDisposition() + { $request = new HTTP\Request( 'GET', '/addressbooks/user1/book1?export' @@ -99,14 +97,13 @@ END:VCARD $response = $this->request($request, 200); $this->assertEquals('text/directory', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="book1-' . date('Y-m-d') . '.vcf"', + 'attachment; filename="book1-'.date('Y-m-d').'.vcf"', $response->getHeader('Content-Disposition') ); - } - function testContentDispositionBadChars() { - + public function testContentDispositionBadChars() + { $this->carddavBackend->createAddressBook( 'principals/user1', 'book-b_ad"(ch)ars', @@ -126,10 +123,8 @@ END:VCARD $response = $this->request($request, 200); $this->assertEquals('text/directory', $response->getHeader('Content-Type')); $this->assertEquals( - 'attachment; filename="book-b_adchars-' . date('Y-m-d') . '.vcf"', + 'attachment; filename="book-b_adchars-'.date('Y-m-d').'.vcf"', $response->getHeader('Content-Disposition') ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php index 03c468f86..753efc73d 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateFilterTest.php @@ -1,31 +1,32 @@ assertTrue($this->plugin->validateFilters($input, $filters, $test), $message); } else { $this->assertFalse($this->plugin->validateFilters($input, $filters, $test), $message); } - } - function data() { - + public function data() + { $body1 = << 'tel', + 'name' => 'tel', 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => [ + 'test' => 'anyof', + 'param-filters' => [ [ - 'name' => 'type', + 'name' => 'type', 'is-not-defined' => false, - 'text-match' => null + 'text-match' => null, ], ], 'text-matches' => [], @@ -107,16 +108,16 @@ HELLO; // Check if URL contains 'google' $filter11 = [ - 'name' => 'url', + 'name' => 'url', 'is-not-defined' => false, - 'test' => 'anyof', - 'param-filters' => [], - 'text-matches' => [ + 'test' => 'anyof', + 'param-filters' => [], + 'text-matches' => [ [ - 'match-type' => 'contains', - 'value' => 'google', + 'match-type' => 'contains', + 'value' => 'google', 'negate-condition' => false, - 'collation' => 'i;octet', + 'collation' => 'i;octet', ], ], ]; @@ -137,22 +138,21 @@ HELLO; // Param filter with text $filter15 = $filter5; $filter15['param-filters'][0]['text-match'] = [ - 'match-type' => 'contains', - 'value' => 'WORK', - 'collation' => 'i;octet', + 'match-type' => 'contains', + 'value' => 'WORK', + 'collation' => 'i;octet', 'negate-condition' => false, ]; $filter16 = $filter15; $filter16['param-filters'][0]['text-match']['negate-condition'] = true; - // Param filter + text filter $filter17 = $filter5; $filter17['test'] = 'anyof'; $filter17['text-matches'][] = [ - 'match-type' => 'contains', - 'value' => '444', - 'collation' => 'i;octet', + 'match-type' => 'contains', + 'value' => '444', + 'collation' => 'i;octet', 'negate-condition' => false, ]; @@ -162,20 +162,19 @@ HELLO; $filter18['test'] = 'allof'; return [ - // Basic filters - [$body1, [$filter1], 'anyof',true], - [$body1, [$filter2], 'anyof',false], - [$body1, [$filter3], 'anyof',false], - [$body1, [$filter4], 'anyof',true], + [$body1, [$filter1], 'anyof', true], + [$body1, [$filter2], 'anyof', false], + [$body1, [$filter3], 'anyof', false], + [$body1, [$filter4], 'anyof', true], // Combinations - [$body1, [$filter1, $filter2], 'anyof',true], - [$body1, [$filter1, $filter2], 'allof',false], - [$body1, [$filter1, $filter4], 'anyof',true], - [$body1, [$filter1, $filter4], 'allof',true], - [$body1, [$filter2, $filter3], 'anyof',false], - [$body1, [$filter2, $filter3], 'allof',false], + [$body1, [$filter1, $filter2], 'anyof', true], + [$body1, [$filter1, $filter2], 'allof', false], + [$body1, [$filter1, $filter4], 'anyof', true], + [$body1, [$filter1, $filter4], 'allof', true], + [$body1, [$filter2, $filter3], 'anyof', false], + [$body1, [$filter2, $filter3], 'allof', false], // Basic parameters [$body1, [$filter5], 'anyof', true, 'TEL;TYPE is defined, so this should return true'], @@ -203,7 +202,5 @@ HELLO; [$body1, [$filter18], 'anyof', false], [$body1, [$filter18], 'anyof', false], ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php index acba2cfc8..2317b86cc 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/ValidateVCardTest.php @@ -1,5 +1,7 @@ 'addressbook1', + 'id' => 'addressbook1', 'principaluri' => 'principals/admin', - 'uri' => 'addressbook1', - ] + 'uri' => 'addressbook1', + ], ]; $this->cardBackend = new Backend\Mock($addressbooks, []); @@ -39,21 +41,19 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { $response = new HTTP\ResponseMock(); $this->server->httpResponse = $response; - } - function request(HTTP\Request $request, $expectedStatus = null) { - + public function request(HTTP\Request $request, $expectedStatus = null) + { $this->server->httpRequest = $request; $this->server->exec(); if ($expectedStatus) { - $realStatus = $this->server->httpResponse->getStatus(); $msg = ''; if ($realStatus !== $expectedStatus) { - $msg = 'Response body: ' . $this->server->httpResponse->getBodyAsString(); + $msg = 'Response body: '.$this->server->httpResponse->getBodyAsString(); } $this->assertEquals( $expectedStatus, @@ -63,24 +63,22 @@ class ValidateVCardTest extends \PHPUnit_Framework_TestCase { } return $this->server->httpResponse; - } - function testCreateFile() { - + public function testCreateFile() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', + 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', ]); $response = $this->request($request); $this->assertEquals(415, $response->status); - } - function testCreateFileValid() { - + public function testCreateFileValid() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -104,20 +102,18 @@ VCF; ); // Valid, non-auto-fixed responses should contain an ETag. $this->assertTrue( - $response->getHeader('ETag') !== null, + null !== $response->getHeader('ETag'), 'We did not receive an etag' ); - $expected = [ - 'uri' => 'blabla.vcf', + 'uri' => 'blabla.vcf', 'carddata' => $vcard, - 'size' => strlen($vcard), - 'etag' => '"' . md5($vcard) . '"', + 'size' => strlen($vcard), + 'etag' => '"'.md5($vcard).'"', ]; $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } /** @@ -126,8 +122,8 @@ VCF; * * @depends testCreateFileValid */ - function testCreateVCardAutoFix() { - + public function testCreateVCardAutoFix() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -168,14 +164,13 @@ END:VCARD\r VCF; $expected = [ - 'uri' => 'blabla.vcf', + 'uri' => 'blabla.vcf', 'carddata' => $expectedVCard, - 'size' => strlen($expectedVCard), - 'etag' => '"' . md5($expectedVCard) . '"', + 'size' => strlen($expectedVCard), + 'etag' => '"'.md5($expectedVCard).'"', ]; $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } /** @@ -187,8 +182,8 @@ VCF; * * @depends testCreateFileValid */ - function testCreateVCardStrictFail() { - + public function testCreateVCardStrictFail() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf', @@ -209,11 +204,10 @@ VCF; $request->setBody($vcard); $this->request($request, 415); - } - function testCreateFileNoUID() { - + public function testCreateFileNoUID() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -231,13 +225,13 @@ VCF; $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf'); $this->assertTrue( - strpos($foo['carddata'], 'UID') !== false, + false !== strpos($foo['carddata'], 'UID'), print_r($foo, true) ); } - function testCreateFileJson() { - + public function testCreateFileJson() + { $request = new HTTP\Request( 'PUT', '/addressbooks/admin/addressbook1/blabla.vcf' @@ -246,29 +240,27 @@ VCF; $response = $this->request($request); - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); + $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body); $foo = $this->cardBackend->getCard('addressbook1', 'blabla.vcf'); $this->assertEquals("BEGIN:VCARD\r\nVERSION:4.0\r\nUID:foo\r\nFN:FirstName LastName\r\nEND:VCARD\r\n", $foo['carddata']); - } - function testCreateFileVCalendar() { - + public function testCreateFileVCalendar() + { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', + 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf', ]); $request->setBody("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"); $response = $this->request($request); - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body); - + $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body); } - function testUpdateFile() { - + public function testUpdateFile() + { $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); $request = new HTTP\Request( 'PUT', @@ -276,11 +268,10 @@ VCF; ); $response = $this->request($request, 415); - } - function testUpdateFileParsableBody() { - + public function testUpdateFileParsableBody() + { $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo'); $request = new HTTP\Request( 'PUT', @@ -293,13 +284,12 @@ VCF; $response = $this->request($request, 204); $expected = [ - 'uri' => 'blabla.vcf', + 'uri' => 'blabla.vcf', 'carddata' => $body, - 'size' => strlen($body), - 'etag' => '"' . md5($body) . '"', + 'size' => strlen($body), + 'etag' => '"'.md5($body).'"', ]; $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf')); - } } 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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, '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') ); - - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php index 7d7a54d06..3627991bf 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php @@ -1,38 +1,39 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; -class ACLMethodTest extends \PHPUnit_Framework_TestCase { - +class ACLMethodTest extends \PHPUnit\Framework\TestCase +{ /** - * @expectedException Sabre\DAV\Exception\BadRequest + * @expectedException \Sabre\DAV\Exception\BadRequest */ - function testCallback() { - + public function testCallback() + { $acl = new Plugin(); $server = new DAV\Server(); $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpAcl($server->httpRequest, $server->httpResponse); - } /** /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testNotSupportedByNode() { - + public function testNotSupportedByNode() + { $tree = [ new DAV\SimpleCollection('test'), ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request(); + $server->httpRequest = new HTTP\Request('GET', '/'); $body = '<?xml version="1.0"?> <d:acl xmlns:d="DAV:"> </d:acl>'; @@ -41,17 +42,16 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } - function testSuccessSimple() { - + public function testSuccessSimple() + { $tree = [ new MockACLNode('test', []), ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request(); + $server->httpRequest = new HTTP\Request('GET', '/'); $server->httpRequest->setUrl('/test'); $body = '<?xml version="1.0"?> @@ -62,14 +62,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $this->assertFalse($acl->httpACL($server->httpRequest, $server->httpResponse)); - } /** - * @expectedException Sabre\DAVACL\Exception\NotRecognizedPrincipal + * @expectedException \Sabre\DAVACL\Exception\NotRecognizedPrincipal */ - function testUnrecognizedPrincipal() { - + public function testUnrecognizedPrincipal() + { $tree = [ new MockACLNode('test', []), ]; @@ -88,14 +87,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\NotRecognizedPrincipal + * @expectedException \Sabre\DAVACL\Exception\NotRecognizedPrincipal */ - function testUnrecognizedPrincipal2() { - + public function testUnrecognizedPrincipal2() + { $tree = [ new MockACLNode('test', []), new DAV\SimpleCollection('principals', [ @@ -117,14 +115,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\NotSupportedPrivilege + * @expectedException \Sabre\DAVACL\Exception\NotSupportedPrivilege */ - function testUnknownPrivilege() { - + public function testUnknownPrivilege() + { $tree = [ new MockACLNode('test', []), ]; @@ -143,20 +140,19 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\NoAbstract + * @expectedException \Sabre\DAVACL\Exception\NoAbstract */ - function testAbstractPrivilege() { - + public function testAbstractPrivilege() + { $tree = [ new MockACLNode('test', []), ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->on('getSupportedPrivilegeSet', function($node, &$supportedPrivilegeSet) { + $server->on('getSupportedPrivilegeSet', function ($node, &$supportedPrivilegeSet) { $supportedPrivilegeSet['{DAV:}foo'] = ['abstract' => true]; }); $server->httpRequest = new HTTP\Request('ACL', '/test'); @@ -172,14 +168,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\AceConflict + * @expectedException \Sabre\DAVACL\Exception\AceConflict */ - function testUpdateProtectedPrivilege() { - + public function testUpdateProtectedPrivilege() + { $oldACL = [ [ 'principal' => 'principals/notfound', @@ -206,14 +201,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\AceConflict + * @expectedException \Sabre\DAVACL\Exception\AceConflict */ - function testUpdateProtectedPrivilege2() { - + public function testUpdateProtectedPrivilege2() + { $oldACL = [ [ 'principal' => 'principals/notfound', @@ -240,14 +234,13 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } /** - * @expectedException Sabre\DAVACL\Exception\AceConflict + * @expectedException \Sabre\DAVACL\Exception\AceConflict */ - function testUpdateProtectedPrivilege3() { - + public function testUpdateProtectedPrivilege3() + { $oldACL = [ [ 'principal' => 'principals/notfound', @@ -274,11 +267,10 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); - } - function testSuccessComplex() { - + public function testSuccessComplex() + { $oldACL = [ [ 'principal' => 'principals/foo', @@ -317,7 +309,6 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); - $this->assertFalse($acl->httpAcl($server->httpRequest, $server->httpResponse)); $this->assertEquals([ @@ -332,6 +323,5 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { 'protected' => false, ], ], $node->getACL()); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php index f16693625..724abc685 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php @@ -1,18 +1,20 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class AllowAccessTest extends \PHPUnit_Framework_TestCase { - +class AllowAccessTest extends \PHPUnit\Framework\TestCase +{ /** * @var DAV\Server */ protected $server; - function setUp() { - + public function setUp() + { $nodes = [ new DAV\Mock\Collection('testdir', [ 'file1.txt' => 'contents', @@ -27,106 +29,92 @@ class AllowAccessTest extends \PHPUnit_Framework_TestCase { ); // Login $this->server->getPlugin('auth')->beforeMethod( - new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Request('GET', '/'), new \Sabre\HTTP\Response() ); $aclPlugin = new Plugin(); $this->server->addPlugin($aclPlugin); - } - function testGet() { - + public function testGet() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse])); } - function testGetDoesntExist() { - + public function testGetDoesntExist() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/foo'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse])); } - function testHEAD() { - + public function testHEAD() + { $this->server->httpRequest->setMethod('HEAD'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:HEAD', [$this->server->httpRequest, $this->server->httpResponse])); } - function testOPTIONS() { - + public function testOPTIONS() + { $this->server->httpRequest->setMethod('OPTIONS'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:OPTIONS', [$this->server->httpRequest, $this->server->httpResponse])); } - function testPUT() { - + public function testPUT() + { $this->server->httpRequest->setMethod('PUT'); $this->server->httpRequest->setUrl('/testdir/file1.txt'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:PUT', [$this->server->httpRequest, $this->server->httpResponse])); } - function testPROPPATCH() { - + public function testPROPPATCH() + { $this->server->httpRequest->setMethod('PROPPATCH'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:PROPPATCH', [$this->server->httpRequest, $this->server->httpResponse])); } - function testCOPY() { - + public function testCOPY() + { $this->server->httpRequest->setMethod('COPY'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:COPY', [$this->server->httpRequest, $this->server->httpResponse])); } - function testMOVE() { - + public function testMOVE() + { $this->server->httpRequest->setMethod('MOVE'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:MOVE', [$this->server->httpRequest, $this->server->httpResponse])); } - function testLOCK() { - + public function testLOCK() + { $this->server->httpRequest->setMethod('LOCK'); $this->server->httpRequest->setUrl('/testdir'); - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - + $this->assertTrue($this->server->emit('beforeMethod:LOCK', [$this->server->httpRequest, $this->server->httpResponse])); } - function testBeforeBind() { - + public function testBeforeBind() + { $this->assertTrue($this->server->emit('beforeBind', ['testdir/file'])); - } - - function testBeforeUnbind() { - + public function testBeforeUnbind() + { $this->assertTrue($this->server->emit('beforeUnbind', ['testdir'])); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php index ceae9aed0..3c3aaf6c9 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php @@ -1,19 +1,21 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class BlockAccessTest extends \PHPUnit_Framework_TestCase { - +class BlockAccessTest extends \PHPUnit\Framework\TestCase +{ /** * @var DAV\Server */ protected $server; protected $plugin; - function setUp() { - + public function setUp() + { $nodes = [ new DAV\SimpleCollection('testdir'), ]; @@ -28,151 +30,138 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { ); // Login $this->server->getPlugin('auth')->beforeMethod( - new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Request('GET', '/'), new \Sabre\HTTP\Response() ); $this->server->addPlugin($this->plugin); - } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testGet() { - + public function testGet() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } - function testGetDoesntExist() { - + public function testGetDoesntExist() + { $this->server->httpRequest->setMethod('GET'); $this->server->httpRequest->setUrl('/foo'); - $r = $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); + $r = $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); $this->assertTrue($r); - } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testHEAD() { - + public function testHEAD() + { $this->server->httpRequest->setMethod('HEAD'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testOPTIONS() { - + public function testOPTIONS() + { $this->server->httpRequest->setMethod('OPTIONS'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testPUT() { - + public function testPUT() + { $this->server->httpRequest->setMethod('PUT'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testPROPPATCH() { - + public function testPROPPATCH() + { $this->server->httpRequest->setMethod('PROPPATCH'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testCOPY() { - + public function testCOPY() + { $this->server->httpRequest->setMethod('COPY'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testMOVE() { - + public function testMOVE() + { $this->server->httpRequest->setMethod('MOVE'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testACL() { - + public function testACL() + { $this->server->httpRequest->setMethod('ACL'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testLOCK() { - + public function testLOCK() + { $this->server->httpRequest->setMethod('LOCK'); $this->server->httpRequest->setUrl('/testdir'); - $this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse]); - + $this->server->emit('beforeMethod:GET', [$this->server->httpRequest, $this->server->httpResponse]); } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testBeforeBind() { - + public function testBeforeBind() + { $this->server->emit('beforeBind', ['testdir/file']); - } /** - * @expectedException Sabre\DAVACL\Exception\NeedPrivileges + * @expectedException \Sabre\DAVACL\Exception\NeedPrivileges */ - function testBeforeUnbind() { - + public function testBeforeUnbind() + { $this->server->emit('beforeUnbind', ['testdir']); - } - function testPropFind() { - + public function testPropFind() + { $propFind = new DAV\PropFind('testdir', [ '{DAV:}displayname', '{DAV:}getcontentlength', @@ -187,19 +176,18 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { 200 => [], 404 => [], 403 => [ - '{DAV:}displayname' => null, + '{DAV:}displayname' => null, '{DAV:}getcontentlength' => null, - '{DAV:}bar' => null, - '{DAV:}owner' => null, + '{DAV:}bar' => null, + '{DAV:}owner' => null, ], ]; $this->assertEquals($expected, $propFind->getResultForMultiStatus()); - } - function testBeforeGetPropertiesNoListing() { - + public function testBeforeGetPropertiesNoListing() + { $this->plugin->hideNodesFromListings = true; $propFind = new DAV\PropFind('testdir', [ '{DAV:}displayname', @@ -210,6 +198,5 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { $r = $this->server->emit('propFind', [$propFind, new DAV\SimpleCollection('testdir')]); $this->assertFalse($r); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php index 1cdf2949f..60fb8f3e8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class AceConflictTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class AceConflictTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new AceConflict('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class AceConflictTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:no-ace-conflict' => 1, ]; @@ -29,11 +31,7 @@ class AceConflictTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php index b13e7722d..f08e536b5 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NeedPrivilegesExceptionTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $uri = 'foo'; $privileges = [ '{DAV:}read', @@ -23,12 +25,12 @@ class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, - '/d:root/d:need-privileges' => 1, - '/d:root/d:need-privileges/d:resource' => 2, - '/d:root/d:need-privileges/d:resource/d:href' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, + '/d:root' => 1, + '/d:root/d:need-privileges' => 1, + '/d:root/d:need-privileges/d:resource' => 2, + '/d:root/d:need-privileges/d:resource/d:href' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, '/d:root/d:need-privileges/d:resource/d:privilege/d:write' => 1, ]; @@ -39,11 +41,7 @@ class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php index f52b17371..38e9d8b93 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NoAbstractTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NoAbstractTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new NoAbstract('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class NoAbstractTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:no-abstract' => 1, ]; @@ -29,11 +31,7 @@ class NoAbstractTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php index df89aaf84..62915ea1d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NotRecognizedPrincipalTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new NotRecognizedPrincipal('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:recognized-principal' => 1, ]; @@ -29,11 +31,7 @@ class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php index 50623952b..668c713d2 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { - - function testSerialize() { - +class NotSupportedPrivilegeTest extends \PHPUnit\Framework\TestCase +{ + public function testSerialize() + { $ex = new NotSupportedPrivilege('message'); $server = new DAV\Server(); @@ -18,7 +20,7 @@ class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { $ex->serialize($server, $root); $xpaths = [ - '/d:root' => 1, + '/d:root' => 1, '/d:root/d:not-supported-privilege' => 1, ]; @@ -29,11 +31,7 @@ class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php index 91de64372..28e328ea6 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -7,24 +9,24 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { - - function getServer() { - +class ExpandPropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function getServer() + { $tree = [ new DAV\Mock\PropertiesCollection('node1', [], [ '{http://sabredav.org/ns}simple' => 'foo', - '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'), - '{DAV:}displayname' => 'Node 1', + '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'), + '{DAV:}displayname' => 'Node 1', ]), new DAV\Mock\PropertiesCollection('node2', [], [ - '{http://sabredav.org/ns}simple' => 'simple', + '{http://sabredav.org/ns}simple' => 'simple', '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1', 'node3']), - '{DAV:}displayname' => 'Node 2', + '{DAV:}displayname' => 'Node 2', ]), new DAV\Mock\PropertiesCollection('node3', [], [ '{http://sabredav.org/ns}simple' => 'simple', - '{DAV:}displayname' => 'Node 3', + '{DAV:}displayname' => 'Node 3', ]), ]; @@ -39,7 +41,7 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { [ 'principal' => '{DAV:}all', 'privilege' => '{DAV:}all', - ] + ], ]); $this->assertTrue($plugin instanceof Plugin); @@ -47,11 +49,10 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; - } - function testSimple() { - + public function testSimple() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="displayname" /> @@ -62,8 +63,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node1', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node1', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -74,22 +75,21 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: ' . $server->httpResponse->body); + $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: '.$server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:href' => 1, ]; @@ -97,25 +97,24 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response: '.$server->httpResponse->body); } - } /** * @depends testSimple */ - function testExpand() { - + public function testExpand() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="href" namespace="http://sabredav.org/ns"> @@ -125,8 +124,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node1', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node1', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -137,24 +136,23 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: ' . $server->httpResponse->body); + $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: '.$server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, ]; @@ -162,25 +160,24 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . ' Full response body: ' . $server->httpResponse->getBodyAsString()); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).' Full response body: '.$server->httpResponse->getBodyAsString()); } - } /** * @depends testSimple */ - function testExpandHrefList() { - + public function testExpandHrefList() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="hreflist" namespace="http://sabredav.org/ns"> @@ -190,8 +187,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node2', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node2', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -205,21 +202,20 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, ]; @@ -227,25 +223,24 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result)); } - } /** * @depends testExpand */ - function testExpandDeep() { - + public function testExpandDeep() + { $xml = '<?xml version="1.0"?> <d:expand-property xmlns:d="DAV:"> <d:property name="hreflist" namespace="http://sabredav.org/ns"> @@ -258,8 +253,8 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/node2', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/node2', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -273,27 +268,26 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, ]; @@ -301,17 +295,16 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result)); } - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php index 2d9744e29..51411f304 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php @@ -1,55 +1,49 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class MockACLNode extends DAV\Node implements IACL { - +class MockACLNode extends DAV\Node implements IACL +{ public $name; public $acl; - function __construct($name, array $acl = []) { - + public function __construct($name, array $acl = []) + { $this->name = $name; $this->acl = $acl; - } - function getName() { - + public function getName() + { return $this->name; - } - function getOwner() { - + public function getOwner() + { return null; - } - function getGroup() { - + public function getGroup() + { return null; - } - function getACL() { - + public function getACL() + { return $this->acl; - } - function setACL(array $acl) { - + public function setACL(array $acl) + { $this->acl = $acl; - } - function getSupportedPrivilegeSet() { - + public function getSupportedPrivilegeSet() + { return null; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php index 934906802..f67025c5a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php @@ -1,64 +1,58 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class MockPrincipal extends DAV\Node implements IPrincipal { - +class MockPrincipal extends DAV\Node implements IPrincipal +{ public $name; public $principalUrl; public $groupMembership = []; public $groupMemberSet = []; - function __construct($name, $principalUrl, array $groupMembership = [], array $groupMemberSet = []) { - + public function __construct($name, $principalUrl, array $groupMembership = [], array $groupMemberSet = []) + { $this->name = $name; $this->principalUrl = $principalUrl; $this->groupMembership = $groupMembership; $this->groupMemberSet = $groupMemberSet; - } - function getName() { - + public function getName() + { return $this->name; - } - function getDisplayName() { - + public function getDisplayName() + { return $this->getName(); - } - function getAlternateUriSet() { - + public function getAlternateUriSet() + { return []; - } - function getPrincipalUrl() { - + public function getPrincipalUrl() + { return $this->principalUrl; - } - function getGroupMemberSet() { - + public function getGroupMemberSet() + { return $this->groupMemberSet; - } - function getGroupMemberShip() { - + public function getGroupMemberShip() + { return $this->groupMembership; - } - function setGroupMemberSet(array $groupMemberSet) { - + public function setGroupMemberSet(array $groupMemberSet) + { $this->groupMemberSet = $groupMemberSet; - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php index 8552448f5..9ab16df74 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -8,12 +10,12 @@ use Sabre\HTTP; require_once 'Sabre/DAVACL/MockACLNode.php'; require_once 'Sabre/HTTP/ResponseMock.php'; -class PluginAdminTest extends \PHPUnit_Framework_TestCase { - +class PluginAdminTest extends \PHPUnit\Framework\TestCase +{ public $server; - function setUp() { - + public function setUp() + { $principalBackend = new PrincipalBackend\Mock(); $tree = [ @@ -27,15 +29,15 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $this->server->addPlugin($plugin); } - function testNoAdminAccess() { - + public function testNoAdminAccess() + { $plugin = new Plugin(); $this->server->addPlugin($plugin); $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', ]); $response = new HTTP\ResponseMock(); @@ -46,14 +48,13 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(403, $response->status); - } /** * @depends testNoAdminAccess */ - function testAdminAccess() { - + public function testAdminAccess() + { $plugin = new Plugin(); $plugin->adminPrincipals = [ 'principals/admin', @@ -62,8 +63,8 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', ]); $response = new HTTP\ResponseMock(); @@ -74,6 +75,5 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $this->server->exec(); $this->assertEquals(200, $response->status); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php index fb42efba7..16d3e781e 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php @@ -1,14 +1,16 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; -class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { - - function testPrincipalCollectionSet() { - +class PluginPropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function testPrincipalCollectionSet() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; $plugin->setDefaultACL([ @@ -42,14 +44,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { 'principals2/', ]; - $this->assertEquals($expected, $result[200]['{DAV:}principal-collection-set']->getHrefs()); - - } - function testCurrentUserPrincipal() { - + public function testCurrentUserPrincipal() + { $fakeServer = new DAV\Server(); $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock()); $fakeServer->addPlugin($plugin); @@ -62,7 +61,6 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { ]); $fakeServer->addPlugin($plugin); - $requestedProperties = [ '{DAV:}current-user-principal', ]; @@ -76,7 +74,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType()); // This will force the login - $fakeServer->emit('beforeMethod', [$fakeServer->httpRequest, $fakeServer->httpResponse]); + $fakeServer->emit('beforeMethod:PROPFIND', [$fakeServer->httpRequest, $fakeServer->httpResponse]); $result = $fakeServer->getPropertiesForPath('', $requestedProperties); $result = $result[0]; @@ -86,11 +84,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']); $this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType()); $this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref()); - } - function testSupportedPrivilegeSet() { - + public function testSupportedPrivilegeSet() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; $plugin->setDefaultACL([ @@ -119,28 +116,27 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->xml->write('{DAV:}root', $prop); $xpaths = [ - '/d:root' => 1, - '/d:root/d:supported-privilege' => 1, - '/d:root/d:supported-privilege/d:privilege' => 1, - '/d:root/d:supported-privilege/d:privilege/d:all' => 1, - '/d:root/d:supported-privilege/d:abstract' => 0, - '/d:root/d:supported-privilege/d:supported-privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, + '/d:root' => 1, + '/d:root/d:supported-privilege' => 1, + '/d:root/d:supported-privilege/d:privilege' => 1, + '/d:root/d:supported-privilege/d:privilege/d:all' => 1, + '/d:root/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, ]; - // reloading because php dom sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($result); @@ -148,15 +144,12 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $dxpath = new \DOMXPath($dom2); $dxpath->registerNamespace('d', 'DAV:'); foreach ($xpaths as $xpath => $count) { - - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count . ' Full XML: ' . $result); - + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : '.$xpath.', we could only find '.$dxpath->query($xpath)->length.' elements, while we expected '.$count.' Full XML: '.$result); } - } - function testACL() { - + public function testACL() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; $plugin->setDefaultACL([ @@ -171,12 +164,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ] + ], ]), new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($nodes); @@ -185,7 +177,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($authPlugin); // Force login - $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $requestedProperties = [ '{DAV:}acl', @@ -194,14 +186,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: '.print_r($result, true)); $this->assertArrayHasKey('{DAV:}acl', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']); - } - function testACLRestrictions() { - + public function testACLRestrictions() + { $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; @@ -210,12 +201,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ] + ], ]), new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($nodes); @@ -224,7 +214,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($authPlugin); // Force login - $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $requestedProperties = [ '{DAV:}acl-restrictions', @@ -233,18 +223,17 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: '.print_r($result, true)); $this->assertArrayHasKey('{DAV:}acl-restrictions', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']); - } - function testAlternateUriSet() { - + public function testAlternateUriSet() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), - ]) + ]), ]; $fakeServer = new DAV\Server($tree); @@ -271,11 +260,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}alternate-URI-set']); $this->assertEquals([], $result[200]['{DAV:}alternate-URI-set']->getHrefs()); - } - function testPrincipalURL() { - + public function testPrincipalURL() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -307,11 +295,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-URL']); $this->assertEquals('principals/user/', $result[200]['{DAV:}principal-URL']->getHref()); - } - function testGroupMemberSet() { - + public function testGroupMemberSet() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -343,11 +330,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-member-set']); $this->assertEquals([], $result[200]['{DAV:}group-member-set']->getHrefs()); - } - function testGroupMemberShip() { - + public function testGroupMemberShip() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -377,11 +363,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-membership']); $this->assertEquals([], $result[200]['{DAV:}group-membership']->getHrefs()); - } - function testGetDisplayName() { - + public function testGetDisplayName() + { $tree = [ new DAV\SimpleCollection('principals', [ $principal = new MockPrincipal('user', 'principals/user'), @@ -410,6 +395,5 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $this->assertTrue(isset($result[200]['{DAV:}displayname'])); $this->assertEquals('user', $result[200]['{DAV:}displayname']); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php index 0147e6a61..169629a03 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php @@ -1,13 +1,15 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { - - function testUpdatePropertiesPassthrough() { - +class PluginUpdatePropertiesTest extends \PHPUnit\Framework\TestCase +{ + public function testUpdatePropertiesPassthrough() + { $tree = [ new DAV\SimpleCollection('foo'), ]; @@ -24,11 +26,10 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $result); - } - function testRemoveGroupMembers() { - + public function testRemoveGroupMembers() + { $tree = [ new MockPrincipal('foo', 'foo'), ]; @@ -42,16 +43,15 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]); $expected = [ - '{DAV:}group-member-set' => 204 + '{DAV:}group-member-set' => 204, ]; $this->assertEquals($expected, $result); $this->assertEquals([], $tree[0]->getGroupMemberSet()); - } - function testSetGroupMembers() { - + public function testSetGroupMembers() + { $tree = [ new MockPrincipal('foo', 'foo'), ]; @@ -65,19 +65,18 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]); $expected = [ - '{DAV:}group-member-set' => 200 + '{DAV:}group-member-set' => 200, ]; $this->assertEquals($expected, $result); $this->assertEquals(['bar', 'baz'], $tree[0]->getGroupMemberSet()); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testSetBadValue() { - + public function testSetBadValue() + { $tree = [ new MockPrincipal('foo', 'foo'), ]; @@ -89,11 +88,10 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->updateProperties('foo', [ '{DAV:}group-member-set' => new \StdClass(), ]); - } - function testSetBadNode() { - + public function testSetBadNode() + { $tree = [ new DAV\SimpleCollection('foo'), ]; @@ -111,6 +109,5 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $result); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php index 9fef3018d..89f69b10a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php @@ -1,16 +1,17 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV; -use Sabre\HTTP; - -abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { +abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase +{ use DAV\DbTestHelperTrait; - function setUp() { - + public function setUp() + { $this->dropTables(['principals', 'groupmembers']); $this->createSchema('principals'); @@ -19,92 +20,85 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')"); $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')"); - $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)"); - + $pdo->query('INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)'); } - - function testConstruct() { - + public function testConstruct() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertTrue($backend instanceof PDO); - } /** * @depends testConstruct */ - function testGetPrincipalsByPrefix() { - + public function testGetPrincipalsByPrefix() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = [ [ - 'uri' => 'principals/admin', + 'uri' => 'principals/admin', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - '{DAV:}displayname' => 'Administrator', + '{DAV:}displayname' => 'Administrator', ], [ - 'uri' => 'principals/user', + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', + '{DAV:}displayname' => 'User', ], [ - 'uri' => 'principals/group', + 'uri' => 'principals/group', '{http://sabredav.org/ns}email-address' => 'group@example.org', - '{DAV:}displayname' => 'Group', + '{DAV:}displayname' => 'Group', ], ]; $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals')); $this->assertEquals([], $backend->getPrincipalsByPrefix('foo')); - } /** * @depends testConstruct */ - function testGetPrincipalByPath() { - + public function testGetPrincipalByPath() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = [ - 'id' => 4, - 'uri' => 'principals/user', + 'id' => 4, + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', + '{DAV:}displayname' => 'User', ]; $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user')); $this->assertEquals(null, $backend->getPrincipalByPath('foo')); - } - function testGetGroupMemberSet() { - + public function testGetGroupMemberSet() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = ['principals/user']; $this->assertEquals($expected, $backend->getGroupMemberSet('principals/group')); - } - function testGetGroupMembership() { - + public function testGetGroupMembership() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $expected = ['principals/group']; $this->assertEquals($expected, $backend->getGroupMembership('principals/user')); - } - function testSetGroupMemberSet() { - + public function testSetGroupMemberSet() + { $pdo = $this->getPDO(); // Start situation @@ -118,12 +112,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Adding principals again $backend->setGroupMemberSet('principals/group', ['principals/user']); $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); - - } - function testSearchPrincipals() { - + public function testSearchPrincipals() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); @@ -139,11 +131,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $result = $backend->searchPrincipals('mom', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']); $this->assertEquals([], $result); - } - function testUpdatePrincipal() { - + public function testUpdatePrincipal() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); @@ -157,22 +148,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($result); $this->assertEquals([ - 'id' => 4, - 'uri' => 'principals/user', - '{DAV:}displayname' => 'pietje', + 'id' => 4, + 'uri' => 'principals/user', + '{DAV:}displayname' => 'pietje', '{http://sabredav.org/ns}email-address' => 'user@example.org', ], $backend->getPrincipalByPath('principals/user')); - } - function testUpdatePrincipalUnknownField() { - + public function testUpdatePrincipalUnknownField() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $propPatch = new DAV\PropPatch([ '{DAV:}displayname' => 'pietje', - '{DAV:}unknown' => 'foo', + '{DAV:}unknown' => 'foo', ]); $backend->updatePrincipal('principals/user', $propPatch); @@ -182,36 +172,31 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ '{DAV:}displayname' => 424, - '{DAV:}unknown' => 403 + '{DAV:}unknown' => 403, ], $propPatch->getResult()); $this->assertEquals([ - 'id' => '4', - 'uri' => 'principals/user', - '{DAV:}displayname' => 'User', + 'id' => '4', + 'uri' => 'principals/user', + '{DAV:}displayname' => 'User', '{http://sabredav.org/ns}email-address' => 'user@example.org', ], $backend->getPrincipalByPath('principals/user')); - } - function testFindByUriUnknownScheme() { - + public function testFindByUriUnknownScheme() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertNull($backend->findByUri('http://foo', 'principals')); - } - - function testFindByUri() { - + public function testFindByUri() + { $pdo = $this->getPDO(); $backend = new PDO($pdo); $this->assertEquals( 'principals/user', $backend->findByUri('mailto:user@example.org', 'principals') ); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php index 1464f4c26..551a77900 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php @@ -1,121 +1,117 @@ <?php -namespace Sabre\DAVACL\PrincipalBackend; +declare(strict_types=1); -class Mock extends AbstractBackend { +namespace Sabre\DAVACL\PrincipalBackend; +class Mock extends AbstractBackend +{ public $groupMembers = []; public $principals; - function __construct(array $principals = null) { - + public function __construct(array $principals = null) + { $this->principals = $principals; if (is_null($principals)) { - $this->principals = [ [ - 'uri' => 'principals/user1', - '{DAV:}displayname' => 'User 1', + 'uri' => 'principals/user1', + '{DAV:}displayname' => 'User 1', '{http://sabredav.org/ns}email-address' => 'user1.sabredav@sabredav.org', - '{http://sabredav.org/ns}vcard-url' => 'addressbooks/user1/book1/vcard1.vcf', + '{http://sabredav.org/ns}vcard-url' => 'addressbooks/user1/book1/vcard1.vcf', ], [ - 'uri' => 'principals/admin', + 'uri' => 'principals/admin', '{DAV:}displayname' => 'Admin', ], [ - 'uri' => 'principals/user2', - '{DAV:}displayname' => 'User 2', + 'uri' => 'principals/user2', + '{DAV:}displayname' => 'User 2', '{http://sabredav.org/ns}email-address' => 'user2.sabredav@sabredav.org', ], ]; - } - } - function getPrincipalsByPrefix($prefix) { - + public function getPrincipalsByPrefix($prefix) + { $prefix = trim($prefix, '/'); - if ($prefix) $prefix .= '/'; + if ($prefix) { + $prefix .= '/'; + } $return = []; foreach ($this->principals as $principal) { - - if ($prefix && strpos($principal['uri'], $prefix) !== 0) continue; + if ($prefix && 0 !== strpos($principal['uri'], $prefix)) { + continue; + } $return[] = $principal; - } return $return; - } - function addPrincipal(array $principal) { - + public function addPrincipal(array $principal) + { $this->principals[] = $principal; - } - function getPrincipalByPath($path) { - + public function getPrincipalByPath($path) + { foreach ($this->getPrincipalsByPrefix('principals') as $principal) { - if ($principal['uri'] === $path) return $principal; + if ($principal['uri'] === $path) { + return $principal; + } } - } - function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') { - + public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') + { $matches = []; foreach ($this->getPrincipalsByPrefix($prefixPath) as $principal) { - foreach ($searchProperties as $key => $value) { - if (!isset($principal[$key])) { continue 2; } - if (mb_stripos($principal[$key], $value, 0, 'UTF-8') === false) { + if (false === mb_stripos($principal[$key], $value, 0, 'UTF-8')) { continue 2; } // We have a match for this searchProperty! - if ($test === 'allof') { + if ('allof' === $test) { continue; } else { break; } - } $matches[] = $principal['uri']; - } - return $matches; + return $matches; } - function getGroupMemberSet($path) { - + public function getGroupMemberSet($path) + { return isset($this->groupMembers[$path]) ? $this->groupMembers[$path] : []; - } - function getGroupMembership($path) { - + public function getGroupMembership($path) + { $membership = []; foreach ($this->groupMembers as $group => $members) { - if (in_array($path, $members)) $membership[] = $group; + if (in_array($path, $members)) { + $membership[] = $group; + } } - return $membership; + return $membership; } - function setGroupMemberSet($path, array $members) { - + public function setGroupMemberSet($path, array $members) + { $this->groupMembers[$path] = $members; - } /** @@ -130,11 +126,11 @@ class Mock extends AbstractBackend { * * Read the PropPatch documentation for more info and examples. * - * @param string $path + * @param string $path * @param \Sabre\DAV\PropPatch $propPatch */ - function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) { - + public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) + { $value = null; foreach ($this->principals as $principalIndex => $value) { if ($value['uri'] === $path) { @@ -142,27 +138,22 @@ class Mock extends AbstractBackend { break; } } - if (!$principal) return; - - $propPatch->handleRemaining(function($mutations) use ($principal, $principalIndex) { + if (!$principal) { + return; + } + $propPatch->handleRemaining(function ($mutations) use ($principal, $principalIndex) { foreach ($mutations as $prop => $value) { - if (is_null($value) && isset($principal[$prop])) { unset($principal[$prop]); } else { $principal[$prop] = $value; } - } $this->principals[$principalIndex] = $principal; return true; - }); - } - - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php index 8779eb69f..54795cf4d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAVACL\PrincipalBackend; +declare(strict_types=1); -class PDOMySQLTest extends AbstractPDOTest { +namespace Sabre\DAVACL\PrincipalBackend; +class PDOMySQLTest extends AbstractPDOTest +{ public $driver = 'mysql'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php index 48454981d..549e0bd60 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php @@ -1,9 +1,10 @@ <?php -namespace Sabre\DAVACL\PrincipalBackend; +declare(strict_types=1); -class PDOSqliteTest extends AbstractPDOTest { +namespace Sabre\DAVACL\PrincipalBackend; +class PDOSqliteTest extends AbstractPDOTest +{ public $driver = 'sqlite'; - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php index bcf78821b..68aebe2ae 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php @@ -1,24 +1,25 @@ <?php -namespace Sabre\DAVACL; - -class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { +declare(strict_types=1); - function testBasic() { +namespace Sabre\DAVACL; +class PrincipalCollectionTest extends \PHPUnit\Framework\TestCase +{ + public function testBasic() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $this->assertTrue($pc instanceof PrincipalCollection); $this->assertEquals('principals', $pc->getName()); - } /** * @depends testBasic */ - function testGetChildren() { - + public function testGetChildren() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); @@ -28,30 +29,27 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { foreach ($children as $child) { $this->assertTrue($child instanceof IPrincipal); } - } /** * @depends testBasic - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\MethodNotAllowed */ - function testGetChildrenDisable() { - + public function testGetChildrenDisable() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $pc->disableListing = true; $children = $pc->getChildren(); - } - function testFindByUri() { - + public function testFindByUri() + { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $this->assertEquals('principals/user1', $pc->findByUri('mailto:user1.sabredav@sabredav.org')); $this->assertNull($pc->findByUri('mailto:fake.user.sabredav@sabredav.org')); $this->assertNull($pc->findByUri('')); } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php index 60e156d9a..3bdcfbbbd 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -7,10 +9,10 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { - - function getServer() { - +class PrincipalPropertySearchTest extends \PHPUnit\Framework\TestCase +{ + public function getServer() + { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); @@ -30,11 +32,10 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; - } - function testDepth1() { - + public function testDepth1() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:property-search> @@ -51,8 +52,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '1', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -66,14 +67,12 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->getStatus(), $server->httpResponse->getBodyAsString()); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - - function testUnknownSearchField() { - + public function testUnknownSearchField() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:property-search> @@ -90,8 +89,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -102,17 +101,16 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->getStatus(), "Full body: " . $server->httpResponse->getBodyAsString()); + $this->assertEquals(207, $server->httpResponse->getStatus(), 'Full body: '.$server->httpResponse->getBodyAsString()); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - } - function testCorrect() { - + public function testCorrect() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:apply-to-principal-collection-set /> @@ -130,8 +128,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -145,41 +143,39 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, + '/d:multistatus/d:response/d:propstat/d:status' => 4, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - function testAND() { - + public function testAND() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:apply-to-principal-collection-set /> @@ -203,8 +199,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -218,40 +214,39 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 0, - '/d:multistatus/d:response/d:href' => 0, - '/d:multistatus/d:response/d:propstat' => 0, - '/d:multistatus/d:response/d:propstat/d:prop' => 0, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, + '/d:multistatus/d:response' => 0, + '/d:multistatus/d:response/d:href' => 0, + '/d:multistatus/d:response/d:propstat' => 0, + '/d:multistatus/d:response/d:propstat/d:prop' => 0, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0, - '/d:multistatus/d:response/d:propstat/d:status' => 0, + '/d:multistatus/d:response/d:propstat/d:status' => 0, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - function testOR() { + public function testOR() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:" test="anyof"> <d:apply-to-principal-collection-set /> @@ -275,8 +270,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -290,40 +285,39 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, + '/d:multistatus/d:response/d:propstat/d:status' => 4, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - function testWrongUri() { + public function testWrongUri() + { $xml = '<?xml version="1.0"?> <d:principal-property-search xmlns:d="DAV:"> <d:property-search> @@ -340,8 +334,8 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -355,11 +349,10 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:multistatus', '/d:multistatus/d:response' => 0, @@ -368,30 +361,27 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } } -class MockPlugin extends Plugin { - - function getCurrentUserPrivilegeSet($node) { - +class MockPlugin extends Plugin +{ + public function getCurrentUserPrivilegeSet($node) + { return [ '{DAV:}read', '{DAV:}write', ]; - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php index fa1314d10..04f168f92 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -7,10 +9,10 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { - - function getServer() { - +class PrincipalSearchPropertySetTest extends \PHPUnit\Framework\TestCase +{ + public function getServer() + { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); @@ -27,18 +29,17 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; - } - function testDepth1() { - + public function testDepth1() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:" />'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '1', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -52,20 +53,19 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - function testDepthIncorrectXML() { - + public function testDepthIncorrectXML() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -79,20 +79,19 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - function testCorrect() { - + public function testCorrect() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"/>'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -106,35 +105,32 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(200, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:principal-search-property-set', - '/d:principal-search-property-set/d:principal-search-property' => 2, - '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, - '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, + '/d:principal-search-property-set/d:principal-search-property' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1, - '/d:principal-search-property-set/d:principal-search-property/d:description' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:description' => 2, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php index 20622ad17..a4821da5a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php @@ -1,58 +1,55 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; - -class PrincipalTest extends \PHPUnit_Framework_TestCase { - - function testConstruct() { +class PrincipalTest extends \PHPUnit\Framework\TestCase +{ + public function testConstruct() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertTrue($principal instanceof Principal); - } /** - * @expectedException Sabre\DAV\Exception + * @expectedException \Sabre\DAV\Exception */ - function testConstructNoUri() { - + public function testConstructNoUri() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, []); - } - function testGetName() { - + public function testGetName() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('admin', $principal->getName()); - } - function testGetDisplayName() { - + public function testGetDisplayName() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('admin', $principal->getDisplayname()); $principal = new Principal($principalBackend, [ - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin' + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', ]); $this->assertEquals('Mr. Admin', $principal->getDisplayname()); - } - function testGetProperties() { - + public function testGetProperties() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, [ - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', ]); @@ -64,15 +61,17 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { ]; $props = $principal->getProperties($keys); - foreach ($keys as $key) $this->assertArrayHasKey($key, $props); + foreach ($keys as $key) { + $this->assertArrayHasKey($key, $props); + } $this->assertEquals('Mr. Admin', $props['{DAV:}displayname']); $this->assertEquals('admin@example.org', $props['{http://sabredav.org/ns}email-address']); } - function testUpdateProperties() { - + public function testUpdateProperties() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); @@ -81,26 +80,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { $result = $principal->propPatch($propPatch); $result = $propPatch->commit(); $this->assertTrue($result); - } - function testGetPrincipalUrl() { - + public function testGetPrincipalUrl() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('principals/admin', $principal->getPrincipalUrl()); - } - function testGetAlternateUriSet() { - + public function testGetAlternateUriSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, [ - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - '{DAV:}alternate-URI-set' => [ + '{DAV:}alternate-URI-set' => [ 'mailto:admin+1@example.org', 'mailto:admin+2@example.org', 'mailto:admin@example.org', @@ -114,10 +111,10 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $principal->getAlternateUriSet()); - } - function testGetAlternateUriSetEmpty() { + public function testGetAlternateUriSetEmpty() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, [ 'uri' => 'principals/admin', @@ -126,26 +123,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { $expected = []; $this->assertEquals($expected, $principal->getAlternateUriSet()); - } - function testGetGroupMemberSet() { - + public function testGetGroupMemberSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals([], $principal->getGroupMemberSet()); - } - function testGetGroupMembership() { + public function testGetGroupMembership() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals([], $principal->getGroupMembership()); - } - function testSetGroupMemberSet() { - + public function testSetGroupMemberSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $principal->setGroupMemberSet(['principals/foo']); @@ -153,27 +148,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { $this->assertEquals([ 'principals/admin' => ['principals/foo'], ], $principalBackend->groupMembers); - } - function testGetOwner() { - + public function testGetOwner() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals('principals/admin', $principal->getOwner()); - } - function testGetGroup() { - + public function testGetGroup() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getGroup()); - } - function testGetACl() { - + public function testGetACl() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertEquals([ @@ -181,28 +173,24 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { 'privilege' => '{DAV:}all', 'principal' => '{DAV:}owner', 'protected' => true, - ] + ], ], $principal->getACL()); - } /** * @expectedException \Sabre\DAV\Exception\Forbidden */ - function testSetACl() { - + public function testSetACl() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $principal->setACL([]); - } - function testGetSupportedPrivilegeSet() { - + public function testGetSupportedPrivilegeSet() + { $principalBackend = new PrincipalBackend\Mock(); $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getSupportedPrivilegeSet()); - } - } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php index 2de0ba6a8..a1e9ee36c 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -8,10 +10,10 @@ use Sabre\HTTP; require_once 'Sabre/DAVACL/MockPrincipal.php'; require_once 'Sabre/DAVACL/MockACLNode.php'; -class SimplePluginTest extends \PHPUnit_Framework_TestCase { - - function testValues() { - +class SimplePluginTest extends \PHPUnit\Framework\TestCase +{ + public function testValues() + { $aclPlugin = new Plugin(); $this->assertEquals('acl', $aclPlugin->getPluginName()); $this->assertEquals( @@ -24,25 +26,24 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { '{DAV:}expand-property', '{DAV:}principal-match', '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set' + '{DAV:}principal-search-property-set', ], $aclPlugin->getSupportedReportSet('')); $this->assertEquals(['ACL'], $aclPlugin->getMethods('')); - $this->assertEquals( 'acl', $aclPlugin->getPluginInfo()['name'] ); } - function testGetFlatPrivilegeSet() { - + public function testGetFlatPrivilegeSet() + { $expected = [ '{DAV:}all' => [ - 'privilege' => '{DAV:}all', - 'abstract' => false, + 'privilege' => '{DAV:}all', + 'abstract' => false, 'aggregates' => [ '{DAV:}read', '{DAV:}write', @@ -50,8 +51,8 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { 'concrete' => '{DAV:}all', ], '{DAV:}read' => [ - 'privilege' => '{DAV:}read', - 'abstract' => false, + 'privilege' => '{DAV:}read', + 'abstract' => false, 'aggregates' => [ '{DAV:}read-acl', '{DAV:}read-current-user-privilege-set', @@ -59,20 +60,20 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { 'concrete' => '{DAV:}read', ], '{DAV:}read-acl' => [ - 'privilege' => '{DAV:}read-acl', - 'abstract' => false, + 'privilege' => '{DAV:}read-acl', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}read-acl', + 'concrete' => '{DAV:}read-acl', ], '{DAV:}read-current-user-privilege-set' => [ - 'privilege' => '{DAV:}read-current-user-privilege-set', - 'abstract' => false, + 'privilege' => '{DAV:}read-current-user-privilege-set', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}read-current-user-privilege-set', + 'concrete' => '{DAV:}read-current-user-privilege-set', ], '{DAV:}write' => [ - 'privilege' => '{DAV:}write', - 'abstract' => false, + 'privilege' => '{DAV:}write', + 'abstract' => false, 'aggregates' => [ '{DAV:}write-properties', '{DAV:}write-content', @@ -83,36 +84,35 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { 'concrete' => '{DAV:}write', ], '{DAV:}write-properties' => [ - 'privilege' => '{DAV:}write-properties', - 'abstract' => false, + 'privilege' => '{DAV:}write-properties', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}write-properties', + 'concrete' => '{DAV:}write-properties', ], '{DAV:}write-content' => [ - 'privilege' => '{DAV:}write-content', - 'abstract' => false, + 'privilege' => '{DAV:}write-content', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}write-content', + 'concrete' => '{DAV:}write-content', ], '{DAV:}unlock' => [ - 'privilege' => '{DAV:}unlock', - 'abstract' => false, + 'privilege' => '{DAV:}unlock', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}unlock', + 'concrete' => '{DAV:}unlock', ], '{DAV:}bind' => [ - 'privilege' => '{DAV:}bind', - 'abstract' => false, + 'privilege' => '{DAV:}bind', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}bind', + 'concrete' => '{DAV:}bind', ], '{DAV:}unbind' => [ - 'privilege' => '{DAV:}unbind', - 'abstract' => false, + 'privilege' => '{DAV:}unbind', + 'abstract' => false, 'aggregates' => [], - 'concrete' => '{DAV:}unbind', + 'concrete' => '{DAV:}unbind', ], - ]; $plugin = new Plugin(); @@ -120,28 +120,24 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server = new DAV\Server(); $server->addPlugin($plugin); $this->assertEquals($expected, $plugin->getFlatPrivilegeSet('')); - } - function testCurrentUserPrincipalsNotLoggedIn() { - + public function testCurrentUserPrincipalsNotLoggedIn() + { $acl = new Plugin(); $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($acl); $this->assertEquals([], $acl->getCurrentUserPrincipals()); - } - function testCurrentUserPrincipalsSimple() { - + public function testCurrentUserPrincipalsSimple() + { $tree = [ - new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin'), - ]) - + ]), ]; $acl = new Plugin(); @@ -153,23 +149,20 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($auth); //forcing login - $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $this->assertEquals(['principals/admin'], $acl->getCurrentUserPrincipals()); - } - function testCurrentUserPrincipalsGroups() { - + public function testCurrentUserPrincipalsGroups() + { $tree = [ - new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin', ['principals/administrators', 'principals/everyone']), new MockPrincipal('administrators', 'principals/administrators', ['principals/groups'], ['principals/admin']), new MockPrincipal('everyone', 'principals/everyone', [], ['principals/admin']), new MockPrincipal('groups', 'principals/groups', [], ['principals/administrators']), - ]) - + ]), ]; $acl = new Plugin(); @@ -181,7 +174,7 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($auth); //forcing login - $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $expected = [ 'principals/admin', @@ -194,11 +187,10 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { // The second one should trigger the cache and be identical $this->assertEquals($expected, $acl->getCurrentUserPrincipals()); - } - function testGetACL() { - + public function testGetACL() + { $acl = [ [ 'principal' => 'principals/admin', @@ -210,7 +202,6 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ], ]; - $tree = [ new MockACLNode('foo', $acl), ]; @@ -221,11 +212,10 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($aclPlugin); $this->assertEquals($acl, $aclPlugin->getACL('foo')); - } - function testGetCurrentUserPrivilegeSet() { - + public function testGetCurrentUserPrivilegeSet() + { $acl = [ [ 'principal' => 'principals/admin', @@ -241,14 +231,12 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ], ]; - $tree = [ new MockACLNode('foo', $acl), new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($tree); @@ -260,7 +248,7 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { $server->addPlugin($auth); //forcing login - $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); + $auth->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); $expected = [ '{DAV:}write', @@ -274,11 +262,10 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $aclPlugin->getCurrentUserPrivilegeSet('foo')); - } - function testCheckPrivileges() { - + public function testCheckPrivileges() + { $acl = [ [ 'principal' => 'principals/admin', @@ -294,14 +281,12 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { ], ]; - $tree = [ new MockACLNode('foo', $acl), new DAV\SimpleCollection('principals', [ new MockPrincipal('admin', 'principals/admin'), ]), - ]; $server = new DAV\Server($tree); @@ -316,6 +301,5 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //$auth->beforeMethod('GET','/'); $this->assertFalse($aclPlugin->checkPrivileges('foo', ['{DAV:}read'], Plugin::R_PARENT, false)); - } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php index 35f240d23..982090d23 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVServerTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVServerTest.php @@ -1,10 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre; use Sabre\HTTP\Request; use Sabre\HTTP\Response; -use Sabre\HTTP\Sapi; /** * This class may be used as a basis for other webdav-related unittests. @@ -16,8 +17,8 @@ use Sabre\HTTP\Sapi; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { - +abstract class DAVServerTest extends \PHPUnit\Framework\TestCase +{ protected $setupCalDAV = false; protected $setupCardDAV = false; protected $setupACL = false; @@ -33,7 +34,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { /** * An array with calendars. Every calendar should have * - principaluri - * - uri + * - uri. */ protected $caldavCalendars = []; protected $caldavCalendarObjects = []; @@ -54,27 +55,27 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { protected $propertyStorageBackend; /** - * @var Sabre\CalDAV\Plugin + * @var \Sabre\CalDAV\Plugin */ protected $caldavPlugin; /** - * @var Sabre\CardDAV\Plugin + * @var \Sabre\CardDAV\Plugin */ protected $carddavPlugin; /** - * @var Sabre\DAVACL\Plugin + * @var \Sabre\DAVACL\Plugin */ protected $aclPlugin; /** - * @var Sabre\CalDAV\SharingPlugin + * @var \Sabre\CalDAV\SharingPlugin */ protected $caldavSharingPlugin; /** - * CalDAV scheduling plugin + * CalDAV scheduling plugin. * * @var CalDAV\Schedule\Plugin */ @@ -108,14 +109,13 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { */ protected $autoLogin = null; - function setUp() { - + public function setUp() + { $this->initializeEverything(); - } - function initializeEverything() { - + public function initializeEverything() + { $this->setUpBackends(); $this->setUpTree(); @@ -173,7 +173,6 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { $this->aclPlugin->adminPrincipals = ['principals/admin']; $this->server->addPlugin($this->aclPlugin); } - } /** @@ -187,11 +186,12 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { * the test. * * @param array|\Sabre\HTTP\Request $request - * @param int $expectedStatus + * @param int $expectedStatus + * * @return \Sabre\HTTP\Response */ - function request($request, $expectedStatus = null) { - + public function request($request, $expectedStatus = null) + { if (is_array($request)) { $request = HTTP\Request::createFromServerArray($request); } @@ -203,10 +203,10 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { if ($expectedStatus) { $responseBody = $expectedStatus !== $response->getStatus() ? $response->getBodyAsString() : ''; - $this->assertEquals($expectedStatus, $response->getStatus(), 'Incorrect HTTP status received for request. Response body: ' . $responseBody); + $this->assertEquals($expectedStatus, $response->getStatus(), 'Incorrect HTTP status received for request. Response body: '.$responseBody); } - return $this->server->httpResponse; + return $this->server->httpResponse; } /** @@ -215,9 +215,10 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { * * @param string $userName */ - function autoLogin($userName) { + public function autoLogin($userName) + { $authBackend = new DAV\Auth\Backend\Mock(); - $authBackend->setPrincipal('principals/' . $userName); + $authBackend->setPrincipal('principals/'.$userName); $this->authPlugin = new DAV\Auth\Plugin($authBackend); // If the auth plugin already exists, we're removing its hooks: @@ -227,14 +228,14 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { $this->server->addPlugin($this->authPlugin); // This will trigger the actual login procedure - $this->authPlugin->beforeMethod(new Request(), new Response()); + $this->authPlugin->beforeMethod(new Request('GET', '/'), new Response()); } /** * Override this to provide your own Tree for your test-case. */ - function setUpTree() { - + public function setUpTree() + { if ($this->setupCalDAV) { $this->tree[] = new CalDAV\CalendarRoot( $this->principalBackend, @@ -258,15 +259,12 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { ); } if ($this->setupFiles) { - $this->tree[] = new DAV\Mock\Collection('files'); - } - } - function setUpBackends() { - + public function setUpBackends() + { if ($this->setupCalDAVSharing && is_null($this->caldavBackend)) { $this->caldavBackend = new CalDAV\Backend\MockSharing($this->caldavCalendars, $this->caldavCalendarObjects); } @@ -289,18 +287,14 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase { if ($this->setupLocks) { $this->locksBackend = new DAV\Locks\Backend\Mock(); } - if ($this->setupPropertyStorage) { + if ($this->setupPropertyStorage) { $this->propertyStorageBackend = new DAV\PropertyStorage\Backend\Mock(); } - } - - function assertHttpStatus($expectedStatus, HTTP\Request $req) { - + public function assertHttpStatus($expectedStatus, HTTP\Request $req) + { $resp = $this->request($req); - $this->assertEquals((int)$expectedStatus, (int)$resp->status, 'Incorrect HTTP status received: ' . $resp->body); - + $this->assertEquals((int) $expectedStatus, (int) $resp->status, 'Incorrect HTTP status received: '.$resp->body); } - } diff --git a/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php b/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php index eb486bf5b..c5357928a 100644 --- a/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php +++ b/vendor/sabre/dav/tests/Sabre/HTTP/ResponseMock.php @@ -1,9 +1,11 @@ <?php +declare(strict_types=1); + namespace Sabre\HTTP; /** - * HTTP Response Mock object + * HTTP Response Mock object. * * This class exists to make the transition to sabre/http easier. * @@ -11,12 +13,11 @@ namespace Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ResponseMock extends Response { - +class ResponseMock extends Response +{ /** * Making these public. */ public $body; public $status; - } diff --git a/vendor/sabre/dav/tests/Sabre/TestUtil.php b/vendor/sabre/dav/tests/Sabre/TestUtil.php index 9df94915f..4e7ca2fc4 100644 --- a/vendor/sabre/dav/tests/Sabre/TestUtil.php +++ b/vendor/sabre/dav/tests/Sabre/TestUtil.php @@ -1,71 +1,66 @@ <?php -namespace Sabre; +declare(strict_types=1); -class TestUtil { +namespace Sabre; +class TestUtil +{ /** * This function deletes all the contents of the temporary directory. - * - * @return void */ - static function clearTempDir() { - + public static function clearTempDir() + { self::deleteTree(SABRE_TEMPDIR, false); - } - - private static function deleteTree($path, $deleteRoot = true) { - + private static function deleteTree($path, $deleteRoot = true) + { foreach (scandir($path) as $node) { - - if ($node == '.' || $node == '..') continue; - $myPath = $path . '/' . $node; + if ('.' == $node || '..' == $node) { + continue; + } + $myPath = $path.'/'.$node; if (is_file($myPath)) { unlink($myPath); } else { self::deleteTree($myPath); } - } if ($deleteRoot) { rmdir($path); } - } - static function getMySQLDB() { - + public static function getMySQLDB() + { try { $pdo = new \PDO(SABRE_MYSQLDSN, SABRE_MYSQLUSER, SABRE_MYSQLPASS); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + return $pdo; } catch (\PDOException $e) { return null; } - } - static function getSQLiteDB() { - - $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/pdobackend'); + public static function getSQLiteDB() + { + $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - return $pdo; + return $pdo; } - static function getPgSqlDB() { - + public static function getPgSqlDB() + { //try { - $pdo = new \PDO(SABRE_PGSQLDSN); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - return $pdo; + $pdo = new \PDO(SABRE_PGSQLDSN); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + + return $pdo; //} catch (\PDOException $e) { // return null; //} - } - - } diff --git a/vendor/sabre/dav/tests/bootstrap.php b/vendor/sabre/dav/tests/bootstrap.php index 26eb32aa2..03e6006b9 100644 --- a/vendor/sabre/dav/tests/bootstrap.php +++ b/vendor/sabre/dav/tests/bootstrap.php @@ -1,38 +1,59 @@ <?php -set_include_path(__DIR__ . '/../lib/' . PATH_SEPARATOR . __DIR__ . PATH_SEPARATOR . get_include_path()); +declare(strict_types=1); -$autoLoader = include __DIR__ . '/../vendor/autoload.php'; +set_include_path(__DIR__.'/../lib/'.PATH_SEPARATOR.__DIR__.PATH_SEPARATOR.get_include_path()); + +$autoLoader = include __DIR__.'/../vendor/autoload.php'; // SabreDAV tests auto loading $autoLoader->add('Sabre\\', __DIR__); // VObject tests auto loading -$autoLoader->addPsr4('Sabre\\VObject\\', __DIR__ . '/../vendor/sabre/vobject/tests/VObject'); -$autoLoader->addPsr4('Sabre\\Xml\\', __DIR__ . '/../vendor/sabre/xml/tests/Sabre/Xml'); +$autoLoader->addPsr4('Sabre\\VObject\\', __DIR__.'/../vendor/sabre/vobject/tests/VObject'); +$autoLoader->addPsr4('Sabre\\Xml\\', __DIR__.'/../vendor/sabre/xml/tests/Sabre/Xml'); date_default_timezone_set('UTC'); +// List of variables that can be set by the environment +$environmentVars = [ + 'SABRE_MYSQLUSER', + 'SABRE_MYSQLPASS', + 'SABRE_MYSQLDSN', + 'SABRE_PGSQLDSN', +]; +foreach ($environmentVars as $var) { + if ($value = getenv($var)) { + define($var, $value); + } +} + $config = [ - 'SABRE_TEMPDIR' => dirname(__FILE__) . '/temp/', + 'SABRE_TEMPDIR' => dirname(__FILE__).'/temp/', 'SABRE_HASSQLITE' => in_array('sqlite', PDO::getAvailableDrivers()), - 'SABRE_HASMYSQL' => in_array('mysql', PDO::getAvailableDrivers()), - 'SABRE_HASPGSQL' => in_array('pgsql', PDO::getAvailableDrivers()), - 'SABRE_MYSQLDSN' => 'mysql:host=127.0.0.1;dbname=sabredav_test', + 'SABRE_HASMYSQL' => in_array('mysql', PDO::getAvailableDrivers()), + 'SABRE_HASPGSQL' => in_array('pgsql', PDO::getAvailableDrivers()), + 'SABRE_MYSQLDSN' => 'mysql:host=127.0.0.1;dbname=sabredav_test', 'SABRE_MYSQLUSER' => 'sabredav', 'SABRE_MYSQLPASS' => '', - 'SABRE_PGSQLDSN' => 'pgsql:host=localhost;dbname=sabredav_test;user=sabredav;password=sabredav', + 'SABRE_PGSQLDSN' => 'pgsql:host=localhost;dbname=sabredav_test;user=sabredav;password=sabredav', ]; -if (file_exists(__DIR__ . '/config.user.php')) { - include __DIR__ . '/config.user.php'; +if (file_exists(__DIR__.'/config.user.php')) { + include __DIR__.'/config.user.php'; foreach ($userConfig as $key => $value) { $config[$key] = $value; } } foreach ($config as $key => $value) { - if (!defined($key)) define($key, $value); + if (!defined($key)) { + define($key, $value); + } } -if (!file_exists(SABRE_TEMPDIR)) mkdir(SABRE_TEMPDIR); -if (file_exists('.sabredav')) unlink('.sabredav'); +if (!file_exists(SABRE_TEMPDIR)) { + mkdir(SABRE_TEMPDIR); +} +if (file_exists('.sabredav')) { + unlink('.sabredav'); +} -- cgit v1.2.3