Commit 6b0f13f0 authored by webchick's avatar webchick

#569206 by mikey_p, justinrandell: Fixed body field re-added when node type settings are re-saved.

parent 0e68871d
......@@ -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'));
}
......
......@@ -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.'));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment