function ContextIntegrationTest::testAssignmentRestriction

Tests the assignment restriction on context definitions.

File

tests/src/Kernel/ContextIntegrationTest.php, line 100

Class

ContextIntegrationTest
Tests the extended core context API with Rules.

Namespace

Drupal\Tests\rules\Kernel

Code

public function testAssignmentRestriction() {
    $action_manager = $this->container
        ->get('plugin.manager.rules_action');
    // Test the assignment restriction on the entity fetch action as an example.
    $entity_fetch_action = $action_manager->createInstance('rules_entity_fetch_by_id');
    $context_definition = $entity_fetch_action->getContextDefinition('type');
    $this->assertEquals(ContextDefinition::ASSIGNMENT_RESTRICTION_INPUT, $context_definition->getAssignmentRestriction());
    // Test the assignment restriction on the entity delete action.
    $entity_delete_action = $action_manager->createInstance('rules_entity_delete');
    $context_definition = $entity_delete_action->getContextDefinition('entity');
    $this->assertEquals(ContextDefinition::ASSIGNMENT_RESTRICTION_SELECTOR, $context_definition->getAssignmentRestriction());
}