Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443205
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-3443205
Commits
b092eaa7
Unverified
Commit
b092eaa7
authored
5 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3041842
by claudiu.cristea, Lendude: Convert ArgumentValidateTest into a kernel test
parent
fd194bbe
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
core/modules/user/tests/src/Kernel/Views/ArgumentValidateTest.php
+25
-13
25 additions, 13 deletions
...ules/user/tests/src/Kernel/Views/ArgumentValidateTest.php
with
25 additions
and
13 deletions
core/modules/user/tests/src/
Functiona
l/Views/ArgumentValidateTest.php
→
core/modules/user/tests/src/
Kerne
l/Views/ArgumentValidateTest.php
+
25
−
13
View file @
b092eaa7
<?php
namespace
Drupal\Tests\user\
Functiona
l\Views
;
namespace
Drupal\Tests\user\
Kerne
l\Views
;
use
Drupal\Core\Form\FormState
;
use
Drupal\Tests\user\Traits\UserCreationTrait
;
use
Drupal\Tests\views\Kernel\ViewsKernelTestBase
;
use
Drupal\views\Plugin\views\argument\ArgumentPluginBase
;
use
Drupal\views\Tests\ViewTestData
;
use
Drupal\views\Views
;
/**
...
...
@@ -11,12 +14,20 @@
*
* @group user
*/
class
ArgumentValidateTest
extends
UserTestBase
{
class
ArgumentValidateTest
extends
ViewsKernelTestBase
{
use
UserCreationTrait
;
/**
* Views used by this test.
*
* @var array
* {@inheritdoc}
*/
public
static
$modules
=
[
'node'
,
'user_test_views'
,
];
/**
* {@inheritdoc}
*/
public
static
$testViews
=
[
'test_view_argument_validate_user'
,
'test_view_argument_validate_username'
];
...
...
@@ -27,22 +38,25 @@ class ArgumentValidateTest extends UserTestBase {
*/
protected
$account
;
/**
* {@inheritdoc}
*/
protected
function
setUp
(
$import_test_views
=
TRUE
)
{
parent
::
setUp
(
$import_test_views
);
$this
->
account
=
$this
->
drupalCreateUser
();
$this
->
installEntitySchema
(
'user'
);
$this
->
installEntitySchema
(
'node'
);
$this
->
account
=
$this
->
createUser
();
ViewTestData
::
createTestViews
(
get_class
(
$this
),
[
'user_test_views'
]);
}
/**
* Tests the User (ID) argument validator.
*/
public
function
testArgumentValidateUserUid
()
{
$account
=
$this
->
account
;
$view
=
Views
::
getView
(
'test_view_argument_validate_user'
);
$this
->
executeView
(
$view
);
$this
->
assertTrue
(
$view
->
argument
[
'null'
]
->
validateArgument
(
$account
->
id
()));
$this
->
assertTrue
(
$view
->
argument
[
'null'
]
->
validateArgument
(
$
this
->
account
->
id
()));
// Reset argument validation.
$view
->
argument
[
'null'
]
->
argument_validated
=
NULL
;
// Fail for a valid numeric, but for a user that doesn't exist
...
...
@@ -59,12 +73,10 @@ public function testArgumentValidateUserUid() {
* Tests the UserName argument validator.
*/
public
function
testArgumentValidateUserName
()
{
$account
=
$this
->
account
;
$view
=
Views
::
getView
(
'test_view_argument_validate_username'
);
$this
->
executeView
(
$view
);
$this
->
assertTrue
(
$view
->
argument
[
'null'
]
->
validateArgument
(
$account
->
getAccountName
()));
$this
->
assertTrue
(
$view
->
argument
[
'null'
]
->
validateArgument
(
$
this
->
account
->
getAccountName
()));
// Reset argument validation.
$view
->
argument
[
'null'
]
->
argument_validated
=
NULL
;
// Fail for a valid string, but for a user that doesn't exist
...
...
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