* @package calendar * @subpackage tests * @copyright (c) 2020 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License */ namespace EGroupware\calendar; require_once __DIR__.'/../../../api/tests/CalDAVTest.php'; use EGroupware\Api\CalDAVTest; use GuzzleHttp\RequestOptions; class CalDAVcreateReadDelete extends CalDAVTest { /** * Test accessing CalDAV without authentication */ public function testNoAuth() { $response = $this->getClient([])->get($this->url('/')); $this->assertHttpStatus(401, $response); } /** * Test accessing CalDAV with authentication */ public function testAuth() { $response = $this->getClient()->get($this->url('/')); $this->assertHttpStatus(200, $response); } const EVENT_URL = '/demo/calendar/new-event-1233456789-new.ics'; const EVENT_ICAL = <<getClient()->put($this->url(self::EVENT_URL), [ RequestOptions::HEADERS => [ 'Content-Type' => 'text/calendar', 'If-None-Match' => '*', ], RequestOptions::BODY => self::EVENT_ICAL, ]); $this->assertHttpStatus(201, $response); } /** * Read created event */ public function testRead() { $response = $this->getClient()->get($this->url(self::EVENT_URL)); $this->assertHttpStatus(200, $response); $this->assertIcal(self::EVENT_ICAL, $response->getBody()); } /** * Delete created event */ public function testDelete() { $response = $this->getClient()->delete($this->url(self::EVENT_URL)); $this->assertHttpStatus(204, $response); } /** * Read created event */ public function testReadDeleted() { $response = $this->getClient()->get($this->url(self::EVENT_URL)); $this->assertHttpStatus(404, $response); } }