aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/CommentsDeleteTest.php
blob: 464cb96ccd9a5c293bd71057c67c6bd07fe1391d (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
41
42
<?php


use JsonApi\Routes\Blubber\CommentsDelete;

class CommentsDeleteTest extends \Codeception\Test\Unit
{
    /**
     * @var \UnitTester
     */
    protected $tester;

    protected function _before()
    {
        \DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh);
    }

    protected function _after()
    {
    }

    public function testDeleteComment()
    {
        $commentId = '372d6c3bd41cd503c022961e73698d4c';
        $credentials = $this->tester->getCredentialsForRoot();
        $this->deleteComment($credentials, $commentId);
    }

    private function deleteComment(array $credentials, $commentId)
    {
        $app = $this->tester->createApp($credentials, 'delete', '/comments/{id}', CommentsDelete::class);

        return $this->tester->sendMockRequest(
            $app,
            $this->tester
            ->createRequestBuilder($credentials)
            ->setUri('/comments/'.$commentId)
            ->delete()
            ->getRequest()
        );
    }
}