Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/phpunit/tests/functions/wp_nonce_url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* @group functions.php
*
* @covers ::wp_nonce_url
*/
class Tests_Functions_wp_nonce_url extends WP_UnitTestCase {


/**
* @dataProvider data_wp_nonce_url
*
* @param $expected
* @param $action
* @param $url
* @param $name
*
* @return void
*/
public function test_wp_nonce_url( $expected, $actionurl, $action = -1, $name = '_wpnonce' ) {

$this->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' => '/',
),
);
}
}