diff --git a/tests/phpunit/tests/functions/wpNonceField.php b/tests/phpunit/tests/functions/wpNonceField.php
index 2596402bb5..78116f01e5 100644
--- a/tests/phpunit/tests/functions/wpNonceField.php
+++ b/tests/phpunit/tests/functions/wpNonceField.php
@@ -15,7 +15,10 @@ class Tests_Functions_wpNonceField extends WP_UnitTestCase {
*/
public function test_wp_nonce_field() {
wp_nonce_field();
- $this->expectOutputRegex( '#^$#' );
+ $this->expectOutputRegex(
+ '#^' .
+ '$#'
+ );
}
/**
@@ -29,6 +32,11 @@ class Tests_Functions_wpNonceField extends WP_UnitTestCase {
* @param string $expected_regexp The expected regular expression.
*/
public function test_wp_nonce_field_return( $action, $name, $referer, $expected_regexp ) {
+ if ( -1 !== $action ) {
+ $nonce_value = wp_create_nonce( $action );
+ $expected_regexp = str_replace( '%%NONCE_VALUE%%', $nonce_value, $expected_regexp );
+ }
+
$this->assertMatchesRegularExpression( $expected_regexp, wp_nonce_field( $action, $name, $referer, false ) );
}
@@ -43,31 +51,39 @@ class Tests_Functions_wpNonceField extends WP_UnitTestCase {
'action' => -1,
'name' => '_wpnonce',
'referer' => true,
- 'expected_regexp' => '#^$#',
- ),
- 'nonce_name' => array(
- 'action' => -1,
- 'name' => 'nonce_name',
- 'referer' => true,
- 'expected_regexp' => '#^$#',
+ 'expected_regexp' =>
+ '#^' .
+ '$#',
),
'action_name' => array(
'action' => 'action_name',
'name' => '_wpnonce',
'referer' => true,
- 'expected_regexp' => '#^$#',
+ 'expected_regexp' =>
+ '#^' .
+ '$#',
+ ),
+ 'nonce_name' => array(
+ 'action' => -1,
+ 'name' => 'nonce_name',
+ 'referer' => true,
+ 'expected_regexp' =>
+ '#^' .
+ '$#',
),
'no_referer' => array(
'action' => -1,
'name' => '_wpnonce',
'referer' => false,
- 'expected_regexp' => '#^$#',
+ 'expected_regexp' =>
+ '#^$#',
),
'& in name' => array(
'action' => -1,
'name' => 'a&b',
'referer' => false,
- 'expected_regexp' => '#^$#',
+ 'expected_regexp' =>
+ '#^$#',
),
);
}