summaryrefslogtreecommitdiffstats
path: root/tests/Psecio/Gatekeeper/GroupModelTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Psecio/Gatekeeper/GroupModelTest.php')
-rw-r--r--tests/Psecio/Gatekeeper/GroupModelTest.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/Psecio/Gatekeeper/GroupModelTest.php b/tests/Psecio/Gatekeeper/GroupModelTest.php
index 15598e6..c71a296 100644
--- a/tests/Psecio/Gatekeeper/GroupModelTest.php
+++ b/tests/Psecio/Gatekeeper/GroupModelTest.php
@@ -93,4 +93,39 @@ class GroupModelTest extends \Psecio\Gatekeeper\Base
$this->assertTrue($group->inGroup(1));
}
+
+ /**
+ * Test adding a child by group model instance
+ */
+ public function testAddChild()
+ {
+ $ds = $this->getMockBuilder('\Psecio\Gatekeeper\DataSource\Mysql')
+ ->disableOriginalConstructor()
+ ->setMethods(array('save'))
+ ->getMock();
+
+ $ds->method('save')
+ ->willReturn(true);
+
+ $group1 = new GroupModel($ds, array('id' => 1234));
+ $group2 = new GroupModel($ds);
+
+ $this->assertTrue($group1->addChild($group2));
+ }
+
+ /**
+ * Test that false is returned when you try to add a child to a
+ * group not yet loaded
+ */
+ public function testAddChildNoId()
+ {
+ $ds = $this->getMockBuilder('\Psecio\Gatekeeper\DataSource\Mysql')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $group1 = new GroupModel($ds);
+ $group2 = new GroupModel($ds);
+
+ $this->assertFalse($group1->addChild($group2));
+ }
}