You are here

protected function ConditionTestDualUserTest::doTestDifferentUser 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::doTestDifferentUser()

Tests with each context mapped to different users.

1 call to ConditionTestDualUserTest::doTestDifferentUser()
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 83
Contains \Drupal\condition_test\Tests\ConditionTestDualUserTest.

Class

ConditionTestDualUserTest
Tests a condition that requires two users.

Namespace

Drupal\condition_test\Tests

Code

protected function doTestDifferentUser() {

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