function ComputedBundleFieldTest::setUp
Same name in other branches
- 11.x core/modules/views/tests/src/Kernel/Handler/ComputedBundleFieldTest.php \Drupal\Tests\views\Kernel\Handler\ComputedBundleFieldTest::setUp()
Overrides ViewsKernelTestBase::setUp
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ ComputedBundleFieldTest.php, line 35
Class
- ComputedBundleFieldTest
- Provides some integration tests for computed bundle fields.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
protected function setUp($import_test_views = TRUE) : void {
// Don't install the test view until the bundles are defined.
parent::setUp(FALSE);
$this->installEntitySchema('entity_test_comp_bund_fld');
// Create a default bundle that has a computed field.
entity_test_create_bundle('entity_test_comp_bund_fld_bund', NULL, 'entity_test_comp_bund_fld');
// Create a second bundle that also has a computed field.
entity_test_create_bundle('entity_test_comp_bund_fld_bund_2', NULL, 'entity_test_comp_bund_fld');
// Create a bundle that does not have the computed field.
entity_test_create_bundle('entity_test_bundle_no_comp_field', NULL, 'entity_test_comp_bund_fld');
ViewTestData::createTestViews(static::class, [
'views_test_config',
]);
// Create an entity using the default bundle with a computed field.
$entity_with_comp_field = EntityTestComputedBundleField::create([
'type' => 'entity_test_comp_bund_fld_bund',
'name' => 'Entity with bundle field',
]);
$entity_with_comp_field->save();
// Create an entity using the second bundle with a computed field.
$entity_with_comp_field_2 = EntityTestComputedBundleField::create([
'type' => 'entity_test_comp_bund_fld_bund_2',
'name' => 'Entity 2 with bundle field',
]);
$entity_with_comp_field_2->save();
// Create an entity using the third bundle without a computed field.
$entity_no_computed_field = EntityTestComputedBundleField::create([
'type' => 'entity_test_bundle_no_comp_field',
'name' => 'Entity without bundle field',
]);
$entity_no_computed_field->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.