You are here

public function ClassyParagraphsTestFieldClass::testClassyParagraphsFieldClass in Classy paragraphs 7

Check markup class.

File

tests/classy_paragraphs.test, line 168
Contains tests for Classy Paragraphs.

Class

ClassyParagraphsTestFieldClass
Class ClassyParagraphsTestFieldClass

Code

public function testClassyParagraphsFieldClass() {
  $field_name = 'cp_test_field';
  $field_label = 'Test field';
  $entity_type = 'paragraphs_item';
  $bundle = 'cp_test_content';

  // Test creation of class field.
  $field = array(
    'field_name' => $field_name,
    'type' => CLASSY_PARAGRAPHS_FIELD_TYPE_LIST,
    'entity_types' => array(
      CLASSY_PARAGRAPHS_ENTITY_TYPE,
    ),
  );
  field_create_field($field);
  $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 creation of class field instance.
  $instance = array(
    'field_name' => $field['field_name'],
    'entity_type' => $entity_type,
    'bundle' => $bundle,
    'label' => $field_label,
  );
  field_create_instance($instance);
  $instance_info = field_info_instance($entity_type, $field['field_name'], $bundle);
  $instance_exists = !empty($instance_info);
  $this
    ->assertTrue($instance_exists, t('Instance was created successfully.'));
}