function ConditionTestDualUserTest::doTestDifferentUser

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Plugin/Condition/ConditionTestDualUserTest.php \Drupal\KernelTests\Core\Plugin\Condition\ConditionTestDualUserTest::doTestDifferentUser()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Plugin/Condition/ConditionTestDualUserTest.php \Drupal\KernelTests\Core\Plugin\Condition\ConditionTestDualUserTest::doTestDifferentUser()
  3. 11.x core/tests/Drupal/KernelTests/Core/Plugin/Condition/ConditionTestDualUserTest.php \Drupal\KernelTests\Core\Plugin\Condition\ConditionTestDualUserTest::doTestDifferentUser()

Tests with each context mapped to different users.

1 call to ConditionTestDualUserTest::doTestDifferentUser()
ConditionTestDualUserTest::testConditions in core/tests/Drupal/KernelTests/Core/Plugin/Condition/ConditionTestDualUserTest.php
Tests the dual user condition.

File

core/tests/Drupal/KernelTests/Core/Plugin/Condition/ConditionTestDualUserTest.php, line 77

Class

ConditionTestDualUserTest
Tests a condition that requires two users.

Namespace

Drupal\KernelTests\Core\Plugin\Condition

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',
    ]);
    $contexts['anonymous'] = EntityContext::fromEntity($this->anonymous);
    $contexts['authenticated'] = EntityContext::fromEntity($this->authenticated);
    \Drupal::service('context.handler')->applyContextMapping($condition, $contexts);
    $this->assertFalse($condition->execute());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.