signin(); $task = factory(Task::class)->create([ 'account_id' => $user->account->id, 'contact_id' => null, 'created_at' => now(), 'updated_at' => now(), ]); $response = $this->get("/dav/calendars/{$user->email}/tasks/{$task->uuid}.ics"); $response->assertStatus(200); $response->assertHeader('X-Sabre-Version'); $this->assertEquals($this->getVTodo($task, true), $response->getContent()); } /** * @group dav */ public function test_caldav_put_one_task() { $user = $this->signin(); $uuid = Str::uuid(); $response = $this->call('PUT', "/dav/calendars/{$user->email}/tasks/{$uuid}.ics", [], [], [], ['content-type' => 'application/xml; charset=utf-8'], "BEGIN:VCALENDAR BEGIN:VTODO UID:{$uuid} SUMMARY:title DESCRIPTION:description END:VTODO END:VCALENDAR " ); $response->assertStatus(201); $response->assertHeader('X-Sabre-Version'); $response->assertHeaderMissing('ETag'); $this->assertDatabaseHas('tasks', [ 'account_id' => $user->account->id, 'contact_id' => null, 'uuid' => $uuid, 'title' => 'title', 'description' => 'description', ]); } /** * @group dav */ public function test_caldav_update_existing_task() { $user = $this->signin(); $task = factory(Task::class)->create([ 'account_id' => $user->account->id, 'contact_id' => null, ]); $response = $this->call('PUT', "/dav/calendars/{$user->email}/tasks/{$task->uuid}.ics", [], [], [], ['content-type' => 'application/xml; charset=utf-8'], "BEGIN:VCALENDAR BEGIN:VTODO UID:{$task->uuid} SUMMARY:new title DESCRIPTION:new description END:VTODO END:VCALENDAR " ); $response->assertStatus(204); $response->assertHeader('X-Sabre-Version'); $response->assertHeaderMissing('ETag'); $this->assertDatabaseHas('tasks', [ 'account_id' => $user->account->id, 'uuid' => $task->uuid, 'title' => 'new title', 'description' => 'new description', ]); } /** * @group dav */ public function test_caldav_update_task_complete() { $user = $this->signin(); $task = factory(Task::class)->create([ 'account_id' => $user->account->id, 'contact_id' => null, ]); $response = $this->call('PUT', "/dav/calendars/{$user->email}/tasks/{$task->uuid}.ics", [], [], [], ['content-type' => 'application/xml; charset=utf-8'], "BEGIN:VCALENDAR BEGIN:VTODO UID:{$task->uuid} SUMMARY:{$task->title} DESCRIPTION:{$task->description} STATUS:COMPLETED COMPLETED:20190121T182800Z END:VTODO END:VCALENDAR " ); $response->assertStatus(204); $response->assertHeader('X-Sabre-Version'); $response->assertHeaderMissing('ETag'); $this->assertDatabaseHas('tasks', [ 'account_id' => $user->account->id, 'uuid' => $task->uuid, 'completed' => true, 'completed_at' => Carbon::create(2019, 01, 21, 18, 28, 00), ]); } public function test_caldav_tasks_report() { $user = $this->signin(); $contact = factory(Contact::class)->create([ 'account_id' => $user->account->id, ]); $task = factory(Task::class)->create([ 'account_id' => $user->account->id, 'created_at' => now(), ]); $response = $this->call('REPORT', "/dav/calendars/{$user->email}/tasks/", [], [], [], [ 'HTTP_DEPTH' => '1', 'content-type' => 'application/xml; charset=utf-8', ], ' ' ); $response->assertStatus(207); $response->assertHeader('X-Sabre-Version'); $peopleurl = route('people.show', $contact); $sabreversion = \Sabre\VObject\Version::VERSION; $response->assertSee(''. ''. "/dav/calendars/{$user->email}/tasks/{$task->uuid}.ics". ''. ''. ""{$this->getEtag($task)}"". "{$this->getVTodo($task)}". ''. 'HTTP/1.1 200 OK'. ''. ''. ''); } public function test_caldav_tasks_report_multiget() { $user = $this->signin(); $task1 = factory(Task::class)->create([ 'account_id' => $user->account->id, 'created_at' => now(), ]); $task2 = factory(Task::class)->create([ 'account_id' => $user->account->id, 'created_at' => now(), ]); $response = $this->call('REPORT', "/dav/calendars/{$user->email}/tasks/", [], [], [], [ 'HTTP_DEPTH' => '1', ], " /dav/calendars/{$user->email}/tasks/{$task1->uuid}.ics /dav/calendars/{$user->email}/tasks/{$task2->uuid}.ics " ); $response->assertStatus(207); $response->assertHeader('X-Sabre-Version'); $response->assertSee(''. ''. "/dav/calendars/{$user->email}/tasks/{$task1->uuid}.ics". ''. ''. ""{$this->getEtag($task1)}"". "{$this->getVTodo($task1)}". ''. 'HTTP/1.1 200 OK'. ''. ''); $response->assertSee( ''. "/dav/calendars/{$user->email}/tasks/{$task2->uuid}.ics". ''. ''. ""{$this->getEtag($task2)}"". "{$this->getVTodo($task2)}". ''. 'HTTP/1.1 200 OK'. ''. ''. ''); } }