You are here

public function EntityFormBlockTestCase::addEntityFormBlock in Entityform block 7

1 call to EntityFormBlockTestCase::addEntityFormBlock()
EntityFormBlockTestCase::testEntityFormBlock in ./entityform_block.test

File

./entityform_block.test, line 33
Tests for the Entityform Block module

Class

EntityFormBlockTestCase
@file Tests for the Entityform Block module

Code

public function addEntityFormBlock() {
  $this
    ->drupalGet('admin/structure/entityform_types/add');
  $this
    ->assertText(t('Enable as a block'), "Option to enable a block appears on the entity form creation page");
  $this
    ->assertNoFieldChecked('edit-data-block-set-enable-block', "Enable block is not checked.");
  $edit['label'] = $this->entityFormType;
  $edit['type'] = $this->entityFormType;
  $edit['data[block_set][enable_block]'] = TRUE;
  $this
    ->drupalPost('admin/structure/entityform_types/add', $edit, t('Save entityform type'));
  $this
    ->assertRaw(t('The Entityform @title has been created.', array(
    '@title' => $edit['label'],
  )), 'Entitytype form has been created');
  $this
    ->assertRaw(t('Entityform block @title has been created', array(
    '@title' => $edit['label'],
  )), 'Entityform block has been created');
  $block_types = array();
  $block_types = variable_get('entityform_block_types');
  $exists = entityform_block_exists($block_types, $this->entityFormType);
  $this
    ->assertNotNull($exists, 'The entityform type block is in the variable');
  $delta = db_query("SELECT delta from {block} where module = :module and delta = :delta", array(
    ':module' => 'entityform_block',
    ':delta' => $this->entityFormType,
  ))
    ->fetchField();
  $this
    ->assertNotNull($delta, t('Block found in the database'));

  // Add some fields.
  $field_edit = array(
    'fields[_add_new_field][field_name]' => $this->entityFieldName,
    'fields[_add_new_field][label]' => $this->entityFieldName,
    'fields[_add_new_field][type]' => 'text',
    'fields[_add_new_field][widget_type]' => 'text_textfield',
  );
  $url = 'admin/structure/entityform_types/manage/' . $this->entityFormType . '/fields';
  $this
    ->drupalPost($url, $field_edit, t('Save'));
  $this
    ->drupalPost(NULL, NULL, t('Save field settings'));
  $this
    ->assertText(t('Updated field @type field settings.', array(
    '@type' => $this->entityFieldName,
  )));
}