protected function EckTestHelper::addField in Entity Construction Kit (ECK) 7.2
Add a field to a given entity type.
Parameters
string $entity_type: The machine name of the entity type for this entity object; defaults to 'test_entity'.
string $bundle: The machine name of the bundle for this entity object; defaults to 'test_entity'.
1 call to EckTestHelper::addField()
- EckEntityTranslationTest::testTranslations in tests/
EckEntityTranslationTest.test - Test translating an entity type.
File
- tests/
EckTestHelper.test, line 109 - The EckTestHelper class.
Class
- EckTestHelper
- Helper logic for the other ECK tests.
Code
protected function addField($entity_type = 'test_entity', $bundle = 'test_entity') {
$this
->drupalGet("admin/structure/entity-type/{$entity_type}/{$bundle}/fields");
$this
->assertResponse(200);
$edit = array(
'fields[_add_new_field][label]' => 'Body',
'fields[_add_new_field][weight]' => 1,
'fields[_add_new_field][field_name]' => 'body',
'fields[_add_new_field][type]' => 'text_long',
'fields[_add_new_field][widget_type]' => 'text_textarea',
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertResponse(200);
$this
->assertText('has no field settings');
$this
->drupalPost(NULL, array(), t('Save field settings'));
$this
->assertResponse(200);
$this
->assertText('Updated field Body field settings.');
$edit = array(
'field[translatable]' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Save settings'));
$this
->assertResponse(200);
$this
->assertText('Saved Body configuration');
}