diff --git a/tests/phpunit/tests/file.php b/tests/phpunit/tests/file.php index 8ee3e8de20..3aad09e109 100644 --- a/tests/phpunit/tests/file.php +++ b/tests/phpunit/tests/file.php @@ -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 ); diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php index d2e6ddf0d0..fddcf4aade 100644 --- a/tests/phpunit/tests/filters.php +++ b/tests/phpunit/tests/filters.php @@ -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 ); diff --git a/tests/phpunit/tests/general/document-title.php b/tests/phpunit/tests/general/document-title.php index 0e5d282a40..7ba319666a 100644 --- a/tests/phpunit/tests/general/document-title.php +++ b/tests/phpunit/tests/general/document-title.php @@ -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', diff --git a/tests/phpunit/tests/hooks/add_filter.php b/tests/phpunit/tests/hooks/add_filter.php index 35ac55e7bc..79aeb755d6 100755 --- a/tests/phpunit/tests/hooks/add_filter.php +++ b/tests/phpunit/tests/hooks/add_filter.php @@ -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 ); diff --git a/tests/phpunit/tests/hooks/apply_filters.php b/tests/phpunit/tests/hooks/apply_filters.php index 048a00a78f..06161b9bc7 100755 --- a/tests/phpunit/tests/hooks/apply_filters.php +++ b/tests/phpunit/tests/hooks/apply_filters.php @@ -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 ); diff --git a/tests/phpunit/tests/hooks/do_action.php b/tests/phpunit/tests/hooks/do_action.php index b810d4690b..18d62521ac 100755 --- a/tests/phpunit/tests/hooks/do_action.php +++ b/tests/phpunit/tests/hooks/do_action.php @@ -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 ) ); diff --git a/tests/phpunit/tests/hooks/do_all_hook.php b/tests/phpunit/tests/hooks/do_all_hook.php index a1e3586e84..6c6a0a9844 100755 --- a/tests/phpunit/tests/hooks/do_all_hook.php +++ b/tests/phpunit/tests/hooks/do_all_hook.php @@ -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 ); diff --git a/tests/phpunit/tests/hooks/has_filter.php b/tests/phpunit/tests/hooks/has_filter.php index 0e65b4244c..86d965dc46 100755 --- a/tests/phpunit/tests/hooks/has_filter.php +++ b/tests/phpunit/tests/hooks/has_filter.php @@ -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 ); diff --git a/tests/phpunit/tests/hooks/has_filters.php b/tests/phpunit/tests/hooks/has_filters.php index becf4413b3..3bc5f9f493 100755 --- a/tests/phpunit/tests/hooks/has_filters.php +++ b/tests/phpunit/tests/hooks/has_filters.php @@ -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 ); diff --git a/tests/phpunit/tests/hooks/iterator.php b/tests/phpunit/tests/hooks/iterator.php index 344d31d8f3..30b5580954 100755 --- a/tests/phpunit/tests/hooks/iterator.php +++ b/tests/phpunit/tests/hooks/iterator.php @@ -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 ); diff --git a/tests/phpunit/tests/hooks/preinit_hooks.php b/tests/phpunit/tests/hooks/preinit_hooks.php index e1d991c023..e00474b3c3 100755 --- a/tests/phpunit/tests/hooks/preinit_hooks.php +++ b/tests/phpunit/tests/hooks/preinit_hooks.php @@ -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( diff --git a/tests/phpunit/tests/hooks/remove_all_filters.php b/tests/phpunit/tests/hooks/remove_all_filters.php index 57f4d83875..faf1858495 100755 --- a/tests/phpunit/tests/hooks/remove_all_filters.php +++ b/tests/phpunit/tests/hooks/remove_all_filters.php @@ -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 ); diff --git a/tests/phpunit/tests/hooks/remove_filter.php b/tests/phpunit/tests/hooks/remove_filter.php index 42a3f84623..b35b10f938 100755 --- a/tests/phpunit/tests/hooks/remove_filter.php +++ b/tests/phpunit/tests/hooks/remove_filter.php @@ -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 ); diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 9cc3f09d2a..6335df02af 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -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 ); diff --git a/tests/phpunit/tests/link/getPreviewPostLink.php b/tests/phpunit/tests/link/getPreviewPostLink.php index 40d1ee9614..c716844ca0 100644 --- a/tests/phpunit/tests/link/getPreviewPostLink.php +++ b/tests/phpunit/tests/link/getPreviewPostLink.php @@ -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, ) ); diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php index eb6f2c51af..bdd5529cc3 100644 --- a/tests/phpunit/tests/meta.php +++ b/tests/phpunit/tests/meta.php @@ -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'; diff --git a/tests/phpunit/tests/multisite/getSpaceUsed.php b/tests/phpunit/tests/multisite/getSpaceUsed.php index cbc5138453..be1364a8f0 100644 --- a/tests/phpunit/tests/multisite/getSpaceUsed.php +++ b/tests/phpunit/tests/multisite/getSpaceUsed.php @@ -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(); diff --git a/tests/phpunit/tests/multisite/ms-files-rewriting.php b/tests/phpunit/tests/multisite/ms-files-rewriting.php index 8bc87df7d2..38be416aac 100644 --- a/tests/phpunit/tests/multisite/ms-files-rewriting.php +++ b/tests/phpunit/tests/multisite/ms-files-rewriting.php @@ -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 ); diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index ddf01163f7..37f52941c9 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -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 ); diff --git a/tests/phpunit/tests/oembed/WpEmbed.php b/tests/phpunit/tests/oembed/WpEmbed.php index 8fe8ae661b..9a46e1f3af 100644 --- a/tests/phpunit/tests/oembed/WpEmbed.php +++ b/tests/phpunit/tests/oembed/WpEmbed.php @@ -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' ); diff --git a/tests/phpunit/tests/option/multisite.php b/tests/phpunit/tests/option/multisite.php index 5cde7ba126..0669a7adc6 100644 --- a/tests/phpunit/tests/option/multisite.php +++ b/tests/phpunit/tests/option/multisite.php @@ -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()