summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/taxonomy/taxonomy.admin.inc3
-rw-r--r--modules/taxonomy/taxonomy.module7
-rw-r--r--modules/taxonomy/taxonomy.test32
3 files changed, 32 insertions, 10 deletions
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index 2deb4eeba..af96fda63 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -513,7 +513,8 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
}
// Save all updated terms.
- foreach ($changed_terms as $term) {
+ foreach ($changed_terms as $changed) {
+ $term = (object)$changed;
taxonomy_term_save($term);
}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 5dc0771bb..ffb126e4a 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -361,7 +361,7 @@ function taxonomy_term_save($term) {
}
}
else {
- db_insert('term_hierarchy')->field(array('tid' => $term_tid, 'parent' => $term->parent))->execute();
+ db_insert('term_hierarchy')->fields(array('tid' => $term->tid, 'parent' => $term->parent))->execute();
}
db_delete('term_synonym')->condition('tid', $term->tid)->execute();
@@ -685,8 +685,9 @@ function taxonomy_node_save($node, $terms) {
if (!$typed_term_tid) {
$edit = array('vid' => $vid, 'name' => $typed_term);
- $status = taxonomy_term_save($edit);
- $typed_term_tid = $edit['tid'];
+ $term = (object)$edit;
+ $status = taxonomy_term_save($term);
+ $typed_term_tid = $term->tid;
}
// Defend against duplicate, differently cased tags
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 08f98dbb2..7f34de9de 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -542,8 +542,7 @@ class TaxonomyTestNodeApiTestCase extends DrupalWebTestCase {
}
/**
- * Test term edit form to ensure terms can be edited from administration page
- * and that term name and description are saved.
+ * Test term editing and creation.
*/
class TermEditTestCase extends DrupalWebTestCase {
/**
@@ -551,9 +550,8 @@ class TermEditTestCase extends DrupalWebTestCase {
*/
function getInfo() {
return array(
- 'name' => 'Term edit test',
- 'description' => t('Ensure terms can be edited from administration page
- and that term name and description are saved.'),
+ 'name' => 'Term creation and editing',
+ 'description' => t('Ensure terms can be created and saved via taxonomy administration and freetagging forms.'),
'group' => t('Taxonomy'));
}
@@ -563,11 +561,33 @@ class TermEditTestCase extends DrupalWebTestCase {
function setUp() {
parent::setUp();
// Prepare a user to do the tests.
- $web_user = $this->drupalCreateUser(array('administer taxonomy'));
+ $web_user = $this->drupalCreateUser(array('administer taxonomy', 'create article content'));
$this->drupalLogin($web_user);
}
/**
+ * Test term creation with a free-tagging vocabulary from the node form.
+ */
+ function testNodeTermCreation() {
+ $terms = array(
+ $this->randomName(),
+ $this->randomName(),
+ $this->randomName(),
+ );
+ $edit = array();
+ $edit['title'] = $this->randomName();
+ // Insert the terms in a comma separated list. Vocabulary 1 is a
+ // free-tagging field created by the default profile.
+ $edit['taxonomy[tags][1]'] = implode(', ', $terms);
+ $edit['body'] = $this->randomName();
+ $this->drupalPost('node/add/article', $edit, t('Save'));
+ $this->assertRaw(t('@type %title has been created.', array('@type' => t('Article'), '%title' => $edit['title'])), t('The node was created successfully'));
+ foreach ($terms as $term) {
+ $this->assertText($term, t('The term was saved and appears on the node page'));
+ }
+ }
+
+ /**
* Save and edit a term and assert that the name and description are correct.
*/
function testTermEdit() {