class ComputedFieldTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Handler/ComputedFieldTest.php \Drupal\Tests\views\Kernel\Handler\ComputedFieldTest
- 10 core/modules/views/tests/src/Kernel/Handler/ComputedFieldTest.php \Drupal\Tests\views\Kernel\Handler\ComputedFieldTest
Provides some integration tests for the Field handler.
@group views
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\views\Kernel\Handler\ComputedFieldTest implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ComputedFieldTest
See also
\Drupal\views\Plugin\views\field\EntityField
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ ComputedFieldTest.php, line 15
Namespace
Drupal\Tests\views\Kernel\HandlerView source
class ComputedFieldTest extends ViewsKernelTestBase {
/**
* Views to be enabled.
*
* @var array
*/
public static $testViews = [
'computed_field_view',
];
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_test',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this->installEntitySchema('entity_test_computed_field');
}
/**
* Tests the computed field handler.
*/
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.