public function FivestarBaseTestCase::createFivestarField in Fivestar 8
Same name and namespace in other branches
- 7.2 test/fivestar.base.test \FivestarBaseTestCase::createFivestarField()
Add a fivestar field to a content type.
Parameters
$options: An associative array of options for the field and instance.
3 calls to FivestarBaseTestCase::createFivestarField()
- FivestarTestCase::testExposedWidgetDisplay in test/
fivestar.field.test - Test that we can switch the fivestar widgets around for the exposed widget type.
- FivestarTestCase::testViewerRating in test/
fivestar.field.test - Test that users can rate content with exposed widgets.
- FivestarTestCase::testViewerRatingAjax in test/
fivestar.field.test - Test that users can rate content with exposed widgets.
File
- test/
fivestar.base.test, line 41 - Based test file for the Fivestar module.
Class
Code
public function createFivestarField($options = []) {
$options = $options + [
'content_type' => 'test_node_type',
'widget_type' => 'stars',
'display' => [],
];
$field = [
'field_name' => 'fivestar_test',
'type' => 'fivestar',
'cardinality' => 1,
'settings' => [
'axis' => 'vote',
],
];
$instance = [
'entity_type' => 'node',
'field_name' => 'fivestar_test',
'label' => 'Fivestar test field',
'bundle' => $options['content_type'],
'widget' => [
'type' => $options['widget_type'],
'settings' => [
'widget' => [
'fivestar_widget' => 'default',
],
],
],
'settings' => [
'axis' => 'vote',
'stars' => '5',
],
'display' => $options['display'],
];
field_create_field($field);
field_create_instance($instance);
}