Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
7b7064d8
Commit
7b7064d8
authored
Sep 26, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding the permission manager test
parent
b982a164
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
PermissionManagerTest.php
Tests/PermissionManagerTest.php
+85
-0
No files found.
Tests/PermissionManagerTest.php
0 → 100644
View file @
7b7064d8
<?php
namespace
Modules\Core\Tests
;
use
Mockery
;
use
Modules\Core\Permissions\PermissionManager
;
class
PermissionManagerTest
extends
\TestCase
{
/**
* @var PermissionManager
*/
protected
$permissions
;
public
function
setUp
()
{
parent
::
setUp
();
$enabledModules
=
[
'Session'
,
'User'
,
'Dashboard'
,
'Core'
];
$moduleMock
=
Mockery
::
mock
(
'Pingpong\Modules\Module'
);
$moduleMock
->
shouldReceive
(
'enabled'
)
->
once
()
->
andReturn
(
$enabledModules
);
$this
->
permissions
=
new
PermissionManager
(
$moduleMock
);
}
/** @test */
public
function
itShouldReturnAllPermissions
()
{
$expected
=
[
'Dashboard'
=>
[
'dashboard'
=>
[
'index'
]
],
'User'
=>
[
'users'
=>
[
'index'
,
'create'
,
'store'
,
'edit'
,
'update'
,
'destroy'
],
'roles'
=>
[
'index'
,
'create'
,
'store'
,
'edit'
,
'update'
,
'destroy'
]
],
];
$permissions
=
$this
->
permissions
->
all
();
$this
->
assertEquals
(
$expected
,
$permissions
);
}
/** @test */
public
function
itShouldCleanPermissionsCorrectlyTypeCasted
()
{
$requestData
=
[
'dashboard.index'
=>
'true'
,
'users.index'
=>
'true'
,
'users.create'
=>
'true'
,
'users.edit'
=>
'true'
,
'users.delete'
=>
'true'
,
'roles.create'
=>
'true'
,
];
$expected
=
[
'dashboard.index'
=>
true
,
'users.index'
=>
true
,
'users.create'
=>
true
,
'users.edit'
=>
true
,
'users.delete'
=>
true
,
'roles.create'
=>
true
,
];
$cleanedPermissions
=
$this
->
permissions
->
clean
(
$requestData
);
$this
->
assertEquals
(
$expected
,
$cleanedPermissions
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment