You are here

public function AutocompleteTest::testAutocomplete in Rules 8.3

Tests autocompletion works for a variable in the metadata state.

File

tests/src/Kernel/Engine/AutocompleteTest.php, line 61

Class

AutocompleteTest
Tests that data selector autocomplete results work correctly.

Namespace

Drupal\Tests\rules\Kernel\Engine

Code

public function testAutocomplete() {
  $rule = $this->expressionManager
    ->createRule();
  $action = $this->expressionManager
    ->createAction('rules_data_set');
  $rule
    ->addExpressionObject($action);
  $results = RulesComponent::create($rule)
    ->addContextDefinition('entity', ContextDefinition::create('entity'))
    ->autocomplete('e', $action);
  $this
    ->assertSame([
    [
      'value' => 'entity',
      'label' => 'entity',
    ],
    [
      'value' => 'entity.',
      'label' => 'entity...',
    ],
  ], $results);
}