3 namespace Drupal\Tests\views\Kernel\Handler;
5 use Drupal\entity_test\Entity\EntityTestComputedField;
6 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
7 use Drupal\views\Views;
10 * Provides some integration tests for the Field handler.
12 * @see \Drupal\views\Plugin\views\field\EntityField
15 class ComputedFieldTest extends ViewsKernelTestBase {
18 * Views to be enabled.
22 public static $testViews = ['computed_field_view'];
29 public static $modules = ['entity_test'];
35 protected function setUp($import_test_views = TRUE) {
36 parent::setUp($import_test_views);
38 $this->installEntitySchema('entity_test_computed_field');
42 * Test the computed field handler.
44 public function testComputedFieldHandler() {
45 \Drupal::state()->set('entity_test_computed_field_item_list_value', ['computed string']);
47 $entity = EntityTestComputedField::create([]);
50 $view = Views::getView('computed_field_view');
52 $rendered_view = $view->preview();
53 $output = $this->container->get('renderer')->renderRoot($rendered_view);
54 $this->assertContains('computed string', (string) $output);