public function ParagraphsPackTestCase::testParagraphsPackFieldTitleInstanceCreation in Paragraphs pack 7
Test function for field title instance creation.
File
- tests/
paragraphs_pack.test, line 81 - Paragraphs pack primary module's tests.
Class
- ParagraphsPackTestCase
- Test Case for Paragraphs pack primary module.
Code
public function testParagraphsPackFieldTitleInstanceCreation() {
$field_label = 'Test title';
// Run function that's being tested.
paragraphs_pack_add_field_title($this->paragraph_bundle_name, $field_label);
// Test field instance existence.
$field = paragraphs_pack_get_field_title();
$instance_info = field_info_instance(PP_PARAGRAPH_TYPE, $field['field_name'], $this->paragraph_bundle_name);
$instance_exists = !empty($instance_info);
$this
->assertTrue($instance_exists, t('Instance was created successfully.'));
// Test field instance settings.
if ($instance_exists) {
$this
->assertEqual($instance_info['field_name'], $field['field_name']);
$this
->assertEqual($instance_info['entity_type'], PP_PARAGRAPH_TYPE);
$this
->assertEqual($instance_info['bundle'], $this->paragraph_bundle_name);
$this
->assertEqual($instance_info['label'], $field_label);
$this
->assertEqual($instance_info['widget']['type'], 'text_textfield');
$this
->assertEqual($instance_info['settings']['text_processing'], 0);
$this
->assertEqual($instance_info['settings']['user_register_form'], FALSE);
// Test display settings.
$display = array(
'default' => array(
'label' => 'hidden',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
),
'paragraphs_editor_preview' => array(
'label' => 'hidden',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
),
);
$display_difference = $this
->array_diff_assoc_deep($display, $instance_info['display']);
$this
->assertTrue(empty($display_difference), t('Display contains all specified settings. Differences (print_r) %differences', array(
'%differences' => print_r($display_difference, TRUE),
)));
}
}