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'];
34 protected function setUp($import_test_views = TRUE) {
35 parent::setUp($import_test_views);
37 $this->installEntitySchema('entity_test_computed_field');
41 * Test the computed field handler.
43 public function testComputedFieldHandler() {
44 \Drupal::state()->set('entity_test_computed_field_item_list_value', ['computed string']);
46 $entity = EntityTestComputedField::create([]);
49 $view = Views::getView('computed_field_view');
51 $rendered_view = $view->preview();
52 $output = $this->container->get('renderer')->renderRoot($rendered_view);
53 $this->assertContains('computed string', (string) $output);