diff options
author | Chris Cornutt <enygma@phpdeveloper.org> | 2015-01-25 16:47:25 -0600 |
---|---|---|
committer | Chris Cornutt <enygma@phpdeveloper.org> | 2015-01-25 16:47:25 -0600 |
commit | 727ca8c94d56add88876a078a293b5a68edb3e6f (patch) | |
tree | 6e35a43a83781cf54ed35b4401a27c3f27551b42 | |
parent | 854a0d042dd1e4e40ef69e59638fa490d913ac29 (diff) | |
download | gatekeeper-727ca8c94d56add88876a078a293b5a68edb3e6f.zip gatekeeper-727ca8c94d56add88876a078a293b5a68edb3e6f.tar.gz gatekeeper-727ca8c94d56add88876a078a293b5a68edb3e6f.tar.bz2 |
adding a test for the create() method in the user group collection
-rw-r--r-- | tests/Psecio/Gatekeeper/UserGroupCollectionTest.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/Psecio/Gatekeeper/UserGroupCollectionTest.php b/tests/Psecio/Gatekeeper/UserGroupCollectionTest.php index f68c5f9..d9290fe 100644 --- a/tests/Psecio/Gatekeeper/UserGroupCollectionTest.php +++ b/tests/Psecio/Gatekeeper/UserGroupCollectionTest.php @@ -21,4 +21,30 @@ class UserGroupCollectionTest extends \Psecio\Gatekeeper\Base $groups->findByUserId($userId); $this->assertCount(2, $groups); } + + /** + * Test the creation of new collection items based on data given + */ + public function testCreateRecordsFromModelDataById() + { + $ds = $this->getMockBuilder('\Psecio\Gatekeeper\DataSource\Mysql') + ->disableOriginalConstructor() + ->setMethods(array('save', 'fetch')) + ->getMock(); + + $ds->method('save')->willReturn(true); + + $userModel = new UserModel($ds, array('id' => 1)); + $data = array(array('id' => 1, 'name' => 'Group #1')); + $ds->method('fetch')->willReturn($data); + + $groupIdList = array(1, 2, 3); + + $groups = new UserGroupCollection($ds); + $groups->create($userModel, $groupIdList); + + $this->assertEquals( + count($groups->toArray()), count($groupIdList) + ); + } }
\ No newline at end of file |