#314147 follow-up by catch: Fixed typos with previous patch, and added tests.

merge-requests/26/head
Angie Byron 2008-11-09 00:58:03 +00:00
parent 88a6e82db1
commit 6da33f2055
3 changed files with 32 additions and 10 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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,10 +561,32 @@ 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.
*/