summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-03 22:51:48 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-03 22:51:48 -0400
commit60c8867feeeefcf160fb1432419887f17a0d957b (patch)
tree0cb7e413ad920bf196fb1df21695d7f7039bc1e5 /tests
parent38e9f9928e3f13658af3c6bbe9ec0bf078f1c177 (diff)
Improve LDAP user group membership synchronization
Diffstat (limited to 'tests')
-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));
+ }
}