diff options
author | Chris Cornutt <enygma@phpdeveloper.org> | 2015-02-18 13:57:25 -0500 |
---|---|---|
committer | Chris Cornutt <enygma@phpdeveloper.org> | 2015-02-18 13:57:25 -0500 |
commit | 38366beb8b0b29031e91c2ac13a44f5176db05bd (patch) | |
tree | 3e4ce8cd42bd8a4a201296e938f7f030937f5f7a | |
parent | d10e44f828aebde598dbc0998c4659c931f421d1 (diff) | |
download | gatekeeper-38366beb8b0b29031e91c2ac13a44f5176db05bd.zip gatekeeper-38366beb8b0b29031e91c2ac13a44f5176db05bd.tar.gz gatekeeper-38366beb8b0b29031e91c2ac13a44f5176db05bd.tar.bz2 |
adding tests for the "create" method in user permission collection
-rw-r--r-- | tests/Psecio/Gatekeeper/UserPermissionCollectionTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/Psecio/Gatekeeper/UserPermissionCollectionTest.php b/tests/Psecio/Gatekeeper/UserPermissionCollectionTest.php index d2a306f..35c3a20 100644 --- a/tests/Psecio/Gatekeeper/UserPermissionCollectionTest.php +++ b/tests/Psecio/Gatekeeper/UserPermissionCollectionTest.php @@ -21,4 +21,43 @@ class UserPermissionCollectionTest extends \Psecio\Gatekeeper\Base $permissions->findByUserId($userId); $this->assertCount(2, $permissions); } + + /** + * Test the creation of a user permission relation by permission ID + */ + public function testCreateUserPermissionById() + { + $return = array( + array('id' => 1, 'name' => 'perm5') + ); + + $ds = $this->buildMock($return, 'fetch'); + $permissions = new UserPermissionCollection($ds); + $model = new UserPermissionModel($ds); + + $data = array(1, 2, 3); + $permissions->create($model, $data); + } + + /** + * Test the creation of a user permission relation by permission model instance + */ + public function testCreateUserPermissionByModel() + { + $return = array( + array('id' => 1, 'name' => 'perm5'), + array('id' => 2, 'name' => 'perm6') + ); + + $ds = $this->buildMock($return, 'fetch'); + $permissions = new UserPermissionCollection($ds); + $model = new UserPermissionModel($ds); + + $data = array( + new PermissionModel($ds, array('id' => 1)), + new PermissionModel($ds, array('id' => 2)), + new PermissionModel($ds, array('id' => 3)) + ); + $permissions->create($model, $data); + } }
\ No newline at end of file |