diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index 812d68032570e5aeeda53845d761b91eb96a386d..e094ff3a975b689499b19311b8e96bf12ae7250c 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -363,13 +363,13 @@ function node_type_form_submit($form, &$form_state) { node_types_rebuild(); menu_rebuild(); - node_add_body_field($type); $t_args = array('%name' => $type->name); if ($status == SAVED_UPDATED) { drupal_set_message(t('The content type %name has been updated.', $t_args)); } elseif ($status == SAVED_NEW) { + node_add_body_field($type); drupal_set_message(t('The content type %name has been added.', $t_args)); watchdog('node', 'Added content type %name.', $t_args, WATCHDOG_NOTICE, l(t('view'), 'admin/structure/types')); } diff --git a/modules/node/node.test b/modules/node/node.test index a2ab173085216a08d4f539fdf874e1d6b3b95e94..629509c7a01ecc20d3df9dd03051fa5a64352f2a 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -1056,9 +1056,10 @@ class NodeTypeTestCase extends DrupalWebTestCase { } /** - * Test creating a content type. + * Test creating a content type programmatically and via a form. */ function testNodeTypeCreation() { + // Create a content type programmaticaly. $type = $this->drupalCreateContentType(); $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $type->type))->fetchField(); @@ -1070,6 +1071,18 @@ class NodeTypeTestCase extends DrupalWebTestCase { $this->drupalGet('node/add/' . str_replace('_', '-', $type->name)); $this->assertResponse(200, 'The new content type can be accessed at node/add.'); + + // Create a content type via the user interface. + $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types')); + $this->drupalLogin($web_user); + $edit = array( + 'name' => 'foo', + 'title_label' => 'title for foo', + 'type' => 'foo', + ); + $this->drupalPost('admin/structure/types/add', $edit, t('Save content type')); + $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => 'foo'))->fetchField(); + $this->assertTrue($type_exists, 'The new content type has been created in the database.'); } /** @@ -1106,6 +1119,7 @@ class NodeTypeTestCase extends DrupalWebTestCase { 'description' => 'Lorem ipsum.', ); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); + field_info_cache_clear(); $this->drupalGet('node/add'); $this->assertRaw('Bar', t('New name was displayed.')); @@ -1114,6 +1128,14 @@ class NodeTypeTestCase extends DrupalWebTestCase { $this->assertEqual(url('node/add/bar', array('absolute' => TRUE)), $this->getUrl(), t('New machine name was used in URL.')); $this->assertRaw('Foo', t('Title field was found.')); $this->assertRaw('Body', t('Body field was found.')); + + // Remove the body field. + $this->drupalPost('admin/structure/types/manage/bar/fields/body/delete', NULL, t('Delete')); + // Resave the settings for this type. + $this->drupalPost('admin/structure/types/manage/bar', array(), t('Save content type')); + // Check that the body field doesn't exist. + $this->drupalGet('node/add/bar'); + $this->assertNoRaw('Body', t('Body field was not found.')); } }