protected function EckTestHelper::createEntityType in Entity Construction Kit (ECK) 7.2
Create an entity type.
Parameters
array $args: Any arguments to be passed to the form. Key elements include:
- 'entity_type_label'
- 'entity_type_name'
- 'bundle_label' - If not present, a bundle with the same name as the entity type will be created.
- 'bundle_name' - If not present, a bundle with the same name as the entity type will be created.
2 calls to EckTestHelper::createEntityType()
- EckCrudTest::testProcess in tests/
EckCrudTest.test - Confirm that entity types can be created, bundles created, etc.
- EckEntityTranslationTest::testTranslations in tests/
EckEntityTranslationTest.test - Test translating an entity type.
File
- tests/
EckTestHelper.test, line 60 - The EckTestHelper class.
Class
- EckTestHelper
- Helper logic for the other ECK tests.
Code
protected function createEntityType(array $args = array()) {
// Load the 'add type' form, confirm it is what was expected.
$this
->drupalGet('admin/structure/entity-type/add');
$this
->assertResponse(200);
$this
->assertFieldByName('entity_type_label');
$this
->assertFieldByName('entity_type_name');
$this
->assertFieldByName('bundle_label');
$this
->assertFieldByName('bundle_name');
$this
->assertFieldByName('default_properties[title]');
$this
->assertFieldByName('default_properties[uid]');
$this
->assertFieldByName('default_properties[created]');
$this
->assertFieldByName('default_properties[changed]');
$this
->assertFieldByName('default_properties[language]');
// Default values.
$edit = $args + array(
'entity_type_label' => 'Test entity',
'entity_type_name' => 'test_entity',
'bundle_label' => '',
'bundle_name' => '',
'default_properties[title]' => TRUE,
'default_properties[uid]' => TRUE,
'default_properties[created]' => TRUE,
'default_properties[changed]' => TRUE,
'default_properties[language]' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertResponse(200);
// Confirm the submission worked.
$this
->assertText(strip_tags(t('The entity type %entity_type has been created.', array(
'%entity_type' => $edit['entity_type_label'],
))));
$this
->assertEqual($this
->getUrl(), url('admin/structure/entity-type/' . $edit['entity_type_name'], array(
'absolute' => TRUE,
)));
$this
->assertLinkByHref(url('admin/structure/entity-type/' . $edit['entity_type_name']));
$this
->assertLink('delete');
$this
->assertLinkByHref(url('admin/structure/entity-type/' . $edit['entity_type_name'] . '/delete'));
// @todo Bug: Upon creating a new entity type the visitor should see the "bundle list" page, instead the "entity types" list page is shown.
}