aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/ConsultationsSlotShowTest.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2022-06-17 07:39:22 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2022-06-17 07:39:22 +0000
commitbb62df65ac6aa71a757b58a01f9cb95a859a38f9 (patch)
treeb59576cb558380c7d09847862e796a2fde670fc2 /tests/jsonapi/ConsultationsSlotShowTest.php
parentad8f5f3b12e4f12bd77f6e2b0f0c3e36c47c5694 (diff)
implement tests for consultation jsonapi routes
Closes #1174 Merge request studip/studip!696
Diffstat (limited to 'tests/jsonapi/ConsultationsSlotShowTest.php')
-rw-r--r--tests/jsonapi/ConsultationsSlotShowTest.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/jsonapi/ConsultationsSlotShowTest.php b/tests/jsonapi/ConsultationsSlotShowTest.php
new file mode 100644
index 0000000..be8f5b7
--- /dev/null
+++ b/tests/jsonapi/ConsultationsSlotShowTest.php
@@ -0,0 +1,45 @@
+<?php
+use JsonApi\Routes\Consultations\SlotShow;
+use JsonApi\Schemas\ConsultationSlot as Schema;
+
+require_once __DIR__ . '/ConsultationHelper.php';
+
+class ConsultationsSlotShowTest extends Codeception\Test\Unit
+{
+ use ConsultationHelper;
+
+ public function testFetchBlock(): void
+ {
+ $credentials = $this->tester->getCredentialsForTestDozent();
+ $range = User::find($credentials['id']);
+
+ $block = $this->createBlockWithSlotsForRange($range);
+ $slot = $this->getSlotFromBlock($block);
+
+ $response = $this->sendMockRequest(
+ '/consultation-slots/{id}',
+ SlotShow::class,
+ $credentials,
+ ['id' => $slot->id]
+ );
+ $document = $this->getSingleResourceDocument($response);
+
+ $resourceObject = $document->primaryResource();
+ $this->assertTrue(is_string($resourceObject->id()));
+ $this->assertSame($slot->id, $resourceObject->id());
+ $this->assertSame(Schema::TYPE, $resourceObject->type());
+
+ $this->assertEquals($slot->start_time, strtotime($resourceObject->attribute('start_time')));
+ $this->assertEquals($slot->end_time, strtotime($resourceObject->attribute('end_time')));
+
+ $this->assertHasRelations($resourceObject, Schema::REL_BLOCK, Schema::REL_BOOKINGS);
+
+//
+// $this->assertSame(self::$BLOCK_DATA['room'], $resourceObject->attribute('room'));
+// $this->assertSame(self::$BLOCK_DATA['show_participants'], $resourceObject->attribute('show-participants'));
+// $this->assertSame(self::$BLOCK_DATA['require_reason'], $resourceObject->attribute('require-reason'));
+// $this->assertSame(self::$BLOCK_DATA['confirmation_text'], $resourceObject->attribute('confirmation-text'));
+// $this->assertSame(self::$BLOCK_DATA['note'], $resourceObject->attribute('note'));
+// $this->assertSame(self::$BLOCK_DATA['size'], $resourceObject->attribute('size'));
+ }
+}