final protected function FeedsMapperTestCase::createContentType in Feeds 7.2
Same name and namespace in other branches
- 6 tests/feeds_mapper.test \FeedsMapperTestCase::createContentType()
- 7 tests/feeds_mapper_test.inc \FeedsMapperTestCase::createContentType()
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()
26 calls to FeedsMapperTestCase::createContentType()
- FeedsAccountSwitcherTest::testAuthorizedImport in tests/
FeedsAccountSwitcherTest.test - Tests if an extra account switch happens on authorized imports.
- Feedsi18nNodeTestCase::setUp in tests/
feeds_i18n_node.test - Sets up a Drupal site for running functional and integration tests.
- FeedsMapperDateMultipleTestCase::test in tests/
feeds_mapper_date_multiple.test - Testing import by loading a 4 item XML file.
- FeedsMapperDateTestCase::test in tests/
feeds_mapper_date.test - Basic test loading a single entry CSV file.
- FeedsMapperDateTestCase::testClearOutValues in tests/
feeds_mapper_date.test - Tests if values are cleared out when an empty value is provided.
File
- tests/
feeds_mapper.test, line 134 - Contains FeedsMapperTestCase.
Class
- FeedsMapperTestCase
- Helper class with auxiliary functions for feeds mapper module tests.
Code
protected final function createContentType(array $settings = array(), array $fields = array()) {
$type = $this
->drupalCreateContentType($settings);
$typename = $type->type;
$admin_type_url = 'admin/structure/types/manage/' . str_replace('_', '-', $typename);
// 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_type_url . '/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;
}