final protected function FeedsMapperTestBase::createContentType in Feeds 8.2
Create a new content-type, and add a field to it. Mostly copied from cck/tests/content.crud.test ContentUICrud::testAddFieldUI
Parameters
$settings: (Optional) An array of settings to pass through to drupalCreateContentType().
$fields: (Optional) an keyed array of $field_name => $field_type used to add additional fields to the new content type.
Return value
The machine name of the new content type.
See also
DrupalWebTestCase::drupalCreateContentType()
6 calls to FeedsMapperTestBase::createContentType()
- FeedsMapperDateMultipleTest::test in lib/
Drupal/ feeds/ Tests/ FeedsMapperDateMultipleTest.php - Testing import by loading a 4 item XML file.
- FeedsMapperDateTest::test in lib/
Drupal/ feeds/ Tests/ FeedsMapperDateTest.php - Basic test loading a single entry CSV file.
- FeedsMapperFieldTest::test in lib/
Drupal/ feeds/ Tests/ FeedsMapperFieldTest.php - Basic test loading a double entry CSV file.
- FeedsMapperFileTest::test in lib/
Drupal/ feeds/ Tests/ FeedsMapperFileTest.php - Basic test loading a single entry CSV file.
- FeedsMapperFileTest::testImages in lib/
Drupal/ feeds/ Tests/ FeedsMapperFileTest.php - Tests mapping to an image field.
File
- lib/
Drupal/ feeds/ Tests/ FeedsMapperTestBase.php, line 102 - Helper class with auxiliary functions for feeds mapper module tests.
Class
- FeedsMapperTestBase
- Base class for implementing Feeds Mapper test cases.
Namespace
Drupal\feeds\TestsCode
protected final function createContentType(array $settings = array(), array $fields = array()) {
$type = $this
->drupalCreateContentType($settings);
$typename = $type->type;
// Create the fields
foreach ($fields as $field_name => $options) {
if (is_string($options)) {
$options = array(
'type' => $options,
);
}
$field_type = isset($options['type']) ? $options['type'] : 'text';
$field_widget = isset($options['widget']) ? $options['widget'] : $this
->selectFieldWidget($field_name, $field_type);
$this
->assertTrue($field_widget !== NULL, "Field type {$field_type} supported");
$label = $field_name . '_' . $field_type . '_label';
$edit = array(
'fields[_add_new_field][label]' => $label,
'fields[_add_new_field][field_name]' => $field_name,
'fields[_add_new_field][type]' => $field_type,
'fields[_add_new_field][widget_type]' => $field_widget,
);
$this
->drupalPost("admin/structure/types/manage/{$typename}/fields", $edit, 'Save');
// (Default) Configure the field.
$edit = isset($options['settings']) ? $options['settings'] : array();
$this
->drupalPost(NULL, $edit, 'Save field settings');
$this
->assertText('Updated field ' . $label . ' field settings.');
$edit = isset($options['instance_settings']) ? $options['instance_settings'] : array();
$this
->drupalPost(NULL, $edit, 'Save settings');
$this
->assertText('Saved ' . $label . ' configuration.');
}
return $typename;
}