public function FivestarBaseTestCase::createFivestarField in Fivestar 7.2
Same name and namespace in other branches
- 8 test/fivestar.base.test \FivestarBaseTestCase::createFivestarField()
Add a fivestar field to a content type.
Parameters
array $options: An associative array of options for the field and instance.
5 calls to FivestarBaseTestCase::createFivestarField()
- FivestarTestCase::testAuthorRating in test/
fivestar.field.test - Test that authors can rate their own content.
- FivestarTestCase::testExposedWidgetDisplay in test/
fivestar.field.test - Tests changing the fivestar widget.
- FivestarTestCase::testViewerNonRating in test/
fivestar.field.test - Test exposed display setting.
- 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 47 - Test base for the Fivestar module.
Class
- FivestarBaseTestCase
- Base class for Fivestar Ajax tests.
Code
public function createFivestarField(array $options = array()) {
$options = $options + array(
'content_type' => 'test_node_type',
'widget_type' => 'stars',
'display' => array(),
);
$field = array(
'field_name' => 'fivestar_test',
'type' => 'fivestar',
'cardinality' => 1,
'settings' => array(
'axis' => 'vote',
),
);
$instance = array(
'entity_type' => 'node',
'field_name' => 'fivestar_test',
'label' => 'Fivestar test field',
'bundle' => $options['content_type'],
'widget' => array(
'type' => $options['widget_type'],
'settings' => array(
'widget' => array(
'fivestar_widget' => 'default',
),
),
),
'settings' => array(
'axis' => 'vote',
'stars' => '5',
),
'display' => $options['display'],
);
field_create_field($field);
field_create_instance($instance);
}