From eb6430708b85850bd2c9a5c0dccdc971f8a6f1ed Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sun, 27 Sep 2015 16:31:47 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/term/getTermBy.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/phpunit/tests/term/getTermBy.php b/tests/phpunit/tests/term/getTermBy.php index f5a2162d50..29a6bdc1aa 100644 --- a/tests/phpunit/tests/term/getTermBy.php +++ b/tests/phpunit/tests/term/getTermBy.php @@ -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 ); + } }