ViewsDataTest.php in Zircon Profile 8
File
core/modules/options/src/Tests/Views/ViewsDataTest.php
View source
<?php
namespace Drupal\options\Tests\Views;
class ViewsDataTest extends OptionsTestBase {
public static $modules = [
'options',
'options_test',
'entity_test',
'views',
];
protected $fieldStorage;
public function setUp() {
parent::setUp();
$field_name = 'test_options';
$this->fieldStorage = entity_create('field_storage_config', [
'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 = entity_create('field_config', [
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'required' => TRUE,
])
->save();
}
public function testOptionsFieldViewsData() {
$field_data = \Drupal::service('views.views_data')
->get('entity_test__test_options');
$test_options_field = $field_data['test_options_value'];
$this
->assertEqual($test_options_field['argument']['id'], 'string_list_field', 'Argument handler is properly set for fields with allowed value callbacks.');
$this
->assertEqual($test_options_field['filter']['id'], 'list_field', 'Filter handler is properly set for fields with allowed value callbacks.');
}
}
Classes
Name |
Description |
ViewsDataTest |
Test to ensure views data is properly created for the Options module. |