function ConditionTestDualUserTest::doTestIdenticalUser

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

Tests with both contexts mapped to the same user.

1 call to ConditionTestDualUserTest::doTestIdenticalUser()
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 60

Class

ConditionTestDualUserTest
Tests a condition that requires two users.

Namespace

Drupal\KernelTests\Core\Plugin\Condition

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

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