public function ParagraphsPackTestCase::testParagraphsPackFieldItemsCreation in Paragraphs pack 7
Test function for field items creation.
File
- tests/
paragraphs_pack.test, line 207 - Paragraphs pack primary module's tests.
Class
- ParagraphsPackTestCase
- Test Case for Paragraphs pack primary module.
Code
public function testParagraphsPackFieldItemsCreation() {
$target_type = 'node';
// Run tested function.
$field = paragraphs_pack_get_field_items($target_type);
// Test field existence.
$field_exists = !empty($field);
$this
->assertTrue($field_exists, t('Field was created successfully.'));
$field_info = field_info_field($field['field_name']);
$field_info_exists = !empty($field_info);
$this
->assertTrue($field_info_exists, t('Field was created successfully.'));
// Test field settings.
if ($field_info_exists) {
$this
->assertEqual($field_info['field_name'], PP_FIELD_ITEMS . '_' . $target_type);
$this
->assertEqual($field_info['type'], 'entityreference');
$this
->assertEqual($field_info['entity_types'], array(
PP_PARAGRAPH_TYPE,
));
$this
->assertEqual($field_info['cardinality'], FIELD_CARDINALITY_UNLIMITED);
$this
->assertEqual($field_info['settings']['target_type'], $target_type);
}
}