Fix tax name with % on the Thank You page #45103

This commit is contained in:
PavloBorysenko 2024-09-18 17:57:33 +02:00
parent 8dafe5f53b
commit e493ac9257
1 changed files with 26 additions and 21 deletions

View File

@ -16,35 +16,40 @@ class WC_Order_Item_Tax_Test extends WC_Unit_Test_Case {
* @return void
*/
public function setUp(): void {
$this->order_item_tax = new \WC_Order_Item_Tax();
$this->order_item_tax = new \WC_Order_Item_Tax();
parent::setUp();
}
/**
/**
* Test save label.
* @param string $label label to save.
* @param string $expected_label expected label.
* @testDox Test that the label is saved correctly
* @dataProvider data_provider_test_set_label
* @dataProvider data_provider_test_set_label
*/
public function test_set_label($label, $expected_label) {
$this->order_item_tax->set_label($label);
public function test_set_label( $label, $expected_label ) {
$this->order_item_tax->set_label( $label );
$actual_label = $this->order_item_tax->get_label();
$actual_label = $this->order_item_tax->get_label();
$this->assertSame($expected_label, $actual_label);
}
$this->assertSame( $expected_label, $actual_label );
}
public function data_provider_test_set_label() : array {
return array(
'empty' => array( '', __( 'Tax', 'woocommerce' ) ),
'simple string' => array( 'Test Tax', 'Test Tax' ),
'%text'=> array( 'Tax %15', 'Tax %15' ),
'% text'=> array( 'Tax % 15', 'Tax % 15' ),
'text%'=> array( 'Tax 15%', 'Tax 15%' ),
'text %'=> array( 'Tax 15 %', 'Tax 15 %' ),
'mix of special chars' => array( '<test> "Tax %15 %D0 \t' , '"Tax &#37;15 &#37;D0 \t'),
'non-latin characters' => array( '%מַס %Φόρος' , '&#37;מַס &#37;Φόρος'),
/**
* Data provider.
*/
public function data_provider_test_set_label(): array {
return array(
'empty' => array( '', __( 'Tax', 'woocommerce' ) ),
'simple string' => array( 'Test Tax', 'Test Tax' ),
'%text' => array( 'Tax %15', 'Tax &#37;15' ),
'% text' => array( 'Tax % 15', 'Tax &#37; 15' ),
'text%' => array( 'Tax 15%', 'Tax 15&#37;' ),
'text %' => array( 'Tax 15 %', 'Tax 15 &#37;' ),
'mix of special chars' => array( '<test> "Tax %15 %D0 \t', '"Tax &#37;15 &#37;D0 \t' ),
'non-latin characters' => array( '%מַס %Φόρος', '&#37;מַס &#37;Φόρος' ),
);
}
);
}
}