class ViewsDataTest
Same name in this branch
- 9 core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest
Same name and namespace in other branches
- 11.x core/modules/options/tests/src/Kernel/Views/ViewsDataTest.php \Drupal\Tests\options\Kernel\Views\ViewsDataTest
- 11.x core/modules/views/tests/src/Unit/ViewsDataTest.php \Drupal\Tests\views\Unit\ViewsDataTest
- 11.x core/modules/views/tests/src/Kernel/ViewsDataTest.php \Drupal\Tests\views\Kernel\ViewsDataTest
Test to ensure views data is properly created for the Options module.
@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\options\Kernel\Views\OptionsTestBase implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\options\Kernel\Views\ViewsDataTest implements \Drupal\Tests\options\Kernel\Views\OptionsTestBase
- class \Drupal\Tests\options\Kernel\Views\OptionsTestBase 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 ViewsDataTest
File
-
core/
modules/ options/ tests/ src/ Kernel/ Views/ ViewsDataTest.php, line 13
Namespace
Drupal\Tests\options\Kernel\ViewsView source
class ViewsDataTest extends OptionsTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'options',
'options_test',
'entity_test',
'views',
];
/**
* The field storage.
*
* @var \Drupal\Core\Field\FieldStorageDefinitionInterface
*/
protected $fieldStorage;
/**
* @var int
*/
protected $field;
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp();
$this->installEntitySchema('entity_test');
$field_name = 'test_options';
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'list_string',
'cardinality' => 1,
'settings' => [
'allowed_values_function' => 'options_test_dynamic_values_callback',
],
]);
$this->fieldStorage
->save();
$this->field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'required' => TRUE,
])->save();
}
/**
* Tests the option module's implementation of hook_field_views_data().
*/
public function testOptionsFieldViewsData() {
$field_data = \Drupal::service('views.views_data')->get('entity_test__test_options');
// Check that the options module has properly overridden default views data.
$test_options_field = $field_data['test_options_value'];
$this->assertEquals('string_list_field', $test_options_field['argument']['id'], 'Argument handler is properly set for fields with allowed value callbacks.');
$this->assertEquals('list_field', $test_options_field['filter']['id'], 'Filter handler is properly set for fields with allowed value callbacks.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.