Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
585aa50e
Commit
585aa50e
authored
Jan 28, 2009
by
Angie Byron
Browse files
#346156
by stBorchert, swentel, and catch: Fix deletion of terms (with tests).
parent
f5a4f24b
Changes
5
Hide whitespace changes
Inline
Side-by-side
modules/forum/forum.admin.inc
View file @
585aa50e
...
...
@@ -173,7 +173,7 @@ function forum_confirm_delete(&$form_state, $tid) {
* Implementation of forms api _submit call. Deletes a forum after confirmation.
*/
function
forum_confirm_delete_submit
(
$form
,
&
$form_state
)
{
taxonomy_del
_
te
rm
(
$form_state
[
'values'
][
'tid'
]);
taxonomy_
term_
del
e
te
(
$form_state
[
'values'
][
'tid'
]);
drupal_set_message
(
t
(
'The forum %term and all sub-forums have been deleted.'
,
array
(
'%term'
=>
$form_state
[
'values'
][
'name'
])));
watchdog
(
'content'
,
'forum: deleted %term and all its sub-forums.'
,
array
(
'%term'
=>
$form_state
[
'values'
][
'name'
]));
...
...
modules/forum/forum.test
View file @
585aa50e
...
...
@@ -103,6 +103,10 @@ class ForumTestCase extends DrupalWebTestCase {
$this
->
container
=
$this
->
createForum
(
'container'
);
// Create forum inside the forum container.
$this
->
forum
=
$this
->
createForum
(
'forum'
,
$this
->
container
[
'tid'
]);
// Create second forum in container.
$this
->
delete_forum
=
$this
->
createForum
(
'forum'
,
$this
->
container
[
'tid'
]);
// Delete this second form.
$this
->
deleteForum
(
$this
->
delete_forum
[
'tid'
]);
// Create forum at the top (root) level.
$this
->
root_forum
=
$this
->
createForum
(
'forum'
);
}
...
...
@@ -181,6 +185,21 @@ class ForumTestCase extends DrupalWebTestCase {
return
$term
;
}
/**
* Delete a forum.
*
* @param integer $tid Forum id.
*/
function
deleteForum
(
$tid
)
{
// Delete the forum id.
$this
->
drupalPost
(
'admin/build/forum/edit/forum/'
.
$tid
,
array
(),
t
(
'Delete'
));
$this
->
drupalPost
(
NULL
,
NULL
,
t
(
'Delete'
));
// Assert that the forum no longer exists.
$this
->
drupalGet
(
'forum/'
.
$tid
);
$this
->
assertRaw
(
t
(
'No forums defined'
),
'The forum was not found'
);
}
/**
* Run basic tests on the indicated user.
*
...
...
modules/taxonomy/taxonomy.admin.inc
View file @
585aa50e
...
...
@@ -837,7 +837,7 @@ function taxonomy_term_confirm_delete(&$form_state, $tid) {
* @see taxonomy_term_confirm_delete()
*/
function
taxonomy_term_confirm_delete_submit
(
$form
,
&
$form_state
)
{
taxonomy_del
_
te
rm
(
$form_state
[
'values'
][
'tid'
]);
taxonomy_
term_
del
e
te
(
$form_state
[
'values'
][
'tid'
]);
taxonomy_check_vocabulary_hierarchy
(
$form
[
'#vocabulary'
],
$form_state
[
'values'
]);
drupal_set_message
(
t
(
'Deleted term %name.'
,
array
(
'%name'
=>
$form_state
[
'values'
][
'name'
])));
watchdog
(
'taxonomy'
,
'Deleted term %name.'
,
array
(
'%name'
=>
$form_state
[
'values'
][
'name'
]),
WATCHDOG_NOTICE
);
...
...
modules/taxonomy/taxonomy.module
View file @
585aa50e
...
...
@@ -765,8 +765,8 @@ function taxonomy_get_parents($tid, $key = 'tid') {
*/
function
taxonomy_get_parents_all
(
$tid
)
{
$parents
=
array
();
if
(
$tid
)
{
$parents
[]
=
taxonomy_term_load
(
$tid
)
;
if
(
$term
=
taxonomy_term_load
(
$tid
)
)
{
$parents
[]
=
$term
;
$n
=
0
;
while
(
$parent
=
taxonomy_get_parents
(
$parents
[
$n
]
->
tid
))
{
$parents
=
array_merge
(
$parents
,
$parent
);
...
...
modules/taxonomy/taxonomy.test
View file @
585aa50e
...
...
@@ -390,9 +390,9 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
}
/**
* Save
and
edit a
term and assert that the name and description are correct
.
* Save
,
edit a
nd delete a term using the user interface
.
*/
function
testTerm
Edit
()
{
function
testTerm
Interface
()
{
$edit
=
array
(
'name'
=>
$this
->
randomName
(
12
),
'description'
=>
$this
->
randomName
(
100
),
...
...
@@ -431,6 +431,14 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
$this
->
drupalGet
(
'taxonomy/term/'
.
$term
[
0
]
->
tid
);
$this
->
assertText
(
$edit
[
'name'
],
t
(
'The randomly generated term name is present.'
));
$this
->
assertText
(
$edit
[
'description'
],
t
(
'The randomly generated term description is present.'
));
// Delete the term.
$this
->
drupalPost
(
'taxonomy/term/'
.
$term
[
0
]
->
tid
.
'/edit'
,
array
(),
t
(
'Delete'
));
$this
->
drupalPost
(
NULL
,
NULL
,
t
(
'Delete'
));
// Assert that the term no longer exists.
$this
->
drupalGet
(
'taxonomy/term/'
.
$term
[
0
]
->
tid
);
$this
->
assertResponse
(
404
,
t
(
'The taxonomy term page was not found'
));
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment