aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/ConsultationsBlocksByRangeIndexTest.php
blob: 89300b522c75425a12404661115b3df9a3edee1b (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
35
36
37
38
39
40
<?php
use JsonApi\Routes\Consultations\BlocksByRangeIndex;

require_once __DIR__ . '/ConsultationHelper.php';

// TODO: Activate consultations on institute for testing
class ConsultationsBlocksByRangeIndexTest extends Codeception\Test\Unit
{
    use ConsultationHelper;

    public static function rangeProvider(): array
    {
        return [
            'Course' => ['course', 'a07535cf2f8a72df33c12ddfa4b53dde'],
            'User'   => ['user', '205f3efb7997a0fc9755da2b535038da'],
        ];
    }

    /**
     * @dataProvider rangeProvider
     */
    public function testFetchBlocksByRangeIndex(string $range_type, string $range_id): void
    {
        $credentials = $this->tester->getCredentialsForTestDozent();
        $range = RangeFactory::createRange($range_type, $range_id);

        $this->createBlockWithSlotsForRange($range);

        $response = $this->sendMockRequest(
            "/{type:courses|institutes|users}/{id}/consultations",
            BlocksByRangeIndex::class,
            $credentials,
            ['type' => "{$range_type}s", 'id' => $range_id]
        );
        $document = $this->getResourceCollectionDocument($response);

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