diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php | 144 |
1 files changed, 62 insertions, 82 deletions
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 @@ <?php +declare(strict_types=1); + namespace Sabre\CalDAV; use Sabre\DAV; @@ -7,14 +9,14 @@ use Sabre\DAVACL; use Sabre\HTTP; use Sabre\VObject; -class ICSExportPluginTest extends \Sabre\DAVServerTest { - +class ICSExportPluginTest extends \Sabre\DAVServerTest +{ protected $setupCalDAV = true; protected $icsExportPlugin; - function setUp() { - + public function setUp() + { parent::setUp(); $this->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') ); - } - } |