Add test for get_term_by( 'slug' ) behavior with accented chars.

When passing a value of 'slug' to `wp_insert_term()` that contains non-ASCII
characters, WordPress converts accented characters to non-accented versions.
(See `sanitize_title()` and `remove_accents()`.) The same conversion happens
when fetching when fetching a term using a slug. In this way, it's possible to
create a term and fetch it using the same accented string, even though the slug
is actually stored with non-accented characters.

See #16282.

git-svn-id: https://develop.svn.wordpress.org/trunk@34628 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2015-09-27 16:31:47 +00:00
parent 148d6a37fe
commit eb6430708b

View File

@ -20,4 +20,20 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase {
$term = get_term_by( 'id', 123456, 'category' );
$this->assertFalse( $term );
}
/**
* @ticket 16282
*/
public function test_get_term_by_slug_should_match_nonaccented_equivalents() {
register_taxonomy( 'wptests_tax', 'post' );
$slug = 'ńaș';
$t = $this->factory->term->create( array(
'slug' => $slug,
'taxonomy' => 'wptests_tax',
) );
$found = get_term_by( 'slug', 'nas', 'wptests_tax' );
$this->assertSame( $t, $found->term_id );
}
}