Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
eca
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
eca
Merge requests
!510
Fix ECA action list remove by value from token
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix ECA action list remove by value from token
issue/eca-3525806:3525806-action-list-remove
into
3.0.x
Overview
0
Commits
1
Pipelines
3
Changes
2
Merged
Richard Papp
requested to merge
issue/eca-3525806:3525806-action-list-remove
into
3.0.x
2 weeks ago
Overview
0
Commits
1
Pipelines
3
Changes
2
Expand
Closes
#3525806
0
0
Merge request reports
Compare
3.0.x
version 1
9fab2b7f
2 weeks ago
3.0.x (base)
and
latest version
latest version
c36f9bac
1 commit,
2 weeks ago
version 1
9fab2b7f
1 commit,
2 weeks ago
2 files
+
84
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
modules/base/tests/src/Kernel/ListRemoveTest.php
0 → 100644
+
81
−
0
Options
<?php
namespace
Drupal\Tests\eca\Kernel
;
use
Drupal\Component\Serialization\Yaml
;
use
Drupal\KernelTests\KernelTestBase
;
/**
* Tests for ECA action eca_list_remove plugin.
*
* @group eca
* @group eca_base
*/
class
ListRemoveTest
extends
KernelTestBase
{
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'system'
,
'user'
,
'eca'
,
'eca_base'
,
];
/**
* {@inheritdoc}
*/
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
installConfig
(
static
::
$modules
);
}
/**
* Tests list remove action by value.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
public
function
testListRemoveByValue
():
void
{
/** @var \Drupal\eca\Token\TokenInterface $tokenServices */
$tokenServices
=
\Drupal
::
service
(
'eca.token_services'
);
/** @var \Drupal\Core\Action\ActionManager $actionManager */
$actionManager
=
\Drupal
::
service
(
'plugin.manager.action'
);
$tokenServices
->
addTokenData
(
'list'
,
[
'a'
,
'b'
,
'c'
]);
$config
=
[
'list_token'
=>
'list'
,
'method'
=>
'value'
,
'value'
=>
'b'
,
'token_name'
=>
'item'
,
];
/** @var \Drupal\eca_base\Plugin\Action\TokenSetValue $action */
$action
=
$actionManager
->
createInstance
(
'eca_list_remove'
,
$config
);
$this
->
assertTrue
(
$action
->
access
(
NULL
));
$action
->
execute
(
NULL
);
$this
->
assertEquals
(
Yaml
::
encode
([
'a'
,
'c'
,
]),
$tokenServices
->
replaceClear
(
'[list]'
));
$this
->
assertEquals
(
'b'
,
$tokenServices
->
replaceClear
(
'[item]'
));
$tokenServices
->
addTokenData
(
'list'
,
[
'a'
,
'b'
,
'c'
]);
$tokenServices
->
addTokenData
(
'item_to_remove'
,
'a'
);
$config
=
[
'list_token'
=>
'list'
,
'method'
=>
'value'
,
'value'
=>
'[item_to_remove]'
,
'token_name'
=>
'item'
,
];
/** @var \Drupal\eca_base\Plugin\Action\TokenSetValue $action */
$action
=
$actionManager
->
createInstance
(
'eca_list_remove'
,
$config
);
$this
->
assertTrue
(
$action
->
access
(
NULL
));
$action
->
execute
();
$this
->
assertEquals
(
Yaml
::
encode
([
'b'
,
'c'
,
]),
$tokenServices
->
replace
(
'[list]'
));
$this
->
assertEquals
(
'a'
,
$tokenServices
->
replaceClear
(
'[item]'
));
}
}
Loading