Add tests

This commit is contained in:
Mike Jolley 2019-04-03 11:58:15 +01:00
parent b1a811ca46
commit 7feae340f2
1 changed files with 27 additions and 0 deletions

View File

@ -115,4 +115,31 @@ class WC_Tests_Template_Functions extends WC_Unit_Test_Case {
unset( $_REQUEST['attribute_pa_size'] );
}
/**
* Test wc_query_string_form_fields.
*
* @return void
*/
public function test_wc_query_string_form_fields() {
$actual_html = wc_query_string_form_fields( '?test=1', array(), '', true );
$expected_html = '<input type="hidden" name="test" value="1" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test=1&test2=something', array(), '', true );
$expected_html = '<input type="hidden" name="test" value="1" /><input type="hidden" name="test2" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test.something=something', array(), '', true );
$expected_html = '<input type="hidden" name="test.something" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test+something=something', array(), '', true );
$expected_html = '<input type="hidden" name="test+something" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
$actual_html = wc_query_string_form_fields( '?test%20something=something', array(), '', true );
$expected_html = '<input type="hidden" name="test%20something" value="something" />';
$this->assertEquals( $expected_html, $actual_html, var_export( $actual_html, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
}
}