Skip to content

Commit f8eee6d

Browse files
Tests: Test multiplication sign handling in sanitize_title_with_dashes
1 parent 1cf070e commit f8eee6d

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,39 @@ public function test_replaces_forward_slash() {
146146
* @ticket 19820
147147
*/
148148
public function test_replaces_multiply_sign() {
149-
$this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) );
149+
$this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ), 'Multiplication sign (×) should be replaced with letter x' );
150+
}
151+
152+
/**
153+
* @ticket 64284
154+
*/
155+
public function test_replaces_multiply_sign_with_spaces() {
156+
$this->assertSame( 'iphone-12-x-256gb', sanitize_title_with_dashes( 'iPhone 12 × 256GB', '', 'save' ), 'Product title with multiplication sign and spaces should convert × to x' );
157+
$this->assertSame( 'screen-1920-x-1080', sanitize_title_with_dashes( 'Screen 1920 × 1080', '', 'save' ), 'Screen dimensions with multiplication sign should convert × to x' );
158+
}
159+
160+
/**
161+
* @ticket 64284
162+
*/
163+
public function test_replaces_times_html_entity() {
164+
$this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ), 'HTML entity × should be replaced with letter x' );
165+
$this->assertSame( 'product-5x10', sanitize_title_with_dashes( 'Product 5×10', '', 'save' ), 'HTML entity × without spaces should be replaced with letter x' );
166+
}
167+
168+
/**
169+
* @ticket 64284
170+
*/
171+
public function test_replaces_times_numeric_entity() {
172+
$this->assertSame( '3x4-equals-12', sanitize_title_with_dashes( '3×4 equals 12', '', 'save' ), 'Numeric HTML entity × should be replaced with letter x' );
173+
}
174+
175+
/**
176+
* @ticket 64284
177+
*/
178+
public function test_replaces_multiply_sign_in_display_context() {
179+
// Should work in display context too, not just 'save'.
180+
$this->assertSame( '6x7', sanitize_title_with_dashes( '6×7', '', 'display' ), 'Multiplication sign should be replaced with x in display context' );
181+
$this->assertSame( 'testx', sanitize_title_with_dashes( 'test×', '' ), 'Multiplication sign should be replaced with x when context is not specified' );
150182
}
151183

152184
/**

0 commit comments

Comments
 (0)