Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
regcode
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
regcode
Commits
bd5dd633
Commit
bd5dd633
authored
8 months ago
by
Tim Rohaly
Browse files
Options
Downloads
Plain Diff
Merge branch '3225738-add-test-case' into '2.0.x'
Issue
#3225738
by TR: Add test case for settings form See merge request
!10
parents
07aa4113
ffcdfa24
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#273063
passed
8 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Functional/RegcodeSettingsTest.php
+87
-0
87 additions, 0 deletions
tests/src/Functional/RegcodeSettingsTest.php
with
87 additions
and
0 deletions
tests/src/Functional/RegcodeSettingsTest.php
0 → 100644
+
87
−
0
View file @
bd5dd633
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\Tests\regcode\Functional
;
use
Drupal\Tests\BrowserTestBase
;
// cspell:ignore unpriv
/**
* Tests operation of the Regcode settings page.
*
* @group Regcode
*/
class
RegcodeSettingsTest
extends
BrowserTestBase
{
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'regcode'
,
'help'
,
'block'
];
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'stark'
;
/**
* Admin user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected
$adminUser
;
/**
* Authenticated but unprivileged user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected
$unprivUser
;
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
// System help block is needed to see output from hook_help().
$this
->
drupalPlaceBlock
(
'help_block'
,
[
'region'
=>
'help'
]);
// Create our test users.
$this
->
adminUser
=
$this
->
createUser
([
'administer site configuration'
,
'access administration pages'
,
'administer registration codes'
,
]);
$this
->
unprivUser
=
$this
->
createUser
();
}
/**
* Tests module permissions / access to configuration page.
*/
public
function
testUserAccess
()
{
/** @var \Drupal\Tests\WebAssert $assert */
$assert
=
$this
->
assertSession
();
// Test as anonymous user.
$this
->
drupalGet
(
'admin/config/people/regcode/settings'
);
$assert
->
statusCodeEquals
(
403
);
$assert
->
pageTextContains
(
'Access denied'
);
$assert
->
pageTextContains
(
'You are not authorized to access this page.'
);
// Test as authenticated but unprivileged user.
$this
->
drupalLogin
(
$this
->
unprivUser
);
$this
->
drupalGet
(
'admin/config/people/regcode/settings'
);
$assert
->
statusCodeEquals
(
403
);
$this
->
drupalLogout
();
// Test as admin user.
$this
->
drupalLogin
(
$this
->
adminUser
);
$this
->
drupalGet
(
'admin/config/people/regcode/settings'
);
$assert
->
statusCodeEquals
(
200
);
$assert
->
pageTextContains
(
'Configure the registration code module.'
);
$this
->
drupalLogout
();
}
}
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