summaryrefslogtreecommitdiff
path: root/tests/units/Formatter/UserMentionFormatterTest.php
blob: 92f73d169fc89d6a1a33af06f3db844bac603d22 (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 Kanboard\Formatter\UserMentionFormatter;

require_once __DIR__.'/../Base.php';

class UserMentionFormatterTest extends Base
{
    public function testFormat()
    {
        $userMentionFormatter = new UserMentionFormatter($this->container);
        $users = array(
            array(
                'id' => 1,
                'username' => 'someone',
                'name' => 'Someone',
                'email' => 'test@localhost',
                'avatar_path' => 'avatar_image',
            ),
            array(
                'id' => 2,
                'username' => 'somebody',
                'name' => '',
                'email' => '',
                'avatar_path' => '',
            )
        );

        $expected = array(
            array(
                'value' => 'someone',
                'html' => '<div class="avatar avatar-20 avatar-inline"><img src="?controller=AvatarFileController&amp;action=image&amp;user_id=1&amp;hash=5acc03af0274414544b9615fb223d925&amp;size=20" alt="Someone" title="Someone"></div> someone <small>Someone</small>',
            ),
            array(
                'value' => 'somebody',
                'html' => '<div class="avatar avatar-20 avatar-inline"><div class="avatar-letter" style="background-color: rgb(191, 210, 121)" title="somebody">S</div></div> somebody',
            ),
        );

        $this->assertSame($expected, $userMentionFormatter->withUsers($users)->format());
    }
}