Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
customerror
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
customerror
Commits
88ea493a
Commit
88ea493a
authored
11 years ago
by
Gisle Hannemyr
Browse files
Options
Downloads
Patches
Plain Diff
#2136653
by gisle: Fixed broken test cases.
parent
9433a051
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
customerror.test
+45
-53
45 additions, 53 deletions
customerror.test
with
45 additions
and
53 deletions
customerror.test
+
45
−
53
View file @
88ea493a
<?php
/**
* @file
* Tests for the CustomError module.
*/
class
CustomErrorTestCas
extends
DrupalWebTestCase
{
class
CustomErrorTestCase
extends
DrupalWebTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
t
(
'Custom Error'
)
,
'description'
=>
t
(
'Check that the custom error messages are displayed.'
)
,
'group'
=>
t
(
'Custom Error'
)
,
'name'
=>
'Custom Error'
,
'description'
=>
'Check that the custom error messages are displayed.'
,
'group'
=>
'Custom Error'
,
);
}
function
setUp
()
{
// Enable any modules required for the test.
parent
::
setUp
(
array
(
'customerror'
)
)
;
parent
::
setUp
(
'customerror'
);
}
/**
* Tests 404 pages.
*/
function
testPageNotFoundMessage
()
{
// Set title and text of error message.
$error_code
=
404
;
$title
=
$this
->
randomName
(
$number
=
10
,
$prefix
=
'simpletest_'
);
variable_set
(
'customerror_'
.
$error_code
.
'_title'
,
$title
);
$description
=
array
(
'value'
=>
$this
->
randomName
(
$number
=
512
,
$prefix
=
'simpletest_'
),
'format'
=>
filter_default_format
(),
);
variable_set
(
'customerror_'
.
$error_code
,
$description
);
// Access error page directly, check for title and text of error message.
$this
->
drupalGet
(
'customerror/'
.
$error_code
);
//debug($this, 'this');
$this
->
assertText
(
$title
,
'Title on '
.
$error_code
.
' error page set when accessed directly'
);
//debug($description['value'], 'Description');
$this
->
assertText
(
$description
[
'value'
],
'Description on '
.
$error_code
.
' error page set when accessed directly'
);
// Point Drupal to the new error message.
variable_set
(
'site_'
.
$error_code
,
'customerror/'
.
$error_code
);
function
testPageNotFoundMessage
()
{
// Set title and description of error message.
$title
=
$this
->
randomName
(
$number
=
10
);
$description
=
$this
->
randomName
(
$number
=
80
);
variable_set
(
'site_404'
,
'customerror/404'
);
variable_set
(
'customerror_404_title'
,
$title
);
variable_set
(
'customerror_404'
,
$description
);
// Access a non-existing page, check for title and text of error message.
$this
->
drupalGet
(
'foo/bar'
);
// Access error page directly, check for response code, title and description of error message.
$this
->
drupalGet
(
'customerror/404'
);
$this
->
assertResponse
(
404
,
'Response code on 404 error page set when accessed directly.'
);
$this
->
assertText
(
$title
,
'Title on 404 error page set when accessed directly.'
);
$this
->
assertText
(
$description
,
'Description on 404 error page set when accessed directly.'
);
/* Check for response code, title and text of error message */
$this
->
assertResponse
(
$error_code
,
'Response code on '
.
$error_code
.
' error page set when accessed at non-existent URL'
);
$this
->
assertText
(
$title
,
'Title on '
.
$error_code
.
' error page set when accessed at non-existent URL'
);
$this
->
assertText
(
$description
[
'value'
],
'Description on '
.
$error_code
.
' error page set when accessed at non-existent URL'
);
// Access a non-existing page, check for response code, title and description of error message.
$this
->
drupalGet
(
'foo/dontexist'
);
$this
->
assertResponse
(
404
,
'Response code on 404 error page set when accessed at non-existent URL.'
);
$this
->
assertText
(
$title
,
'Title on 404 error page set when accessed at non-existent URL.'
);
$this
->
assertText
(
$description
,
'Description on 404 error page set when accessed at non-existent URL.'
);
}
/**
* Tests 403 pages.
*/
function
testAccessDeniedMessage
()
{
/* Set title and text of error message */
$error_code
=
403
;
$title
=
$this
->
randomName
(
$number
=
10
,
$prefix
=
'simpletest_'
);
variable_set
(
'customerror_'
.
$error_code
.
'_title'
,
$title
);
$description
=
array
(
'value'
=>
$this
->
randomName
(
$number
=
512
,
$prefix
=
'simpletest_'
),
'format'
=>
filter_default_format
(),
);
variable_set
(
'customerror_'
.
$error_code
,
$description
);
// Set title and description of error message.
$title
=
$this
->
randomName
(
$number
=
10
);
$description
=
$this
->
randomName
(
$number
=
80
);
variable_set
(
'site_403'
,
'customerror/403'
);
variable_set
(
'customerror_403_title'
,
$title
);
variable_set
(
'customerror_403'
,
$description
);
// Access error page directly, check for title and text of error message.
$this
->
drupalGet
(
'customerror/'
.
$error_code
);
$this
->
assertText
(
$title
,
'Title on '
.
$error_code
.
' error page set when accessed directly'
);
$this
->
assertText
(
$description
[
'value'
],
'Description on '
.
$error_code
.
' error page set when accessed directly'
);
// Access error page directly, check for response code, title and description of error message.
$this
->
drupalGet
(
'customerror/403'
);
$this
->
assertResponse
(
403
,
'Response code on 403 error page set when accessed at non-existent URL'
);
$this
->
assertText
(
$title
,
'Title on 403 error page set when accessed directly'
);
$this
->
assertText
(
$description
,
'Description on 403 error page set when accessed directly'
);
// Point Drupal to the new error message.
variable_set
(
'site_'
.
$error_code
,
'customerror/'
.
$error_code
);
// Access admin page as un anonymous user, check for title and text of error message.
// Access admin page as an anonymous user, check for response code, title and description of error message.
$this
->
drupalGet
(
'admin'
);
/* Check for response code, title and text of error message */
$this
->
assertResponse
(
$error_code
,
'Response code on '
.
$error_code
.
' error page set when accessed at non-existent URL'
);
$this
->
assertText
(
$title
,
'Title on '
.
$error_code
.
' error page set when accessed at non-existent URL'
);
$this
->
assertText
(
$description
[
'value'
],
'Description on '
.
$error_code
.
' error page set when accessed at non-existent URL'
);
$this
->
assertResponse
(
403
,
'Response code on 403 error page set when accessed at non-existent URL'
);
$this
->
assertText
(
$title
,
'Title on 403 error page set when accessed at non-existent URL'
);
$this
->
assertText
(
$description
,
'Description on 403 error page set when accessed at non-existent URL'
);
}
}
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