summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Cornutt <chris.cornutt@hp.com>2015-01-15 11:03:24 -0600
committerChris Cornutt <chris.cornutt@hp.com>2015-01-15 11:03:24 -0600
commit79d183ac076d65355cd5bb2ec146da62c206a1ca (patch)
tree4d342d25e89fb8016514a7a9aa8b6c69e2901b8e
parentaa36a1b94e5c4f3f1644285bc24f946a8642b07a (diff)
downloadgatekeeper-79d183ac076d65355cd5bb2ec146da62c206a1ca.zip
gatekeeper-79d183ac076d65355cd5bb2ec146da62c206a1ca.tar.gz
gatekeeper-79d183ac076d65355cd5bb2ec146da62c206a1ca.tar.bz2
adding Group model tests for adding child (with and without an ID)
-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));
+ }
}