- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php
r41318 r42343 6 6 class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { 7 7 function test_strips_html() { 8 $input = "Captain <strong>Awesome</strong>";9 $expected = "captain-awesome";10 $this->assertEquals( $expected, sanitize_title($input));8 $input = 'Captain <strong>Awesome</strong>'; 9 $expected = 'captain-awesome'; 10 $this->assertEquals( $expected, sanitize_title( $input ) ); 11 11 } 12 12 13 13 function test_strips_unencoded_percent_signs() { 14 $this->assertEquals( "fran%c3%a7ois", sanitize_title_with_dashes("fran%c3%a7%ois"));14 $this->assertEquals( 'fran%c3%a7ois', sanitize_title_with_dashes( 'fran%c3%a7%ois' ) ); 15 15 } 16 16 17 17 function test_makes_title_lowercase() { 18 $this->assertEquals( "abc", sanitize_title_with_dashes("ABC"));18 $this->assertEquals( 'abc', sanitize_title_with_dashes( 'ABC' ) ); 19 19 } 20 20 21 21 function test_replaces_any_amount_of_whitespace_with_one_hyphen() { 22 $this->assertEquals( "a-t", sanitize_title_with_dashes("a t"));23 $this->assertEquals( "a-t", sanitize_title_with_dashes("a \n\n\nt"));22 $this->assertEquals( 'a-t', sanitize_title_with_dashes( 'a t' ) ); 23 $this->assertEquals( 'a-t', sanitize_title_with_dashes( "a \n\n\nt" ) ); 24 24 } 25 25 26 26 function test_replaces_any_number_of_hyphens_with_one_hyphen() { 27 $this->assertEquals( "a-t-t", sanitize_title_with_dashes("a----t----t"));27 $this->assertEquals( 'a-t-t', sanitize_title_with_dashes( 'a----t----t' ) ); 28 28 } 29 29 30 30 function test_trims_trailing_hyphens() { 31 $this->assertEquals( "a-t-t", sanitize_title_with_dashes("a----t----t----"));31 $this->assertEquals( 'a-t-t', sanitize_title_with_dashes( 'a----t----t----' ) ); 32 32 } 33 33 34 34 function test_handles_non_entity_ampersands() { 35 $this->assertEquals( "penn-teller-bull", sanitize_title_with_dashes("penn & teller bull"));35 $this->assertEquals( 'penn-teller-bull', sanitize_title_with_dashes( 'penn & teller bull' ) ); 36 36 } 37 37 38 38 public function test_strips_nbsp_ndash_and_amp() { 39 $this->assertEquals( "no-entities-here", sanitize_title_with_dashes("No Entities – Here &"));39 $this->assertEquals( 'no-entities-here', sanitize_title_with_dashes( 'No Entities – Here &' ) ); 40 40 } 41 41 42 42 public function test_strips_encoded_ampersand() { 43 $this->assertEquals( "one-two", sanitize_title_with_dashes("One & Two", '', 'save'));43 $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One & Two', '', 'save' ) ); 44 44 } 45 45 46 46 public function test_strips_url_encoded_ampersand() { 47 $this->assertEquals( "one-two", sanitize_title_with_dashes("One { Two;", '', 'save'));47 $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One { Two;', '', 'save' ) ); 48 48 } 49 49 50 50 public function test_strips_trademark_symbol() { 51 $this->assertEquals( "one-two", sanitize_title_with_dashes("One Two™;", '', 'save'));51 $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One Two™;', '', 'save' ) ); 52 52 } 53 53 54 54 public function test_strips_unencoded_ampersand_followed_by_encoded_ampersand() { 55 $this->assertEquals( "one-two", sanitize_title_with_dashes("One && Two;", '', 'save'));55 $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One && Two;', '', 'save' ) ); 56 56 } 57 57 58 58 public function test_strips_unencoded_ampersand_when_not_surrounded_by_spaces() { 59 $this->assertEquals( "onetwo", sanitize_title_with_dashes("One&Two", '', 'save'));59 $this->assertEquals( 'onetwo', sanitize_title_with_dashes( 'One&Two', '', 'save' ) ); 60 60 } 61 61 62 62 function test_replaces_nbsp() { 63 $this->assertEquals( "dont-break-the-space", sanitize_title_with_dashes("don't break the space", '', 'save'));63 $this->assertEquals( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); 64 64 } 65 65 … … 68 68 */ 69 69 function test_replaces_nbsp_entities() { 70 $this->assertEquals( "dont-break-the-space", sanitize_title_with_dashes("don't break the space", '', 'save'));70 $this->assertEquals( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); 71 71 } 72 72 73 73 function test_replaces_ndash_mdash() { 74 $this->assertEquals( "do-the-dash", sanitize_title_with_dashes("Do – the Dash", '', 'save'));75 $this->assertEquals( "do-the-dash", sanitize_title_with_dashes("Do the — Dash", '', 'save'));74 $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do – the Dash', '', 'save' ) ); 75 $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do the — Dash', '', 'save' ) ); 76 76 } 77 77 … … 80 80 */ 81 81 function test_replaces_ndash_mdash_entities() { 82 $this->assertEquals( "do-the-dash", sanitize_title_with_dashes("Do – the – Dash", '', 'save'));83 $this->assertEquals( "do-the-dash", sanitize_title_with_dashes("Do — the — Dash", '', 'save'));82 $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do – the – Dash', '', 'save' ) ); 83 $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do — the — Dash', '', 'save' ) ); 84 84 } 85 85 86 86 function test_replaces_iexcel_iquest() { 87 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("Just ¡a Slug", '', 'save'));88 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("Just a Slug¿", '', 'save'));87 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) ); 88 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) ); 89 89 } 90 90 91 91 function test_replaces_angle_quotes() { 92 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("‹Just a Slug›", '', 'save'));93 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("«Just a Slug»", '', 'save'));92 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( '‹Just a Slug›', '', 'save' ) ); 93 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( '«Just a Slug»', '', 'save' ) ); 94 94 } 95 95 96 96 function test_replaces_curly_quotes() { 97 $this->assertEquals( "hey-its-curly-joe", sanitize_title_with_dashes("Hey its “Curly Joe”", '', 'save'));98 $this->assertEquals( "hey-its-curly-joe", sanitize_title_with_dashes("Hey its ‘Curly Joe’", '', 'save'));99 $this->assertEquals( "hey-its-curly-joe", sanitize_title_with_dashes("Hey its „Curly Joe“", '', 'save'));100 $this->assertEquals( "hey-its-curly-joe", sanitize_title_with_dashes("Hey its ‚Curly Joe‛", '', 'save'));101 $this->assertEquals( "hey-its-curly-joe", sanitize_title_with_dashes("Hey its „Curly Joe‟", '', 'save'));97 $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its “Curly Joe”', '', 'save' ) ); 98 $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‘Curly Joe’', '', 'save' ) ); 99 $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its „Curly Joe“', '', 'save' ) ); 100 $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‚Curly Joe‛', '', 'save' ) ); 101 $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its „Curly Joe‟', '', 'save' ) ); 102 102 } 103 103 104 104 function test_replaces_copy_reg_deg_trade() { 105 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("Just © a Slug", '', 'save'));106 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("® Just a Slug", '', 'save'));107 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("Just a ° Slug", '', 'save'));108 $this->assertEquals( "just-a-slug", sanitize_title_with_dashes("Just ™ a Slug", '', 'save'));105 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just © a Slug', '', 'save' ) ); 106 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( '® Just a Slug', '', 'save' ) ); 107 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just a ° Slug', '', 'save' ) ); 108 $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just ™ a Slug', '', 'save' ) ); 109 109 } 110 110 … … 113 113 */ 114 114 function test_replaces_forward_slash() { 115 $this->assertEquals( "songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon/McCartney", '', 'save'));116 $this->assertEquals( "songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon//McCartney", '', 'save'));117 $this->assertEquals( "songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon///McCartney", '', 'save'));118 $this->assertEquals( "songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon/-McCartney", '', 'save'));119 $this->assertEquals( "songs-by-lennon-mccartney", sanitize_title_with_dashes("//songs by Lennon/McCartney", '', 'save'));115 $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/McCartney', '', 'save' ) ); 116 $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon//McCartney', '', 'save' ) ); 117 $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon///McCartney', '', 'save' ) ); 118 $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/-McCartney', '', 'save' ) ); 119 $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( '//songs by Lennon/McCartney', '', 'save' ) ); 120 120 } 121 121 … … 124 124 */ 125 125 function test_replaces_multiply_sign() { 126 $this->assertEquals( "6x7-is-42", sanitize_title_with_dashes("6×7 is 42", '', 'save'));126 $this->assertEquals( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) ); 127 127 } 128 128 … … 131 131 */ 132 132 function test_replaces_standalone_diacritic() { 133 $this->assertEquals( "aaaa", sanitize_title_with_dashes("āáǎà", '', 'save'));133 $this->assertEquals( 'aaaa', sanitize_title_with_dashes( 'āáǎà', '', 'save' ) ); 134 134 } 135 135 … … 138 138 */ 139 139 function test_replaces_acute_accents() { 140 $this->assertEquals( "aaaa", sanitize_title_with_dashes("ááa´aˊ", '', 'save'));140 $this->assertEquals( 'aaaa', sanitize_title_with_dashes( 'ááa´aˊ', '', 'save' ) ); 141 141 } 142 142
Note: See TracChangeset
for help on using the changeset viewer.