aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/ConsultationsBookingsBySlotIndexTest.php
blob: e927aad4f546713d328a35fdd9f001283b9774f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
use JsonApi\Routes\Consultations\BookingsBySlotIndex;

require_once __DIR__ . '/ConsultationHelper.php';

class ConsultationsBookingsBySlotIndexTest extends Codeception\Test\Unit
{
    use ConsultationHelper;

    public function testFetchSlots(): void
    {
        $credentials = $this->tester->getCredentialsForTestDozent();
        $range = $this->getUserForCredentials($credentials);

        $block = $this->createBlockWithSlotsForRange($range);
        $slot = $this->getSlotFromBlock($block);
        $this->createBookingForSlot(
            $credentials,
            $slot,
            $this->getUserForCredentials($this->tester->getCredentialsForTestAutor())
        );

        $response = $this->sendMockRequest(
            '/consultation-slots/{id}/bookings',
            BookingsBySlotIndex::class,
            $credentials,
            ['id' => $slot->id]
        );
        $document = $this->getResourceCollectionDocument($response);

        $resources = $document->primaryResources();
        $this->tester->assertCount(1, $resources);
    }
}