function UserRoleConditionTest::testLegacy

@group legacy

File

core/modules/user/tests/src/Kernel/Condition/UserRoleConditionTest.php, line 156

Class

UserRoleConditionTest
Tests the user role condition.

Namespace

Drupal\Tests\user\Kernel\Condition

Code

public function testLegacy() {
    $this->expectDeprecation('Passing context values to plugins via configuration is deprecated in drupal:9.1.0 and will be removed before drupal:10.0.0. Instead, call ::setContextValue() on the plugin itself. See https://www.drupal.org/node/3120980');
    // Test Constructor injection.
    $condition = $this->manager
        ->createInstance('user_role', [
        'roles' => [
            RoleInterface::AUTHENTICATED_ID => RoleInterface::AUTHENTICATED_ID,
        ],
        'context' => [
            'user' => $this->authenticated,
        ],
    ]);
    $this->assertTrue($condition->execute(), 'Constructor injection of context and configuration working as anticipated.');
}

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