diff --git a/tests/phpunit/tests/functions/wpNonceField.php b/tests/phpunit/tests/functions/wpNonceField.php new file mode 100644 index 0000000000..ec2c68727d --- /dev/null +++ b/tests/phpunit/tests/functions/wpNonceField.php @@ -0,0 +1,77 @@ +expectOutputRegex( '#^$#' ); + } + + /** + * @ticket 55578 + * + * @dataProvider data_wp_nonce_field + * + * @param int|string $action Action name. + * @param string $name Nonce name. + * @param bool $referer Whether to set the referer field fior validation. + * @param string $expected_reg_exp The expected regular expression. + */ + public function test_wp_nonce_field_return( $action, $name, $referer, $expected_reg_exp ) { + + $this->assertMatchesRegularExpression( $expected_reg_exp, wp_nonce_field( $action, $name, $referer, false ) ); + } + + /** + * Data provider. + * + * @return array + */ + public function data_wp_nonce_field() { + + return array( + 'default' => array( + 'action' => - 1, + 'name' => '_wpnonce', + 'referer' => true, + 'expected_reg_exp' => '#^$#', + ), + 'nonce_name' => array( + 'action' => - 1, + 'name' => 'nonce_name', + 'referer' => true, + 'expected_reg_exp' => '#^$#', + ), + 'action_name' => array( + 'action' => 'action_name', + 'name' => '_wpnonce', + 'referer' => true, + 'expected_reg_exp' => '#^$#', + ), + 'no_referer' => array( + 'action' => - 1, + 'name' => '_wpnonce', + 'referer' => false, + 'expected_reg_exp' => '#^$#', + ), + '& in name' => array( + 'action' => - 1, + 'name' => 'a&b', + 'referer' => false, + 'expected_reg_exp' => '#^$#', + ), + ); + } +} diff --git a/tests/phpunit/tests/functions/wpRefererField.php b/tests/phpunit/tests/functions/wpRefererField.php new file mode 100644 index 0000000000..d0642f4088 --- /dev/null +++ b/tests/phpunit/tests/functions/wpRefererField.php @@ -0,0 +1,32 @@ +expectOutputString( '' ); + } + + /** + * @ticket 55578 + */ + public function test_wp_referer_field_return() { + + $_SERVER['REQUEST_URI'] = '/test/'; + + $this->assertSame( '', wp_referer_field( false ) ); + } +}