Build/Test Tools: Begin eliminating unnecessary randomness in tests.
Although unlikely, clashes in randomly generated strings could cause unexpected failures. In addition, most randomness is entirely unnecessary, is bad practice, and increases test time (however small it may be). See #37371 git-svn-id: https://develop.svn.wordpress.org/trunk@38762 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b45f2feada
commit
c91be6f1fe
@ -84,7 +84,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
|
||||
function test_unique_filename_is_valid() {
|
||||
// make sure it produces a valid, writable, unique filename
|
||||
$filename = wp_unique_filename( $this->dir, rand_str() . '.txt' );
|
||||
$filename = wp_unique_filename( $this->dir, __FUNCTION__ . '.txt' );
|
||||
|
||||
$this->assertTrue( $this->is_unique_writable_file($this->dir, $filename) );
|
||||
|
||||
@ -93,7 +93,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
|
||||
function test_unique_filename_is_unique() {
|
||||
// make sure it produces two unique filenames
|
||||
$name = rand_str();
|
||||
$name = __FUNCTION__;
|
||||
|
||||
$filename1 = wp_unique_filename( $this->dir, $name . '.txt' );
|
||||
$this->assertTrue( $this->is_unique_writable_file($this->dir, $filename1) );
|
||||
@ -108,7 +108,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_unique_filename_is_sanitized() {
|
||||
$name = rand_str();
|
||||
$name = __FUNCTION__;
|
||||
$filename = wp_unique_filename( $this->dir, $name . $this->badchars . '.txt' );
|
||||
|
||||
// make sure the bad characters were all stripped out
|
||||
@ -120,7 +120,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_unique_filename_with_slashes() {
|
||||
$name = rand_str();
|
||||
$name = __FUNCTION__;
|
||||
// "foo/foo.txt"
|
||||
$filename = wp_unique_filename( $this->dir, $name . '/' . $name . '.txt' );
|
||||
|
||||
@ -133,7 +133,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_unique_filename_multiple_ext() {
|
||||
$name = rand_str();
|
||||
$name = __FUNCTION__;
|
||||
$filename = wp_unique_filename( $this->dir, $name . '.php.txt' );
|
||||
|
||||
// "foo.php.txt" becomes "foo.php_.txt"
|
||||
@ -145,7 +145,7 @@ class Tests_File extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_unique_filename_no_ext() {
|
||||
$name = rand_str();
|
||||
$name = __FUNCTION__;
|
||||
$filename = wp_unique_filename( $this->dir, $name );
|
||||
|
||||
$this->assertEquals( $name, $filename );
|
||||
|
@ -9,8 +9,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
function test_simple_filter() {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
add_filter($tag, array($a, 'filter'));
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
@ -27,8 +27,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
function test_remove_filter() {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
add_filter($tag, array($a, 'filter'));
|
||||
$this->assertEquals($val, apply_filters($tag, $val));
|
||||
@ -46,8 +46,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_has_filter() {
|
||||
$tag = rand_str();
|
||||
$func = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$func = __FUNCTION__ . '_func';
|
||||
|
||||
$this->assertFalse( has_filter($tag, $func) );
|
||||
$this->assertFalse( has_filter($tag) );
|
||||
@ -63,8 +63,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
function test_multiple_filters() {
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
// add both filters to the hook
|
||||
add_filter($tag, array($a1, 'filter'));
|
||||
@ -79,9 +79,9 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
function test_filter_args_1() {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$arg1 = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
$arg1 = __FUNCTION__ . '_arg1';
|
||||
|
||||
add_filter($tag, array($a, 'filter'), 10, 2);
|
||||
// call the filter with a single argument
|
||||
@ -95,10 +95,10 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
function test_filter_args_2() {
|
||||
$a1 = new MockAction();
|
||||
$a2 = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$arg1 = rand_str();
|
||||
$arg2 = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
$arg1 = __FUNCTION__ . '_arg1';
|
||||
$arg2 = __FUNCTION__ . '_arg2';
|
||||
|
||||
// a1 accepts two arguments, a2 doesn't
|
||||
add_filter($tag, array($a1, 'filter'), 10, 3);
|
||||
@ -119,8 +119,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
function test_filter_priority() {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
// make two filters with different priorities
|
||||
add_filter($tag, array($a, 'filter'), 10);
|
||||
@ -150,9 +150,9 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
function test_all_filter() {
|
||||
$a = new MockAction();
|
||||
$tag1 = rand_str();
|
||||
$tag2 = rand_str();
|
||||
$val = rand_str();
|
||||
$tag1 = __FUNCTION__ . '_1';
|
||||
$tag2 = __FUNCTION__ . '_2';
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
// add an 'all' filter
|
||||
add_filter('all', array($a, 'filterall'));
|
||||
@ -174,8 +174,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
|
||||
function test_remove_all_filter() {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
add_filter('all', array($a, 'filterall'));
|
||||
$this->assertTrue( has_filter('all') );
|
||||
@ -201,8 +201,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_remove_all_filters_should_respect_the_priority_argument() {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
add_filter( $tag, array( $a, 'filter' ), 12 );
|
||||
$this->assertTrue( has_filter( $tag ) );
|
||||
@ -221,7 +221,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
function test_filter_ref_array() {
|
||||
$obj = new stdClass();
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
add_action($tag, array($a, 'filter'));
|
||||
|
||||
@ -241,7 +241,7 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
$obj = new stdClass();
|
||||
$a = new MockAction();
|
||||
$b = new MockAction();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
add_action($tag, array($a, 'filter_append'), 10, 2);
|
||||
add_action($tag, array($b, 'filter_append'), 10, 2);
|
||||
@ -274,8 +274,8 @@ class Tests_Filters extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_has_filter_after_remove_all_filters() {
|
||||
$a = new MockAction();
|
||||
$tag = rand_str();
|
||||
$val = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$val = __FUNCTION__ . '_val';
|
||||
|
||||
// No priority
|
||||
add_filter( $tag, array( $a, 'filter' ), 11 );
|
||||
|
@ -28,7 +28,6 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase {
|
||||
$this->post_id = $this->factory->post->create( array(
|
||||
'post_author' => $this->author_id,
|
||||
'post_status' => 'publish',
|
||||
'post_content' => rand_str(),
|
||||
'post_title' => 'test_title',
|
||||
'post_type' => 'post',
|
||||
'post_date' => '2015-09-22 18:52:17',
|
||||
|
@ -13,7 +13,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
public function test_add_filter_with_function() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -28,7 +28,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$callback = array( $a, 'action' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -42,7 +42,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
public function test_add_filter_with_static_method() {
|
||||
$callback = array( 'MockAction', 'action' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -57,7 +57,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
$callback_one = '__return_null';
|
||||
$callback_two = '__return_false';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -72,7 +72,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
$callback_one = '__return_null';
|
||||
$callback_two = '__return_false';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -87,7 +87,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
public function test_readd_filter() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -101,7 +101,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
public function test_readd_filter_with_different_priority() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -118,7 +118,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase {
|
||||
$b = new MockAction();
|
||||
$c = new MockAction();
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
$hook->add_filter( $tag, array( $a, 'action' ), 10, 1 );
|
||||
$hook->add_filter( $tag, array( $b, 'action' ), 5, 1 );
|
||||
|
@ -11,10 +11,10 @@ class Tests_WP_Hook_Apply_Filters extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$callback = array( $a, 'filter' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
|
||||
@ -28,10 +28,10 @@ class Tests_WP_Hook_Apply_Filters extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$callback = array( $a, 'filter' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
|
||||
|
@ -19,10 +19,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$callback = array( $a, 'action' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->do_action( array( $arg ) );
|
||||
@ -34,10 +34,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$callback = array( $a, 'filter' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->do_action( array( $arg ) );
|
||||
@ -52,10 +52,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
|
||||
$callback_one = array( $a, 'filter' );
|
||||
$callback_two = array( $b, 'filter' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
|
||||
$hook->add_filter( $tag, $callback_two, $priority, $accepted_args );
|
||||
@ -71,10 +71,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
|
||||
$callback_one = array( $a, 'filter' );
|
||||
$callback_two = array( $b, 'filter' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
|
||||
$hook->add_filter( $tag, $callback_two, $priority, $accepted_args );
|
||||
@ -87,10 +87,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
|
||||
public function test_do_action_with_no_accepted_args() {
|
||||
$callback = array( $this, '_action_callback' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = 0;
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->do_action( array( $arg ) );
|
||||
@ -101,10 +101,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
|
||||
public function test_do_action_with_one_accepted_arg() {
|
||||
$callback = array( $this, '_action_callback' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = 1;
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->do_action( array( $arg ) );
|
||||
@ -115,10 +115,10 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase {
|
||||
public function test_do_action_with_more_accepted_args() {
|
||||
$callback = array( $this, '_action_callback' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = 1000;
|
||||
$arg = rand_str();
|
||||
$arg = __FUNCTION__ . '_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->do_action( array( $arg ) );
|
||||
|
@ -14,7 +14,7 @@ class Tests_WP_Hook_Do_All_Hook extends WP_UnitTestCase {
|
||||
$tag = 'all';
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
$arg = rand_str();
|
||||
$arg = 'all_arg';
|
||||
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$args = array( $arg );
|
||||
|
@ -10,7 +10,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase {
|
||||
public function test_has_filter_with_function() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -23,7 +23,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$callback = array( $a, 'action' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -35,7 +35,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase {
|
||||
public function test_has_filter_with_static_method() {
|
||||
$callback = array( 'MockAction', 'action' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -47,7 +47,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase {
|
||||
public function test_has_filter_without_callback() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -64,7 +64,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase {
|
||||
public function test_not_has_filter_with_callback() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
|
||||
$this->assertFalse( $hook->has_filter( $tag, $callback ) );
|
||||
}
|
||||
@ -72,7 +72,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase {
|
||||
public function test_has_filter_with_wrong_callback() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
|
@ -10,7 +10,7 @@ class Tests_WP_Hook_Has_Filters extends WP_UnitTestCase {
|
||||
public function test_has_filters_with_callback() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -27,7 +27,7 @@ class Tests_WP_Hook_Has_Filters extends WP_UnitTestCase {
|
||||
public function test_not_has_filters_with_removed_callback() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -39,7 +39,7 @@ class Tests_WP_Hook_Has_Filters extends WP_UnitTestCase {
|
||||
public function test_not_has_filter_with_directly_removed_callback() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
|
@ -11,7 +11,7 @@ class Tests_WP_Hook_Iterator extends WP_UnitTestCase {
|
||||
$callback_one = '__return_null';
|
||||
$callback_two = '__return_false';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
class Tests_WP_Hook_Preinit_Hooks extends WP_UnitTestCase {
|
||||
|
||||
public function test_array_to_hooks() {
|
||||
$tag1 = rand_str();
|
||||
$tag1 = __FUNCTION__ . '_1';
|
||||
$priority1 = rand( 1, 100 );
|
||||
$tag2 = rand_str();
|
||||
$tag2 = __FUNCTION__ . '_2';
|
||||
$priority2 = rand( 1, 100 );
|
||||
$filters = array(
|
||||
$tag1 => array(
|
||||
|
@ -10,7 +10,7 @@ class Tests_WP_Hook_Remove_All_Filters extends WP_UnitTestCase {
|
||||
public function test_remove_all_filters() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -25,7 +25,7 @@ class Tests_WP_Hook_Remove_All_Filters extends WP_UnitTestCase {
|
||||
$callback_one = '__return_null';
|
||||
$callback_two = '__return_false';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
|
@ -10,7 +10,7 @@ class Tests_WP_Hook_Remove_Filter extends WP_UnitTestCase {
|
||||
public function test_remove_filter_with_function() {
|
||||
$callback = '__return_null';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -24,7 +24,7 @@ class Tests_WP_Hook_Remove_Filter extends WP_UnitTestCase {
|
||||
$a = new MockAction();
|
||||
$callback = array( $a, 'action' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -37,7 +37,7 @@ class Tests_WP_Hook_Remove_Filter extends WP_UnitTestCase {
|
||||
public function test_remove_filter_with_static_method() {
|
||||
$callback = array( 'MockAction', 'action' );
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -51,7 +51,7 @@ class Tests_WP_Hook_Remove_Filter extends WP_UnitTestCase {
|
||||
$callback_one = '__return_null';
|
||||
$callback_two = '__return_false';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
@ -67,7 +67,7 @@ class Tests_WP_Hook_Remove_Filter extends WP_UnitTestCase {
|
||||
$callback_one = '__return_null';
|
||||
$callback_two = '__return_false';
|
||||
$hook = new WP_Hook();
|
||||
$tag = rand_str();
|
||||
$tag = __FUNCTION__;
|
||||
$priority = rand( 1, 100 );
|
||||
$accepted_args = rand( 1, 100 );
|
||||
|
||||
|
@ -306,7 +306,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
|
||||
$file = wp_crop_image( 'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
|
||||
0, 0, 100, 100, 100, 100, false,
|
||||
DIR_TESTDATA . '/images/' . rand_str() . '.jpg' );
|
||||
DIR_TESTDATA . '/images/' . __FUNCTION__ . '.jpg' );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $file );
|
||||
$this->assertFileExists( $file );
|
||||
$image = wp_get_image_editor( $file );
|
||||
|
@ -52,7 +52,7 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_get_preview_post_link_should_return_empty_string_for_non_viewable_post_type() {
|
||||
$post_type = register_post_type( rand_str(12), array(
|
||||
$post_type = register_post_type( 'non_viewable_cpt', array(
|
||||
'public' => false,
|
||||
) );
|
||||
|
||||
|
@ -161,7 +161,7 @@ class Tests_Meta extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_metadata_slashes() {
|
||||
$key = rand_str();
|
||||
$key = __FUNCTION__;
|
||||
$value = 'Test\\singleslash';
|
||||
$expected = 'Testsingleslash';
|
||||
$value2 = 'Test\\\\doubleslash';
|
||||
|
@ -35,8 +35,8 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Upload a file to the new site.
|
||||
$filename = rand_str().'.jpg';
|
||||
$contents = rand_str();
|
||||
$filename = __FUNCTION__ . '.jpg';
|
||||
$contents = __FUNCTION__ . '_contents';
|
||||
$file = wp_upload_bits( $filename, null, $contents );
|
||||
|
||||
// get_space_used() is measures in MB, get the size of the new file in MB.
|
||||
@ -71,8 +71,8 @@ class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Upload a file to the new site.
|
||||
$filename = rand_str().'.jpg';
|
||||
$contents = rand_str();
|
||||
$filename = __FUNCTION__ . '.jpg';
|
||||
$contents = __FUNCTION__ . '_contents';
|
||||
wp_upload_bits( $filename, null, $contents );
|
||||
|
||||
restore_current_blog();
|
||||
|
@ -61,8 +61,8 @@ class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase {
|
||||
* should change with upload directories.
|
||||
*/
|
||||
function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files() {
|
||||
$filename = rand_str().'.jpg';
|
||||
$contents = rand_str();
|
||||
$filename = __FUNCTION__ . '.jpg';
|
||||
$contents = __FUNCTION__ . '_contents';
|
||||
|
||||
// Upload a file to the main site on the network.
|
||||
$file1 = wp_upload_bits( $filename, null, $contents );
|
||||
|
@ -270,8 +270,8 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
|
||||
* should change with upload directories.
|
||||
*/
|
||||
function test_upload_directories_after_multiple_wpmu_delete_blog() {
|
||||
$filename = rand_str().'.jpg';
|
||||
$contents = rand_str();
|
||||
$filename = __FUNCTION__ . '.jpg';
|
||||
$contents = __FUNCTION__ . '_contents';
|
||||
|
||||
// Upload a file to the main site on the network.
|
||||
$file1 = wp_upload_bits( $filename, null, $contents );
|
||||
|
@ -64,7 +64,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_wp_embed_register_handler() {
|
||||
$handle = rand_str();
|
||||
$handle = __FUNCTION__;
|
||||
$regex = '#https?://example\.com/embed/([^/]+)#i';
|
||||
$callback = array( $this, '_embed_handler_callback' );
|
||||
|
||||
@ -102,7 +102,7 @@ class Tests_WP_Embed extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_autoembed_should_return_modified_content() {
|
||||
$handle = rand_str();
|
||||
$handle = __FUNCTION__;
|
||||
$regex = '#https?://example\.com/embed/([^/]+)#i';
|
||||
$callback = array( $this, '_embed_handler_callback' );
|
||||
|
||||
|
@ -25,10 +25,10 @@ class Tests_Multisite_Option extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_from_same_site() {
|
||||
$key = rand_str();
|
||||
$key2 = rand_str();
|
||||
$value = rand_str();
|
||||
$value2 = rand_str();
|
||||
$key = __FUNCTION__ . '_1';
|
||||
$key2 = __FUNCTION__ . '_2';
|
||||
$value = __FUNCTION__ . '_val1';
|
||||
$value2 = __FUNCTION__ . '_val2';
|
||||
|
||||
$this->assertFalse( get_blog_option( 1, 'doesnotexist' ) );
|
||||
$this->assertFalse( get_option( 'doesnotexist' ) ); // check get_option()
|
||||
@ -62,10 +62,10 @@ class Tests_Multisite_Option extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_from_same_site_with_null_blog_id() {
|
||||
$key = rand_str();
|
||||
$key2 = rand_str();
|
||||
$value = rand_str();
|
||||
$value2 = rand_str();
|
||||
$key = __FUNCTION__ . '_1';
|
||||
$key2 = __FUNCTION__ . '_2';
|
||||
$value = __FUNCTION__ . '_val1';
|
||||
$value2 = __FUNCTION__ . '_val2';
|
||||
|
||||
$this->assertFalse( get_blog_option( null, 'doesnotexist' ) );
|
||||
$this->assertFalse( get_option( 'doesnotexist' ) ); // check get_option()
|
||||
@ -109,10 +109,10 @@ class Tests_Multisite_Option extends WP_UnitTestCase {
|
||||
) );
|
||||
$this->assertInternalType( 'integer', $blog_id );
|
||||
|
||||
$key = rand_str();
|
||||
$key2 = rand_str();
|
||||
$value = rand_str();
|
||||
$value2 = rand_str();
|
||||
$key = __FUNCTION__ . '_key1';
|
||||
$key2 = __FUNCTION__ . '_key2';
|
||||
$value = __FUNCTION__ . '_val1';
|
||||
$value2 = __FUNCTION__ . '_val2';
|
||||
|
||||
$this->assertFalse( get_blog_option( $blog_id, 'doesnotexist' ) );
|
||||
//$this->assertFalse( get_option( 'doesnotexist' ) ); // check get_option()
|
||||
|
Loading…
x
Reference in New Issue
Block a user