You are here

public function ComputedFieldTest::testComputedFieldHandler in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Handler/ComputedFieldTest.php \Drupal\Tests\views\Kernel\Handler\ComputedFieldTest::testComputedFieldHandler()

Tests the computed field handler.

File

core/modules/views/tests/src/Kernel/Handler/ComputedFieldTest.php, line 43

Class

ComputedFieldTest
Provides some integration tests for the Field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testComputedFieldHandler() {
  \Drupal::state()
    ->set('entity_test_computed_field_item_list_value', [
    'computed string',
  ]);
  $entity = EntityTestComputedField::create([]);
  $entity
    ->save();
  $view = Views::getView('computed_field_view');
  $rendered_view = $view
    ->preview();
  $output = $this->container
    ->get('renderer')
    ->renderRoot($rendered_view);
  $this
    ->assertStringContainsString('computed string', (string) $output);
}