Improvements to encoded character formatting tests.

In `sanitize_title_with_dashes()` and `sanitize_user()` tests, we break large
test methods into smaller ones in order to isolate those that actually describe
the bug being reported in ticket #10823. The unit tests that are continuing to
fail have been attached as a patch to that ticket.

See #30284.

git-svn-id: https://develop.svn.wordpress.org/trunk@30515 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2014-11-22 19:53:37 +00:00
parent 3818c645c3
commit 73ef6bd6fc
2 changed files with 23 additions and 12 deletions

View File

@ -35,18 +35,28 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase {
$this->assertEquals("penn-teller-bull", sanitize_title_with_dashes("penn & teller bull"));
}
/**
* @ticket 10823
*/
function test_strips_entities() {
public function test_strips_nbsp_ndash_and_amp() {
$this->assertEquals("no-entities-here", sanitize_title_with_dashes("No   Entities – Here &"));
}
public function test_strips_encoded_ampersand() {
$this->assertEquals("one-two", sanitize_title_with_dashes("One & Two", '', 'save'));
}
public function test_strips_url_encoded_ampersand() {
$this->assertEquals("one-two", sanitize_title_with_dashes("One { Two;", '', 'save'));
$this->assertEquals("one-two", sanitize_title_with_dashes("One & Two;", '', 'save'));
}
public function test_strips_trademark_symbol() {
$this->assertEquals("one-two", sanitize_title_with_dashes("One Two™;", '', 'save'));
}
public function test_strips_unencoded_ampersand_followed_by_encoded_ampersand() {
$this->assertEquals("one-two", sanitize_title_with_dashes("One && Two;", '', 'save'));
}
public function test_strips_unencoded_ampersand_when_not_surrounded_by_spaces() {
$this->assertEquals("onetwo", sanitize_title_with_dashes("One&Two", '', 'save'));
$this->assertEquals("onetwo-test", sanitize_title_with_dashes("One&Two Test;", '', 'save'));
}
function test_replaces_nbsp() {

View File

@ -9,14 +9,15 @@ class Tests_Formatting_SanitizeUser extends WP_UnitTestCase {
$expected = is_multisite() ? 'captain awesome' : 'Captain Awesome';
$this->assertEquals($expected, sanitize_user($input));
}
/**
* @ticket 10823
*/
function test_strips_entities() {
public function test_strips_encoded_ampersand() {
$this->assertEquals("ATT", sanitize_user("AT&T"));
$this->assertEquals("ATT Test;", sanitize_user("AT&T Test;"));
$this->assertEquals("AT&T Test;", sanitize_user("AT&T Test;"));
}
public function test_strips_encoded_ampersand_when_followed_by_semicolon() {
$this->assertEquals("ATT Test;", sanitize_user("AT&T Test;"));
}
function test_strips_percent_encoded_octets() {
$expected = is_multisite() ? 'franois' : 'Franois';
$this->assertEquals( $expected, sanitize_user( "Fran%c3%a7ois" ) );