You are here

public function AutocompleteTest::testListAutocomplete in Rules 8.3

Tests that autocomplete results for a flat list are correct.

File

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

Class

AutocompleteTest
Tests that data selector autocomplete results work correctly.

Namespace

Drupal\Tests\rules\Kernel\Engine

Code

public function testListAutocomplete() {
  $rule = $this->expressionManager
    ->createRule();
  $rule
    ->addAction('rules_data_set');
  $context_definition = ContextDefinition::create('integer');
  $context_definition
    ->setMultiple();
  $component = RulesComponent::create($rule)
    ->addContextDefinition('list', $context_definition);
  $results = $component
    ->autocomplete('list.');
  $this
    ->assertSame([
    [
      'value' => 'list.0',
      'label' => 'list.0',
    ],
    [
      'value' => 'list.1',
      'label' => 'list.1',
    ],
    [
      'value' => 'list.2',
      'label' => 'list.2',
    ],
  ], $results);
}