Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/phpunit/tests/term/wpInsertTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,19 @@ public function test_wp_insert_term_with_empty_name_after_db_sanitization() {
$this->assertSame( 'invalid_term_name', $term->get_error_code() );
}

/**
* @ticket 38243
*/
public function test_wp_insert_term_with_invalid_utf8_name_should_not_create_blank_term() {
$count_before = wp_count_terms( array( 'taxonomy' => 'post_tag' ) );

$term = wp_insert_term( urldecode( '360%BF' ), 'post_tag' );

$this->assertWPError( $term );
$this->assertSame( 'invalid_term_name', $term->get_error_code() );
$this->assertSame( $count_before, wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) );
}

/**
* @ticket 31270
*/
Expand Down
24 changes: 24 additions & 0 deletions tests/phpunit/tests/term/wpUpdateTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ public function test_wp_update_term_name_empty_string() {
_unregister_taxonomy( 'wptests_tax' );
}

/**
* @ticket 38243
*/
public function test_wp_update_term_with_invalid_utf8_name_should_return_wp_error() {
$t = self::factory()->term->create(
array(
'name' => 'Foo',
'taxonomy' => 'post_tag',
)
);

$found = wp_update_term(
$t,
'post_tag',
array(
'name' => urldecode( '360%BF' ),
)
);

$this->assertWPError( $found );
$this->assertSame( 'empty_term_name', $found->get_error_code() );
$this->assertSame( 'Foo', get_term( $t )->name );
}

/**
* @ticket 29614
*/
Expand Down
Loading