Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443488
Commits
27519ac9
Commit
27519ac9
authored
14 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#716302
follow-up by David_Rothstein: Tests for Dashboard module.
parent
f3304854
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/dashboard/dashboard.test
+60
-0
60 additions, 0 deletions
modules/dashboard/dashboard.test
with
60 additions
and
0 deletions
modules/dashboard/dashboard.test
0 → 100644
+
60
−
0
View file @
27519ac9
<?php
// $Id$
/**
* @file
* Tests for the dashboard module.
*/
class
DashboardAccessTestCase
extends
DrupalWebTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Dashboard access'
,
'description'
=>
'Test access control for the dashboard.'
,
'group'
=>
'Dashboard'
,
);
}
function
setUp
()
{
parent
::
setUp
();
// Create and log in an administrative user having access to the dashboard.
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'access administration pages'
,
'administer blocks'
));
$this
->
drupalLogin
(
$admin_user
);
// Make sure that the dashboard is using the same theme as the rest of the
// site (and in particular, the same theme used on 403 pages). This forces
// the dashboard blocks to be the same for an administrator as for a
// regular user, and therefore lets us test that the dashboard blocks
// themselves are specifically removed for a user who does not have access
// to the dashboard page.
theme_enable
(
array
(
'stark'
));
variable_set
(
'theme_default'
,
'stark'
);
variable_set
(
'admin_theme'
,
'stark'
);
}
/**
* Test adding a block to the dashboard and checking access to it.
*/
function
testDashboardAccess
()
{
// Add a new custom block to a dashboard region.
$custom_block
=
array
();
$custom_block
[
'info'
]
=
$this
->
randomName
(
8
);
$custom_block
[
'title'
]
=
$this
->
randomName
(
8
);
$custom_block
[
'body[value]'
]
=
$this
->
randomName
(
32
);
$custom_block
[
'regions[stark]'
]
=
'dashboard_main'
;
$this
->
drupalPost
(
'admin/structure/block/add'
,
$custom_block
,
t
(
'Save block'
));
// Ensure admin access.
$this
->
drupalGet
(
'admin'
);
$this
->
assertResponse
(
200
,
t
(
'Admin has access to the dashboard.'
));
$this
->
assertRaw
(
$custom_block
[
'title'
],
t
(
'Admin has access to a dashboard block.'
));
// Ensure non-admin access is denied.
$normal_user
=
$this
->
drupalCreateUser
();
$this
->
drupalLogin
(
$normal_user
);
$this
->
drupalGet
(
'admin'
);
$this
->
assertResponse
(
403
,
t
(
'Non-admin has no access to the dashboard.'
));
$this
->
assertNoText
(
$custom_block
[
'title'
],
t
(
'Non-admin has no access to a dashboard block.'
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment