Problem/Motivation
taxonomy_term_save() used to accept an array of arrays of Term IDs for $term->parent, but, as stated by @Berdir in #9, support was removed in the taxonomy entity class conversion patch, but there aren't any tests. We should write tests.
See the Change Record Entities are now classed objects using a defined interface for more information about what happened to taxonomy_term_save().
Proposed resolution
Write tests if they do not exist already.
Remaining tasks
- Determine if there are already tests to cover this
- If not, write them
User interface changes
None.
API changes
None.
Original report by @mr.baileys
While working on #1162226: taxonomy_term_save should document what is in a $term object, I noticed that taxonomy_term_save() currently supports the following values for $term->parent:
- A single tid
- An array of tids
- An array of arrays of tids
I briefly talked to catch on IRC and couldn't really figure out why we should accept an array of arrays of tids. The tests run fine just supporting 1. and 2., and so does devel generate-terms.
My guess is that this is a left-over from how taxonomy_save_terms() used to be fed input straight form the form API (see #17955: Remove use of form_item() in taxonomy where this array of arrays support was introduced), so I suggest removing it.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 1175156-4-taxonomy.patch | 868 bytes | cosmicdreams |
| 0001-Remove-support-for-nested-arrays-for-term-parent-fro.patch | 1.19 KB | mr.baileys |
Comments
Comment #1
catchSubscribing, this should work fine with multiple parents since that's what the overall foreach is for, but I'd like to double check we have tests for assigning multiple parents before marking RTBC.
Comment #2
kscheirer0001-Remove-support-for-nested-arrays-for-term-parent-fro.patch queued for re-testing.
Comment #4
xjmTagging novice to reroll against current 8.x. Thanks!
Comment #5
cosmicdreams commentedrerolled
Comment #6
cosmicdreams commentedsetting to review so test bot can test
Comment #7
berdir#5: 1175156-4-taxonomy.patch queued for re-testing.
Comment #9
berdirWe actually removed support for that in the taxonomy entity class conversion patch, see http://api.drupal.org/api/drupal/core%21modules%21taxonomy%21taxonomy.en....
Not sure if we want to close this as a duplicate or change to a task to add tests...
Comment #10
dags commentedComment #11
dags commentedComment #12
mparker17Adding tests sounds like a good idea: marking as "Needs issue summary update".
I want to learn how to write automated tests: assigning to myself.
Comment #13
mparker17Updated issue summary.
Comment #14
mparker17Adding notes.
Comment #15
mparker17Based on @lauriii's suggestion in IRC, this issue may not be relevant anymore, so I'm going to skip it for now.
Here's some code that might work in a test class that extends
\Drupal\taxonomy\Tests\TaxonomyTestBase:Comment #16
dcam commentedRemoving the Novice tag in prep for the DrupalCon Austin sprints. Both tags were already removed in #7, but Testbot added them back in.
Comment #25
catch