summaryrefslogtreecommitdiff
path: root/tests/units/Core/User/GroupSyncTest.php
blob: e22b86d47c0f12e861bdfa42b83806c23ff2af84 (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
<?php

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

use Kanboard\Core\User\GroupSync;
use Kanboard\Model\Group;
use Kanboard\Model\GroupMember;

class GroupSyncTest extends Base
{
    public function testSynchronize()
    {
        $group = new Group($this->container);
        $groupMember = new GroupMember($this->container);
        $groupSync = new GroupSync($this->container);

        $this->assertEquals(1, $group->create('My Group 1', 'externalId1'));
        $this->assertEquals(2, $group->create('My Group 2', 'externalId2'));

        $this->assertTrue($groupMember->addUser(1, 1));

        $this->assertTrue($groupMember->isMember(1, 1));
        $this->assertFalse($groupMember->isMember(2, 1));

        $groupSync->synchronize(1, array('externalId1', 'externalId2', 'externalId3'));

        $this->assertTrue($groupMember->isMember(1, 1));
        $this->assertTrue($groupMember->isMember(2, 1));
    }
}