Opened 9 months ago
Closed 8 months ago
#125 closed enhancement (fixed)
Test for Core Trac #5809
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Taxonomy | Keywords: | has-patch |
| Cc: |
Description
Tests setting a term in 2 taxonomies, changing the name of one, and ending up with 2 terms - rather than changing both
Attachments (1)
Change History (10)
wonderboymusic — 9 months ago
comment:2
wonderboymusic — 9 months ago
Without my patch applied, the first test should pass and the second test should fail.
With my patch applied, both tests should pass.
As is stands now, term_taxonomy_id is the primary key for term_id/taxonomy relationship, so since we create the term in the first insert, the second will reuse it. When the term is updated, WP currently changes the name of both terms because it doesn't care that the term_id is in multiple taxonomies (FAIL) - my patch makes a new term so the term_ids shouldn't match in the second assertion.
Replying to tomauger:
Isn't that the point of the ticket - that inserting two terms (one a category, the other a tag) with the same name should have different IDs?
No, the point of the ticket is in it's (current) title: "Updating a term in one taxonomy affects the term in every taxonomy"
So, the patch looks good. I'd commit it, but I'm unclear on the policy:
Is it ok to commit unit tests which are correct, but that will fail until an existing patch is applied to Core?
It should also be tested that the terms still reference the same posts as before the update.

Nice!
I'm pretty unfamiliar with unit tests, but doesn't it seem like the first test:
$this->assertEquals( $t1['term_id'], $t2['term_id'] );
ought to fail? Isn't that the point of the ticket - that inserting two terms (one a category, the other a tag) with the same name should have different IDs?
The second test seems good to me, though I think I would have gone about it differently - after updating the second term, lookup the first term again and see if it's name has changed (rather than comparing the IDs). I'm not suggesting you change the second test, but consider adding a third?