You are here

protected function ConditionTestDualUserTest::doTestIdenticalUser in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/condition_test/src/Tests/ConditionTestDualUserTest.php \Drupal\condition_test\Tests\ConditionTestDualUserTest::doTestIdenticalUser()

Tests with both contexts mapped to the same user.

1 call to ConditionTestDualUserTest::doTestIdenticalUser()
ConditionTestDualUserTest::testConditions in core/modules/system/tests/modules/condition_test/src/Tests/ConditionTestDualUserTest.php
Tests the dual user condition.

File

core/modules/system/tests/modules/condition_test/src/Tests/ConditionTestDualUserTest.php, line 65
Contains \Drupal\condition_test\Tests\ConditionTestDualUserTest.

Class

ConditionTestDualUserTest
Tests a condition that requires two users.

Namespace

Drupal\condition_test\Tests

Code

protected function doTestIdenticalUser() {

  /** @var \Drupal\Core\Condition\ConditionPluginBase $condition */
  $condition = \Drupal::service('plugin.manager.condition')
    ->createInstance('condition_test_dual_user')
    ->setContextMapping([
    'user1' => 'anonymous',
    'user2' => 'anonymous',
  ]);
  $definition = new ContextDefinition('entity:user');
  $contexts['anonymous'] = new Context($definition, $this->anonymous);
  \Drupal::service('context.handler')
    ->applyContextMapping($condition, $contexts);
  $this
    ->assertTrue($condition
    ->execute());
}