Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Handler / ComputedFieldTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Kernel\Handler;
4
5 use Drupal\entity_test\Entity\EntityTestComputedField;
6 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
7 use Drupal\views\Views;
8
9 /**
10  * Provides some integration tests for the Field handler.
11  *
12  * @see \Drupal\views\Plugin\views\field\EntityField
13  * @group views
14  */
15 class ComputedFieldTest extends ViewsKernelTestBase {
16
17   /**
18    * Views to be enabled.
19    *
20    * @var array
21    */
22   public static $testViews = ['computed_field_view'];
23
24   /**
25    * Modules to enable.
26    *
27    * @var array
28    */
29   public static $modules = ['entity_test'];
30
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function setUp($import_test_views = TRUE) {
36     parent::setUp($import_test_views);
37
38     $this->installEntitySchema('entity_test_computed_field');
39   }
40
41   /**
42    * Test the computed field handler.
43    */
44   public function testComputedFieldHandler() {
45     \Drupal::state()->set('entity_test_computed_field_item_list_value', ['computed string']);
46
47     $entity = EntityTestComputedField::create([]);
48     $entity->save();
49
50     $view = Views::getView('computed_field_view');
51
52     $rendered_view = $view->preview();
53     $output = $this->container->get('renderer')->renderRoot($rendered_view);
54     $this->assertContains('computed string', (string) $output);
55   }
56
57 }