protected function doTestIdenticalUser() { /** @var \Drupal\Core\Condition\ConditionPluginBase $condition */
$condition = \Drupal::
service('plugin.manager.condition'
) ->
createInstance('condition_test_dual_user'
) // Map the anonymous user to both contexts.
->
setContextMapping([ 'user1' => 'anonymous',
'user2' => 'anonymous',
]);
$contexts['anonymous'
] = EntityContext::
fromEntity($this->anonymous
);
\Drupal::
service('context.handler'
)->
applyContextMapping($condition,
$contexts);
$this->
assertTrue($condition->
execute());
} /**
* Tests with each context mapped to different users.
*/
protected function doTestDifferentUser() { /** @var \Drupal\Core\Condition\ConditionPluginBase $condition */
$condition = \Drupal::
service('plugin.manager.condition'
) ->
createInstance('condition_test_dual_user'
) ->
setContextMapping([ 'user1' => 'anonymous',