public function ParagraphsPackTestCase::testParagraphsPackFieldViewModeInstanceCreation in Paragraphs pack 7
Test function for field view mode instance creation.
File
- tests/
paragraphs_pack.test, line 309 - Paragraphs pack primary module's tests.
Class
- ParagraphsPackTestCase
- Test Case for Paragraphs pack primary module.
Code
public function testParagraphsPackFieldViewModeInstanceCreation() {
$field_label = 'Test body';
// Run tested function.
paragraphs_pack_add_field_view_mode($this->paragraph_bundle_name, $field_label);
// Test field instance existence.
$field = paragraphs_pack_get_field_view_mode();
$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['required'], TRUE);
// Test display settings.
$display = array(
'default' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => -10,
),
'paragraphs_editor_preview' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => -10,
),
);
$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),
)));
}
}