Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
outils
question2answer
Commits
3f89396a
Commit
3f89396a
authored
Apr 16, 2015
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests: add permissions tests
parent
37311dab
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
AppUsersTest.php
qa-tests/AppUsersTest.php
+51
-0
No files found.
qa-tests/AppUsersTest.php
0 → 100644
View file @
3f89396a
<?php
require_once
QA_INCLUDE_DIR
.
'app/users.php'
;
require_once
QA_INCLUDE_DIR
.
'app/options.php'
;
class
AppUsersTest
extends
PHPUnit_Framework_TestCase
{
/**
* Test logic of permissions function.
* User level values: QA_USER_LEVEL_* in app/users.php [BASIC..SUPER]
* Permission values: QA_PERMIT_* in app/options.php [ALL..SUPERS]
* User flag values: QA_USER_FLAGS_* in app/users.php
*/
public
function
test__qa_permit_value_error
()
{
$userFlags
=
QA_USER_FLAGS_EMAIL_CONFIRMED
;
$blockedFlags
=
QA_USER_FLAGS_EMAIL_CONFIRMED
|
QA_USER_FLAGS_USER_BLOCKED
;
// Admin trying to do Super stuff
$error
=
qa_permit_value_error
(
QA_PERMIT_SUPERS
,
1
,
QA_USER_LEVEL_ADMIN
,
$userFlags
);
$this
->
assertSame
(
'level'
,
$error
);
// Admin trying to do Admin stuff
$error
=
qa_permit_value_error
(
QA_PERMIT_ADMINS
,
1
,
QA_USER_LEVEL_ADMIN
,
$userFlags
);
$this
->
assertSame
(
false
,
$error
);
// Admin trying to do Editor stuff
$error
=
qa_permit_value_error
(
QA_PERMIT_EDITORS
,
1
,
QA_USER_LEVEL_ADMIN
,
$userFlags
);
$this
->
assertSame
(
false
,
$error
);
// Expert trying to do Moderator stuff
$error
=
qa_permit_value_error
(
QA_PERMIT_MODERATORS
,
1
,
QA_USER_LEVEL_EXPERT
,
$userFlags
);
$this
->
assertSame
(
'level'
,
$error
);
// Unconfirmed User trying to do Confirmed stuff
$error
=
qa_permit_value_error
(
QA_PERMIT_CONFIRMED
,
1
,
QA_USER_LEVEL_BASIC
,
0
);
$this
->
assertSame
(
'confirm'
,
$error
);
// Blocked User trying to do anything
$error
=
qa_permit_value_error
(
QA_PERMIT_ALL
,
1
,
QA_USER_LEVEL_BASIC
,
$blockedFlags
);
$this
->
assertSame
(
'userblock'
,
$error
);
// Logged Out User trying to do User stuff
$error
=
qa_permit_value_error
(
QA_PERMIT_USERS
,
null
,
null
,
0
);
$this
->
assertSame
(
'login'
,
$error
);
// Logged Out User trying to do Moderator stuff
$error
=
qa_permit_value_error
(
QA_PERMIT_MODERATORS
,
null
,
null
,
0
);
$this
->
assertSame
(
'level'
,
$error
);
}
}
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