PresenterTest.php 971 Bytes
Newer Older
Jacob Priddy's avatar
Jacob Priddy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php


namespace Tests\Unit\Source\UseCases\GroupUser\AddUserToGroup;

use PHPUnit\Framework\TestCase;
use Source\UseCases\GroupUser\AddUserToGroup\APIPresenter;
use Source\UseCases\GroupUser\AddUserToGroup\ResponseModel;

class PresenterTest extends TestCase
{
    protected APIPresenter $presenter;

    protected ResponseModel $model;

    protected array $response;

18
    protected function setUp(): void
Jacob Priddy's avatar
Jacob Priddy committed
19
20
21
22
23
24
25
26
    {
        parent::setUp();

        $this->presenter = new APIPresenter();
    }

    public function handleTest(string $message): void
    {
27
28
29
        $this->model = new ResponseModel();

        $this->model->addMessage($message);
Jacob Priddy's avatar
Jacob Priddy committed
30
31
32
33
34
35
36
37
38
39
40

        $this->presenter->present($this->model);

        $this->response = $this->presenter->getViewModel();
    }

    /** @test */
    public function it_formats_a_message(): void
    {
        $this->handleTest('message');

41
        self::assertEquals(['messages' => ['message'], 'errors' => []], $this->response);
Jacob Priddy's avatar
Jacob Priddy committed
42
43
    }
}