summaryrefslogtreecommitdiff
path: root/tests/units/Core
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/Core')
-rw-r--r--tests/units/Core/User/GroupSyncTest.php61
1 files changed, 60 insertions, 1 deletions
diff --git a/tests/units/Core/User/GroupSyncTest.php b/tests/units/Core/User/GroupSyncTest.php
index e22b86d4..decb2fdc 100644
--- a/tests/units/Core/User/GroupSyncTest.php
+++ b/tests/units/Core/User/GroupSyncTest.php
@@ -8,7 +8,7 @@ use Kanboard\Model\GroupMember;
class GroupSyncTest extends Base
{
- public function testSynchronize()
+ public function testAddGroups()
{
$group = new Group($this->container);
$groupMember = new GroupMember($this->container);
@@ -27,4 +27,63 @@ class GroupSyncTest extends Base
$this->assertTrue($groupMember->isMember(1, 1));
$this->assertTrue($groupMember->isMember(2, 1));
}
+
+ public function testRemoveGroups()
+ {
+ $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('externalId3'));
+
+ $this->assertFalse($groupMember->isMember(1, 1));
+ $this->assertFalse($groupMember->isMember(2, 1));
+ }
+
+ public function testBoth()
+ {
+ $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->assertEquals(3, $group->create('My Group 3', 'externalId3'));
+
+ $this->assertTrue($groupMember->addUser(1, 1));
+ $this->assertTrue($groupMember->addUser(2, 1));
+
+ $this->assertTrue($groupMember->isMember(1, 1));
+ $this->assertTrue($groupMember->isMember(2, 1));
+ $this->assertFalse($groupMember->isMember(3, 1));
+
+ $groupSync->synchronize(1, array('externalId1', 'externalId3'));
+
+ $this->assertTrue($groupMember->isMember(1, 1));
+ $this->assertFalse($groupMember->isMember(2, 1));
+ $this->assertTrue($groupMember->isMember(3, 1));
+ }
+
+ public function testThatInternalGroupsAreNotTouched()
+ {
+ $group = new Group($this->container);
+ $groupMember = new GroupMember($this->container);
+ $groupSync = new GroupSync($this->container);
+
+ $this->assertEquals(1, $group->create('My Group 1'));
+ $this->assertTrue($groupMember->addUser(1, 1));
+ $this->assertTrue($groupMember->isMember(1, 1));
+
+ $groupSync->synchronize(1, array('externalId3'));
+
+ $this->assertTrue($groupMember->isMember(1, 1));
+ }
}