diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-06-17 07:39:22 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2022-06-17 07:39:22 +0000 |
| commit | bb62df65ac6aa71a757b58a01f9cb95a859a38f9 (patch) | |
| tree | b59576cb558380c7d09847862e796a2fde670fc2 /tests/jsonapi/ConsultationsBookingShowTest.php | |
| parent | ad8f5f3b12e4f12bd77f6e2b0f0c3e36c47c5694 (diff) | |
implement tests for consultation jsonapi routes
Closes #1174
Merge request studip/studip!696
Diffstat (limited to 'tests/jsonapi/ConsultationsBookingShowTest.php')
| -rw-r--r-- | tests/jsonapi/ConsultationsBookingShowTest.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/jsonapi/ConsultationsBookingShowTest.php b/tests/jsonapi/ConsultationsBookingShowTest.php new file mode 100644 index 0000000..8788b77 --- /dev/null +++ b/tests/jsonapi/ConsultationsBookingShowTest.php @@ -0,0 +1,41 @@ +<?php +use JsonApi\Routes\Consultations\BookingsShow; +use JsonApi\Schemas\ConsultationBooking as Schema; + +require_once __DIR__ . '/ConsultationHelper.php'; + +class ConsultationsBookingShowTest 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); + $booking = $this->createBookingForSlot( + $credentials, + $slot, + $this->getUserForCredentials($this->tester->getCredentialsForTestAutor()) + ); + + $response = $this->sendMockRequest( + '/consultation-bookings/{id}', + BookingsShow::class, + $credentials, + ['id' => $booking->id] + ); + $document = $this->getSingleResourceDocument($response); + + $resourceObject = $document->primaryResource(); + $this->assertTrue(is_string($resourceObject->id())); + $this->assertSame($booking->id, $resourceObject->id()); + $this->assertSame(Schema::TYPE, $resourceObject->type()); + + $this->assertEquals(self::$BOOKING_DATA['reason'], $resourceObject->attribute('reason')); + + $this->assertHasRelations($resourceObject, Schema::REL_SLOT, Schema::REL_USER); + } +} |
