From 067b1a104c575db54fa72f2b870a391c3f022429 Mon Sep 17 00:00:00 2001 From: pbearne Date: Thu, 20 Jan 2022 19:49:31 -0500 Subject: [PATCH 1/2] test for wp_nonce_url --- .../phpunit/tests/functions/wp_nonce_url.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/phpunit/tests/functions/wp_nonce_url.php diff --git a/tests/phpunit/tests/functions/wp_nonce_url.php b/tests/phpunit/tests/functions/wp_nonce_url.php new file mode 100644 index 0000000000000..61db42e0a19ab --- /dev/null +++ b/tests/phpunit/tests/functions/wp_nonce_url.php @@ -0,0 +1,52 @@ +assertMatchesRegularExpression( $expected, wp_nonce_url( $actionurl, $action, $name ) ); + } + + public function data_wp_nonce_url() { + return array( + array( + 'expected' => '/^http:\/\/example\.org\/\?_wpnonce=.{10}$/', + 'actionurl' => 'http://example.org/', + 'action' => '12345', + 'name' => '_wpnonce', + ), + array( + 'expected' => '/^https:\/\/example\.org\/\?my_nonce=.{10}$/', + 'actionurl' => 'https://example.org/', + 'action' => '12345', + 'name' => 'my_nonce', + ), + array( + 'expected' => '/\/\?_wpnonce=.{10}$/', + 'actionurl' => '/', + 'action' => '12345', + 'name' => '_wpnonce', + ), + array( + 'expected' => '/\?_wpnonce=.{10}$/', + 'actionurl' => '/', + ), + ); + } +} From 5c279d62b33197e1141f6d61446ee0d257c035fe Mon Sep 17 00:00:00 2001 From: pbearne Date: Thu, 20 Jan 2022 19:53:45 -0500 Subject: [PATCH 2/2] white space --- tests/phpunit/tests/functions/wp_nonce_url.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wp_nonce_url.php b/tests/phpunit/tests/functions/wp_nonce_url.php index 61db42e0a19ab..fc474781fc902 100644 --- a/tests/phpunit/tests/functions/wp_nonce_url.php +++ b/tests/phpunit/tests/functions/wp_nonce_url.php @@ -18,7 +18,7 @@ class Tests_Functions_wp_nonce_url extends WP_UnitTestCase { * * @return void */ - public function test_wp_nonce_url( $expected, $actionurl, $action = -1, $name = '_wpnonce' ) { + public function test_wp_nonce_url( $expected, $actionurl, $action = -1, $name = '_wpnonce' ) { $this->assertMatchesRegularExpression( $expected, wp_nonce_url( $actionurl, $action, $name ) ); }