summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-06-24 22:23:06 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-06-24 22:23:06 +0000
commit6b0f13f03c784284e01986ee480f8189116b03a2 (patch)
tree1fb6b30be55e620a523d2e8ba3d993c4eb1bf5b5
parent0e68871da85154d9d35c64771361b8f157870a62 (diff)
downloadbrdo-6b0f13f03c784284e01986ee480f8189116b03a2.tar.gz
brdo-6b0f13f03c784284e01986ee480f8189116b03a2.tar.bz2
#569206 by mikey_p, justinrandell: Fixed body field re-added when node type settings are re-saved.
-rw-r--r--modules/node/content_types.inc2
-rw-r--r--modules/node/node.test24
2 files changed, 24 insertions, 2 deletions
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index 812d68032..e094ff3a9 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 a2ab17308..629509c7a 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.'));
}
}