diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index 51225f12dd..1db3fd463f 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -240,8 +240,8 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertSame( 1, did_action( $tag1 ) ); $this->assertSame( 0, did_action( $tag2 ) ); - // Do action $tag2 a random number of times. - $count = rand( 0, 10 ); + // Do action $tag2 10 times. + $count = 10; for ( $i = 0; $i < $count; $i++ ) { do_action( $tag2 ); } diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index 9a3b4e5cd9..2fde9195fd 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -487,11 +487,12 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { $p2 = $this->_create_plugin( "assertSame( array( 'advanced-cache.php' ), array_keys( $dropins ) ); unlink( $p1[1] ); unlink( $p2[1] ); + $this->assertSame( array( 'advanced-cache.php' ), array_keys( $dropins ) ); + // Clean up. $this->_restore_drop_ins(); } @@ -509,9 +510,11 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { public function test_is_network_only_plugin() { $p = $this->_create_plugin( "assertTrue( is_network_only_plugin( $p[0] ) ); + $network_only = is_network_only_plugin( $p[0] ); unlink( $p[1] ); + + $this->assertTrue( $network_only ); } /** @@ -571,12 +574,14 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { $uninstallable_plugins[ $plugin[0] ] = true; update_option( 'uninstall_plugins', $uninstallable_plugins ); - $this->assertTrue( is_uninstallable_plugin( $plugin[0] ) ); + $is_uninstallable = is_uninstallable_plugin( $plugin[0] ); unset( $uninstallable_plugins[ $plugin[0] ] ); update_option( 'uninstall_plugins', $uninstallable_plugins ); unlink( $plugin[1] ); + + $this->assertTrue( $is_uninstallable ); } /** @@ -595,14 +600,15 @@ class Tests_Admin_IncludesPlugin extends WP_UnitTestCase { */ private function _create_plugin( $data = " 'Test commenter', 'comment_author_url' => 'http://example.com/', 'comment_author_email' => 'example@example.com', - 'comment_content' => rand_str( 100 ), + 'comment_content' => 'Hello, world!', 'comment_approved' => '1', ); $comment_id = wp_insert_comment( $comment_data ); diff --git a/tests/phpunit/tests/file.php b/tests/phpunit/tests/file.php index eb6168d9af..311ba30339 100644 --- a/tests/phpunit/tests/file.php +++ b/tests/phpunit/tests/file.php @@ -96,8 +96,8 @@ class Tests_File extends WP_UnitTestCase { return false; } - // Write some random contents. - $c = rand_str(); + // Write some contents. + $c = 'foo'; fwrite( $fp, $c ); fclose( $fp ); diff --git a/tests/phpunit/tests/hooks/addFilter.php b/tests/phpunit/tests/hooks/addFilter.php index 5890f22044..593ba509b8 100644 --- a/tests/phpunit/tests/hooks/addFilter.php +++ b/tests/phpunit/tests/hooks/addFilter.php @@ -15,8 +15,8 @@ class Tests_Hooks_AddFilter extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -30,8 +30,8 @@ class Tests_Hooks_AddFilter extends WP_UnitTestCase { $callback = array( $a, 'action' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -44,8 +44,8 @@ class Tests_Hooks_AddFilter extends WP_UnitTestCase { $callback = array( 'MockAction', 'action' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -59,8 +59,8 @@ class Tests_Hooks_AddFilter extends WP_UnitTestCase { $callback_two = '__return_false'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); $this->assertCount( 1, $hook->callbacks[ $priority ] ); @@ -74,8 +74,8 @@ class Tests_Hooks_AddFilter extends WP_UnitTestCase { $callback_two = '__return_false'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); $this->assertCount( 1, $hook->callbacks[ $priority ] ); @@ -89,8 +89,8 @@ class Tests_Hooks_AddFilter extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $this->assertCount( 1, $hook->callbacks[ $priority ] ); @@ -103,8 +103,8 @@ class Tests_Hooks_AddFilter extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $this->assertCount( 1, $hook->callbacks[ $priority ] ); diff --git a/tests/phpunit/tests/hooks/applyFilters.php b/tests/phpunit/tests/hooks/applyFilters.php index fcb8e3b126..388f85c5c2 100644 --- a/tests/phpunit/tests/hooks/applyFilters.php +++ b/tests/phpunit/tests/hooks/applyFilters.php @@ -13,8 +13,8 @@ class Tests_Hooks_ApplyFilters extends WP_UnitTestCase { $callback = array( $a, 'filter' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $arg = __FUNCTION__ . '_arg'; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -30,8 +30,8 @@ class Tests_Hooks_ApplyFilters extends WP_UnitTestCase { $callback = array( $a, 'filter' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $arg = __FUNCTION__ . '_arg'; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); diff --git a/tests/phpunit/tests/hooks/doAction.php b/tests/phpunit/tests/hooks/doAction.php index 0fb5652f3b..5ac1d4d4b9 100644 --- a/tests/phpunit/tests/hooks/doAction.php +++ b/tests/phpunit/tests/hooks/doAction.php @@ -21,8 +21,8 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase { $callback = array( $a, 'action' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $arg = __FUNCTION__ . '_arg'; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -36,8 +36,8 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase { $callback = array( $a, 'filter' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $arg = __FUNCTION__ . '_arg'; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -54,8 +54,8 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase { $callback_two = array( $b, 'filter' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $arg = __FUNCTION__ . '_arg'; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); @@ -73,8 +73,8 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase { $callback_two = array( $b, 'filter' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $arg = __FUNCTION__ . '_arg'; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); @@ -89,7 +89,7 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase { $callback = array( $this, '_action_callback' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); + $priority = 1; $accepted_args = 0; $arg = __FUNCTION__ . '_arg'; @@ -103,7 +103,7 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase { $callback = array( $this, '_action_callback' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); + $priority = 1; $accepted_args = 1; $arg = __FUNCTION__ . '_arg'; @@ -117,7 +117,7 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase { $callback = array( $this, '_action_callback' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); + $priority = 100; $accepted_args = 1000; $arg = __FUNCTION__ . '_arg'; diff --git a/tests/phpunit/tests/hooks/doAllHook.php b/tests/phpunit/tests/hooks/doAllHook.php index 29eec96428..776c3e4576 100644 --- a/tests/phpunit/tests/hooks/doAllHook.php +++ b/tests/phpunit/tests/hooks/doAllHook.php @@ -13,8 +13,8 @@ class Tests_Hooks_DoAllHook extends WP_UnitTestCase { $callback = array( $a, 'action' ); $hook = new WP_Hook(); $tag = 'all'; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $arg = 'all_arg'; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); diff --git a/tests/phpunit/tests/hooks/hasFilter.php b/tests/phpunit/tests/hooks/hasFilter.php index f9d48b3d4e..f6dde3a0f8 100644 --- a/tests/phpunit/tests/hooks/hasFilter.php +++ b/tests/phpunit/tests/hooks/hasFilter.php @@ -12,8 +12,8 @@ class Tests_Hooks_HasFilter extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -25,8 +25,8 @@ class Tests_Hooks_HasFilter extends WP_UnitTestCase { $callback = array( $a, 'action' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -37,8 +37,8 @@ class Tests_Hooks_HasFilter extends WP_UnitTestCase { $callback = array( 'MockAction', 'action' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -49,8 +49,8 @@ class Tests_Hooks_HasFilter extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -74,8 +74,8 @@ class Tests_Hooks_HasFilter extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); diff --git a/tests/phpunit/tests/hooks/hasFilters.php b/tests/phpunit/tests/hooks/hasFilters.php index f5c1e657fc..068ec88e52 100644 --- a/tests/phpunit/tests/hooks/hasFilters.php +++ b/tests/phpunit/tests/hooks/hasFilters.php @@ -12,8 +12,8 @@ class Tests_Hooks_HasFilters extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -29,8 +29,8 @@ class Tests_Hooks_HasFilters extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $hook->remove_filter( $tag, $callback, $priority ); @@ -41,8 +41,8 @@ class Tests_Hooks_HasFilters extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $function_key = _wp_filter_build_unique_id( $tag, $callback, $priority ); diff --git a/tests/phpunit/tests/hooks/iterator.php b/tests/phpunit/tests/hooks/iterator.php index 4840aa3d4d..0bfdcab36b 100644 --- a/tests/phpunit/tests/hooks/iterator.php +++ b/tests/phpunit/tests/hooks/iterator.php @@ -13,8 +13,8 @@ class Tests_Hooks_Iterator extends WP_UnitTestCase { $callback_two = '__return_false'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args ); diff --git a/tests/phpunit/tests/hooks/preinitHooks.php b/tests/phpunit/tests/hooks/preinitHooks.php index 551d64400f..18afaf6992 100644 --- a/tests/phpunit/tests/hooks/preinitHooks.php +++ b/tests/phpunit/tests/hooks/preinitHooks.php @@ -10,9 +10,9 @@ class Tests_Hooks_PreinitHooks extends WP_UnitTestCase { public function test_array_to_hooks() { $tag1 = __FUNCTION__ . '_1'; - $priority1 = rand( 1, 100 ); + $priority1 = 1; $tag2 = __FUNCTION__ . '_2'; - $priority2 = rand( 1, 100 ); + $priority2 = 2; $filters = array( $tag1 => array( $priority1 => array( diff --git a/tests/phpunit/tests/hooks/removeAllFilters.php b/tests/phpunit/tests/hooks/removeAllFilters.php index cfaf81f4c8..90b8a06cda 100644 --- a/tests/phpunit/tests/hooks/removeAllFilters.php +++ b/tests/phpunit/tests/hooks/removeAllFilters.php @@ -12,8 +12,8 @@ class Tests_Hooks_RemoveAllFilters extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); @@ -27,8 +27,8 @@ class Tests_Hooks_RemoveAllFilters extends WP_UnitTestCase { $callback_two = '__return_false'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args ); diff --git a/tests/phpunit/tests/hooks/removeFilter.php b/tests/phpunit/tests/hooks/removeFilter.php index 793cd02b3c..adf8b6ad75 100644 --- a/tests/phpunit/tests/hooks/removeFilter.php +++ b/tests/phpunit/tests/hooks/removeFilter.php @@ -12,8 +12,8 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase { $callback = '__return_null'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $hook->remove_filter( $tag, $callback, $priority ); @@ -26,8 +26,8 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase { $callback = array( $a, 'action' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $hook->remove_filter( $tag, $callback, $priority ); @@ -39,8 +39,8 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase { $callback = array( 'MockAction', 'action' ); $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $hook->remove_filter( $tag, $callback, $priority ); @@ -53,8 +53,8 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase { $callback_two = '__return_false'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); $hook->add_filter( $tag, $callback_two, $priority, $accepted_args ); @@ -69,8 +69,8 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase { $callback_two = '__return_false'; $hook = new WP_Hook(); $tag = __FUNCTION__; - $priority = rand( 1, 100 ); - $accepted_args = rand( 1, 100 ); + $priority = 1; + $accepted_args = 2; $hook->add_filter( $tag, $callback_one, $priority, $accepted_args ); $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args ); diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php index b67e795163..830359427a 100644 --- a/tests/phpunit/tests/image/intermediateSize.php +++ b/tests/phpunit/tests/image/intermediateSize.php @@ -181,23 +181,23 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { * @requires function imagejpeg */ public function test_get_intermediate_sizes_by_array_zero_height() { - // Generate random width. - $random_w = rand( 300, 400 ); + // Use this width. + $width = 300; // Only one dimention match shouldn't return false positive (see: #17626). - add_image_size( 'test-size', $random_w, 0, false ); - add_image_size( 'false-height', $random_w, 100, true ); + add_image_size( 'test-size', $width, 0, false ); + add_image_size( 'false-height', $width, 100, true ); $file = DIR_TESTDATA . '/images/waffles.jpg'; $id = $this->_make_attachment( $file, 0 ); $original = wp_get_attachment_metadata( $id ); - $image_w = $random_w; + $image_w = $width; $image_h = round( ( $image_w / $original['width'] ) * $original['height'] ); // Look for a size by array that exists. // Note: Staying larger than 300px to miss default medium crop. - $image = image_get_intermediate_size( $id, array( $random_w, 0 ) ); + $image = image_get_intermediate_size( $id, array( $width, 0 ) ); // Test for the expected string because the array will by definition // return with the correct height and width attributes. diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index f8edf13dae..c7d60f4b5f 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -68,8 +68,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => "{$post_type}_content", + 'post_title' => "{$post_type}_title", 'tax_input' => array( 'post_tag' => 'tag1,tag2', 'ctax' => 'cterm1,cterm2', @@ -126,8 +126,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ), ); @@ -162,8 +162,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ), ); @@ -207,8 +207,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ), ); @@ -249,8 +249,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'draft', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ), ); @@ -284,8 +284,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ), ); @@ -328,8 +328,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => "{$status}_content", + 'post_title' => "{$status}_title", 'post_date' => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ), ); @@ -370,8 +370,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'private', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ), ); @@ -404,8 +404,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => '2012-02-30 00:00:00', ); @@ -427,8 +427,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date_1}" ), 'Y-m-d H:i:s' ), ); @@ -533,8 +533,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date' => date_format( date_create( "@{$future_date}" ), 'Y-m-d H:i:s' ), ); @@ -564,7 +564,7 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_date' => '2007-10-31 06:15:00', ); @@ -782,11 +782,11 @@ class Tests_Post extends WP_UnitTestCase { register_taxonomy( 'test_tax', 'post' ); - $title = rand_str(); + $title = 'title'; $post_data = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => $title, 'tax_input' => array( 'test_tax' => array( 'term', 'term2', 'term3' ), @@ -906,7 +906,7 @@ class Tests_Post extends WP_UnitTestCase { register_taxonomy( $tax, $post_type ); $post = self::factory()->post->create( array( 'post_type' => $post_type ) ); - wp_set_object_terms( $post, rand_str(), $tax ); + wp_set_object_terms( $post, 'foo', $tax ); $wp_tag_cloud = wp_tag_cloud( array( @@ -973,8 +973,8 @@ class Tests_Post extends WP_UnitTestCase { array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', ) ); $post = get_post( $post_id ); @@ -991,8 +991,8 @@ class Tests_Post extends WP_UnitTestCase { array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_type' => 'page', ) ); @@ -1203,8 +1203,8 @@ class Tests_Post extends WP_UnitTestCase { $post = array( 'post_author' => self::$editor_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_date_gmt' => '2014-01-01 12:00:00', ); diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 86b24cfd32..2922c185d2 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -272,8 +272,8 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $post_id = wp_insert_post( array( - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', ) ); diff --git a/tests/phpunit/tests/post/meta.php b/tests/phpunit/tests/post/meta.php index 37c07d84e8..ad391e741f 100644 --- a/tests/phpunit/tests/post/meta.php +++ b/tests/phpunit/tests/post/meta.php @@ -23,8 +23,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { array( 'post_author' => self::$author->ID, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', ) ); @@ -32,8 +32,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { array( 'post_author' => self::$author->ID, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', ) ); } diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 36c7785f6e..c95c6709c4 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -12,7 +12,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { public function set_up() { parent::set_up(); - $this->menu_id = wp_create_nav_menu( rand_str() ); + $this->menu_id = wp_create_nav_menu( 'foo' ); } /** @@ -255,8 +255,8 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { */ public function test_wp_setup_nav_menu_item_for_post_type_archive() { - $post_type_slug = rand_str( 12 ); - $post_type_description = rand_str(); + $post_type_slug = 'fooo-bar-baz'; + $post_type_description = 'foo'; register_post_type( $post_type_slug, array( @@ -288,7 +288,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { */ public function test_wp_setup_nav_menu_item_for_post_type_archive_no_description() { - $post_type_slug = rand_str( 12 ); + $post_type_slug = 'fooo-bar-baz'; $post_type_description = ''; register_post_type( $post_type_slug, @@ -319,8 +319,8 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { */ public function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description() { - $post_type_slug = rand_str( 12 ); - $post_type_description = rand_str(); + $post_type_slug = 'fooo-bar-baz'; + $post_type_description = 'foobaz'; register_post_type( $post_type_slug, array( @@ -331,7 +331,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { ) ); - $menu_item_description = rand_str(); + $menu_item_description = 'foo_description'; $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, @@ -354,7 +354,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { */ public function test_wp_setup_nav_menu_item_for_unknown_post_type_archive_no_description() { - $post_type_slug = rand_str( 12 ); + $post_type_slug = 'fooo-bar-baz'; $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index 29267e429a..e7def81a0c 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -132,33 +132,33 @@ class Tests_Post_Query extends WP_UnitTestCase { $post_id1 = self::factory()->post->create( array( 'post_type' => 'page', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 1, ) ); $post_id2 = self::factory()->post->create( array( 'post_type' => 'page', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 2, ) ); $post_id3 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id2, - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 3, ) ); $post_id4 = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $post_id2, - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 4, ) ); $post_id5 = self::factory()->post->create( array( 'post_type' => 'page', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 5, ) ); @@ -219,7 +219,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $post_id, array( 'post_mime_type' => 'image/jpeg', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 1, ) ); $att_ids[2] = self::factory()->attachment->create_object( @@ -227,7 +227,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $post_id, array( 'post_mime_type' => 'image/jpeg', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 2, ) ); $att_ids[3] = self::factory()->attachment->create_object( @@ -235,7 +235,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $post_id, array( 'post_mime_type' => 'image/jpeg', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 3, ) ); $att_ids[4] = self::factory()->attachment->create_object( @@ -243,7 +243,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $post_id, array( 'post_mime_type' => 'image/jpeg', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 4, ) ); $att_ids[5] = self::factory()->attachment->create_object( @@ -251,7 +251,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $post_id, array( 'post_mime_type' => 'image/jpeg', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 5, ) ); diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index 4ff458a012..322114e474 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -17,7 +17,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { public function set_up() { parent::set_up(); - $this->post_type = rand_str( 20 ); + $this->post_type = 'test-revision'; } /** @@ -446,7 +446,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { array( 'post_status' => 'publish', 'ID' => $post_id, - 'post_content' => rand_str(), + 'post_content' => 'content', ) ); diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 449467cf1d..7bba3b639b 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -21,7 +21,7 @@ class Tests_Post_Types extends WP_UnitTestCase { public function set_up() { parent::set_up(); - $this->post_type = rand_str( 20 ); + $this->post_type = 'foo1'; } public function test_register_post_type() { diff --git a/tests/phpunit/tests/query/commentCount.php b/tests/phpunit/tests/query/commentCount.php index 4f7803dd6b..5a759a3f06 100644 --- a/tests/phpunit/tests/query/commentCount.php +++ b/tests/phpunit/tests/query/commentCount.php @@ -21,7 +21,7 @@ class Tests_Query_CommentCount extends WP_UnitTestCase { public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { $post_id = $factory->post->create( array( - 'post_content' => 1 . rand_str() . ' about', + 'post_content' => '1 about', 'post_type' => self::$post_type, ) ); @@ -30,7 +30,7 @@ class Tests_Query_CommentCount extends WP_UnitTestCase { $post_id = $factory->post->create( array( - 'post_content' => 1 . rand_str() . ' about', + 'post_content' => '2 about', 'post_type' => self::$post_type, ) ); @@ -41,7 +41,7 @@ class Tests_Query_CommentCount extends WP_UnitTestCase { $post_id = $factory->post->create( array( - 'post_content' => 1 . rand_str() . ' about', + 'post_content' => '3 about', 'post_type' => self::$post_type, ) ); @@ -52,7 +52,7 @@ class Tests_Query_CommentCount extends WP_UnitTestCase { $post_id = $factory->post->create( array( - 'post_content' => 1 . rand_str() . ' about', + 'post_content' => '4 about', 'post_type' => self::$post_type, ) ); diff --git a/tests/phpunit/tests/query/search.php b/tests/phpunit/tests/query/search.php index 2beda65d2f..418acbfc85 100644 --- a/tests/phpunit/tests/query/search.php +++ b/tests/phpunit/tests/query/search.php @@ -10,7 +10,7 @@ class Tests_Query_Search extends WP_UnitTestCase { public function set_up() { parent::set_up(); - $this->post_type = rand_str( 12 ); + $this->post_type = 'foo1'; register_post_type( $this->post_type ); $this->q = new WP_Query(); @@ -36,7 +36,7 @@ class Tests_Query_Search extends WP_UnitTestCase { foreach ( range( 1, 7 ) as $i ) { self::factory()->post->create( array( - 'post_content' => $i . rand_str() . ' about', + 'post_content' => "{$i} about", 'post_type' => $this->post_type, ) ); diff --git a/tests/phpunit/tests/query/taxQuery.php b/tests/phpunit/tests/query/taxQuery.php index 2ca00b605b..2094262e24 100644 --- a/tests/phpunit/tests/query/taxQuery.php +++ b/tests/phpunit/tests/query/taxQuery.php @@ -1209,8 +1209,8 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { register_taxonomy_for_object_type( 'post_tag', 'attachment:image' ); $tag_id = self::factory()->term->create( array( - 'slug' => rand_str(), - 'name' => rand_str(), + 'slug' => 'foo-bar', + 'name' => 'Foo Bar', ) ); $image_id = self::factory()->attachment->create_object( diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index fae3bbb8b3..47ea5820f3 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -522,8 +522,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control public function test_get_items_invalid_date() { $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); - $request->set_param( 'after', rand_str() ); - $request->set_param( 'before', rand_str() ); + $request->set_param( 'after', 'foo' ); + $request->set_param( 'before', 'bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } @@ -570,8 +570,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control */ public function test_get_items_invalid_modified_date() { $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); - $request->set_param( 'modified_after', rand_str() ); - $request->set_param( 'modified_before', rand_str() ); + $request->set_param( 'modified_after', 'foo' ); + $request->set_param( 'modified_before', 'bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 0c7ed625b7..99986a8037 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -888,8 +888,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase public function test_get_comments_invalid_date() { $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); - $request->set_param( 'after', rand_str() ); - $request->set_param( 'before', rand_str() ); + $request->set_param( 'after', 'foo' ); + $request->set_param( 'before', 'bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } @@ -1477,7 +1477,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 'author_email' => 'lovejoy@example.com', 'author_url' => 'http://timothylovejoy.jr', 'content' => 'It\'s all over\, people! We don\'t have a prayer!', - 'date' => rand_str(), + 'date' => 'foo-bar', ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); @@ -2625,8 +2625,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase wp_set_current_user( self::$admin_id ); $params = array( - 'content' => rand_str(), - 'date' => rand_str(), + 'content' => 'content', + 'date' => 'foo', ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); @@ -2641,8 +2641,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase wp_set_current_user( self::$admin_id ); $params = array( - 'content' => rand_str(), - 'date_gmt' => rand_str(), + 'content' => 'content', + 'date_gmt' => 'foo', ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); @@ -2770,7 +2770,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase // Change the comment parent. $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%s', $child_comment ) ); $request->set_param( 'parent', $comment_id_1 ); - $request->set_param( 'content', rand_str() ); + $request->set_param( 'content', 'foo bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php index f4548f3fc8..da24a13d9b 100644 --- a/tests/phpunit/tests/rest-api/rest-pages-controller.php +++ b/tests/phpunit/tests/rest-api/rest-pages-controller.php @@ -330,8 +330,8 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te public function test_get_items_invalid_date() { $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); - $request->set_param( 'after', rand_str() ); - $request->set_param( 'before', rand_str() ); + $request->set_param( 'after', 'foo' ); + $request->set_param( 'before', 'bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } @@ -369,8 +369,8 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te */ public function test_get_items_invalid_modified_date() { $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); - $request->set_param( 'modified_after', rand_str() ); - $request->set_param( 'modified_before', rand_str() ); + $request->set_param( 'modified_after', 'foo' ); + $request->set_param( 'modified_before', 'bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index d820e86d74..f02037962c 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -1694,8 +1694,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te public function test_get_items_invalid_date() { $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); - $request->set_param( 'after', rand_str() ); - $request->set_param( 'before', rand_str() ); + $request->set_param( 'after', 'foo' ); + $request->set_param( 'before', 'bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } @@ -1719,8 +1719,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te */ public function test_get_items_invalid_modified_date() { $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); - $request->set_param( 'modified_after', rand_str() ); - $request->set_param( 'modified_before', rand_str() ); + $request->set_param( 'modified_after', 'foo' ); + $request->set_param( 'modified_before', 'bar' ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } @@ -2697,7 +2697,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 0, array( 'post_mime_type' => 'image/jpeg', - 'menu_order' => rand( 1, 100 ), + 'menu_order' => 1, ) ); @@ -3310,7 +3310,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te public function test_update_post_ignore_readonly() { wp_set_current_user( self::$editor_id ); - $new_content = rand_str(); + $new_content = 'foo bar baz'; $expected_modified = current_time( 'mysql' ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); @@ -3375,7 +3375,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $params = $this->set_post_data( array( - 'date' => rand_str(), + 'date' => 'foo', ) ); $request->set_body_params( $params ); @@ -3390,7 +3390,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $params = $this->set_post_data( array( - 'date_gmt' => rand_str(), + 'date_gmt' => 'foo', ) ); $request->set_body_params( $params ); diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index 62697800cc..1a5ad9774b 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -173,7 +173,7 @@ class Tests_Rewrite extends WP_UnitTestCase { public function test_url_to_postid_custom_post_type() { delete_option( 'rewrite_rules' ); - $post_type = rand_str( 12 ); + $post_type = 'url_to_postid'; register_post_type( $post_type, array( 'public' => true ) ); $id = self::factory()->post->create( array( 'post_type' => $post_type ) ); diff --git a/tests/phpunit/tests/rewrite/numericSlugs.php b/tests/phpunit/tests/rewrite/numericSlugs.php index e11c6b2a46..41ef636368 100644 --- a/tests/phpunit/tests/rewrite/numericSlugs.php +++ b/tests/phpunit/tests/rewrite/numericSlugs.php @@ -23,7 +23,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '2015', 'post_date' => '2015-02-01 01:00:00', @@ -53,7 +53,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '2015', 'post_date' => '2015-02-01 01:00:00', @@ -80,7 +80,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '2015', 'post_date' => '2015-02-01 01:00:00', ) @@ -98,7 +98,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '2015', 'post_date' => '2015-02-01 01:00:00', ) @@ -114,7 +114,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '02', 'post_date' => '2015-02-01 01:00:00', @@ -133,7 +133,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '02', 'post_date' => '2015-02-01 01:00:00', @@ -150,7 +150,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '2', 'post_date' => '2015-02-01 01:00:00', @@ -169,7 +169,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '2', 'post_date' => '2015-02-01 01:00:00', @@ -186,7 +186,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '02', 'post_date' => '2015-02-01 01:00:00', ) @@ -204,7 +204,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '02', 'post_date' => '2015-02-01 01:00:00', ) @@ -220,7 +220,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '2', 'post_date' => '2015-02-01 01:00:00', ) @@ -238,7 +238,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '2', 'post_date' => '2015-02-01 01:00:00', ) @@ -254,7 +254,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '01', 'post_date' => '2015-02-01 01:00:00', @@ -273,7 +273,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '', 'post_name' => '01', 'post_date' => '2015-02-01 01:00:00', @@ -290,7 +290,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '01', 'post_date' => '2015-02-01 01:00:00', ) @@ -308,7 +308,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '01', 'post_date' => '2015-02-01 01:00:00', ) @@ -324,7 +324,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'post_author' => $this->author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), + 'post_content' => 'content', 'post_title' => '01', 'post_date' => '2015-02-01 01:00:00', ) diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 6d7cc06602..122f55b6bc 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -17,7 +17,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { */ public function test_get_unknown_taxonomies() { // Taxonomies for an unknown object type. - $this->assertSame( array(), get_object_taxonomies( rand_str() ) ); + $this->assertSame( array(), get_object_taxonomies( 'unknown' ) ); $this->assertSame( array(), get_object_taxonomies( '' ) ); $this->assertSame( array(), get_object_taxonomies( 0 ) ); $this->assertSame( array(), get_object_taxonomies( null ) ); @@ -144,7 +144,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { public function test_register_taxonomy() { // Make up a new taxonomy name, and ensure it's unused. - $tax = rand_str(); + $tax = 'tax_new'; $this->assertFalse( taxonomy_exists( $tax ) ); register_taxonomy( $tax, 'post' ); @@ -158,7 +158,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { public function test_register_hierarchical_taxonomy() { // Make up a new taxonomy name, and ensure it's unused. - $tax = rand_str(); + $tax = 'tax_new'; $this->assertFalse( taxonomy_exists( $tax ) ); register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 61fbb3a397..737047bdd1 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -51,14 +51,17 @@ class Tests_Term extends WP_UnitTestCase { */ public function test_is_term_type() { // Insert a term. - $term = rand_str(); + $term = 'term_new'; $t = wp_insert_term( $term, $this->taxonomy ); $this->assertIsArray( $t ); $term_obj = get_term_by( 'name', $term, $this->taxonomy ); - $this->assertEquals( $t['term_id'], term_exists( $term_obj->slug ) ); + $exists = term_exists( $term_obj->slug ); // Clean up. - $this->assertTrue( wp_delete_term( $t['term_id'], $this->taxonomy ) ); + $deleted = wp_delete_term( $t['term_id'], $this->taxonomy ); + + $this->assertEquals( $t['term_id'], $exists ); + $this->assertTrue( $deleted ); } /** diff --git a/tests/phpunit/tests/term/getTermField.php b/tests/phpunit/tests/term/getTermField.php index a5a132a9b4..c69044564c 100644 --- a/tests/phpunit/tests/term/getTermField.php +++ b/tests/phpunit/tests/term/getTermField.php @@ -91,7 +91,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { } public function test_get_term_field_name() { - $name = rand_str( 15 ); + $name = 'baz'; $term = self::factory()->term->create_and_get( array( @@ -106,7 +106,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { } public function test_get_term_field_slug_when_slug_is_set() { - $slug = rand_str( 15 ); + $slug = 'baz'; $term = self::factory()->term->create_and_get( array( @@ -121,7 +121,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { } public function test_get_term_field_slug_when_slug_falls_back_from_name() { - $name = rand_str( 15 ); + $name = 'baz'; $term = self::factory()->term->create_and_get( array( @@ -156,7 +156,7 @@ class Tests_Term_getTermField extends WP_UnitTestCase { } public function test_get_term_field_description() { - $desc = wpautop( rand_str() ); + $desc = wpautop( 'baz' ); $term = self::factory()->term->create_and_get( array( diff --git a/tests/phpunit/tests/term/splitSharedTerm.php b/tests/phpunit/tests/term/splitSharedTerm.php index 65cefe8c4a..52e4281016 100644 --- a/tests/phpunit/tests/term/splitSharedTerm.php +++ b/tests/phpunit/tests/term/splitSharedTerm.php @@ -208,7 +208,7 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { array( '%d' ) ); - $menu_id = wp_create_nav_menu( rand_str() ); + $menu_id = wp_create_nav_menu( 'Nav Menu Bar' ); $cat_menu_item = wp_update_nav_menu_item( $menu_id, 0, diff --git a/tests/phpunit/tests/term/termExists.php b/tests/phpunit/tests/term/termExists.php index bb4381036b..8bd9a783c7 100644 --- a/tests/phpunit/tests/term/termExists.php +++ b/tests/phpunit/tests/term/termExists.php @@ -260,7 +260,7 @@ class Tests_TermExists extends WP_UnitTestCase { register_taxonomy( 'wptests_tax', 'post' ); // Insert a term. - $term = rand_str(); + $term = __FUNCTION__; $t = wp_insert_term( $term, 'wptests_tax' ); $this->assertIsArray( $t ); $this->assertEquals( $t['term_id'], term_exists( $t['term_id'] ) ); diff --git a/tests/phpunit/tests/term/wpSetObjectTerms.php b/tests/phpunit/tests/term/wpSetObjectTerms.php index b0da2fa3d6..8032a50e79 100644 --- a/tests/phpunit/tests/term/wpSetObjectTerms.php +++ b/tests/phpunit/tests/term/wpSetObjectTerms.php @@ -133,9 +133,9 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { $ids = self::$post_ids; $terms = array( - rand_str(), - rand_str(), - rand_str(), + 'term0', + 'term1', + 'term2', ); foreach ( $ids as $id ) { @@ -164,7 +164,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { public function test_set_object_terms_invalid() { // Bogus taxonomy. - $result = wp_set_object_terms( self::$post_ids[0], array( rand_str() ), rand_str() ); + $result = wp_set_object_terms( self::$post_ids[0], array( 'foo' ), 'invalid-taxonomy' ); $this->assertWPError( $result ); } diff --git a/tests/phpunit/tests/term/wpTaxonomy.php b/tests/phpunit/tests/term/wpTaxonomy.php index a8689284c2..a47edcc9ee 100644 --- a/tests/phpunit/tests/term/wpTaxonomy.php +++ b/tests/phpunit/tests/term/wpTaxonomy.php @@ -18,7 +18,7 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase { /* @var WP $wp */ global $wp; - $taxonomy = rand_str(); + $taxonomy = 'taxonomy1'; $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post' ); $taxonomy_object->add_rewrite_rules(); @@ -31,7 +31,7 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase { /* @var WP $wp */ global $wp; - $taxonomy = rand_str(); + $taxonomy = 'taxonomy2'; $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post', @@ -58,7 +58,7 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase { /* @var WP_Rewrite $wp_rewrite */ global $wp_rewrite; - $taxonomy = rand_str(); + $taxonomy = 'taxonomy3'; $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post', @@ -79,7 +79,7 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase { } public function test_adds_ajax_callback() { - $taxonomy = rand_str(); + $taxonomy = 'taxonomy4'; $taxonomy_object = new WP_Taxonomy( $taxonomy, 'post', diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index ce81c95bba..23e2efad73 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -299,7 +299,7 @@ class Tests_Theme extends WP_UnitTestCase { // get_query_template() // Template file that doesn't exist. - $this->assertSame( '', get_query_template( rand_str() ) ); + $this->assertSame( '', get_query_template( 'nonexistant' ) ); // Template files that do exist. /* @@ -333,8 +333,8 @@ class Tests_Theme extends WP_UnitTestCase { public function test_switch_theme_bogus() { // Try switching to a theme that doesn't exist. - $template = rand_str(); - $style = rand_str(); + $template = 'some_template'; + $style = 'some_style'; update_option( 'template', $template ); update_option( 'stylesheet', $style ); diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index c3930724ae..8c4c0d199e 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -104,7 +104,7 @@ class Tests_User extends WP_UnitTestCase { $this->assertSame( $val, get_user_option( $key, self::$author_id ) ); // Change and get again. - $val2 = rand_str(); + $val2 = 'baz'; update_user_option( self::$author_id, $key, $val2 ); $this->assertSame( $val2, get_user_option( $key, self::$author_id ) ); } @@ -135,7 +135,7 @@ class Tests_User extends WP_UnitTestCase { // Delete by key AND value. update_user_meta( self::$author_id, $key, $val ); // Incorrect key: key still exists. - delete_user_meta( self::$author_id, $key, rand_str() ); + delete_user_meta( self::$author_id, $key, 'foo' ); $this->assertSame( $val, get_user_meta( self::$author_id, $key, true ) ); // Correct key: deleted. delete_user_meta( self::$author_id, $key, $val ); @@ -149,9 +149,9 @@ class Tests_User extends WP_UnitTestCase { public function test_usermeta_array() { // Some values to set. $vals = array( - rand_str() => 'val-' . rand_str(), - rand_str() => 'val-' . rand_str(), - rand_str() => 'val-' . rand_str(), + 'key0' => 'val0', + 'key1' => 'val1', + 'key2' => 'val2', ); // There is already some stuff in the array. @@ -475,8 +475,8 @@ class Tests_User extends WP_UnitTestCase { $post = array( 'post_author' => self::$author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_type' => 'post', ); @@ -636,7 +636,7 @@ class Tests_User extends WP_UnitTestCase { public function test_user_meta_error() { $id1 = wp_insert_user( array( - 'user_login' => rand_str(), + 'user_login' => 'taco_burrito', 'user_pass' => 'password', 'user_email' => 'taco@burrito.com', ) @@ -645,7 +645,7 @@ class Tests_User extends WP_UnitTestCase { $id2 = wp_insert_user( array( - 'user_login' => rand_str(), + 'user_login' => 'taco_burrito2', 'user_pass' => 'password', 'user_email' => 'taco@burrito.com', ) @@ -826,9 +826,9 @@ class Tests_User extends WP_UnitTestCase { */ public function test_wp_insert_user_should_not_wipe_existing_password() { $user_details = array( - 'user_login' => rand_str(), + 'user_login' => 'jonsnow', 'user_pass' => 'password', - 'user_email' => rand_str() . '@example.com', + 'user_email' => 'jonsnow@example.com', ); $user_id = wp_insert_user( $user_details ); diff --git a/tests/phpunit/tests/user/author.php b/tests/phpunit/tests/user/author.php index 5786578855..1a624ec833 100644 --- a/tests/phpunit/tests/user/author.php +++ b/tests/phpunit/tests/user/author.php @@ -26,8 +26,8 @@ class Tests_User_Author_Template extends WP_UnitTestCase { array( 'post_author' => self::$author_id, 'post_status' => 'publish', - 'post_content' => rand_str(), - 'post_title' => rand_str(), + 'post_content' => 'content', + 'post_title' => 'title', 'post_type' => 'post', ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/editProfile.php b/tests/phpunit/tests/xmlrpc/wp/editProfile.php index 7c00626908..2789dbe460 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editProfile.php +++ b/tests/phpunit/tests/xmlrpc/wp/editProfile.php @@ -16,13 +16,13 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { $subscriber_id = $this->make_user_by_role( 'subscriber' ); $new_data = array( - 'first_name' => rand_str(), - 'last_name' => rand_str(), + 'first_name' => 'firstname', + 'last_name' => 'lastname', 'url' => 'http://www.example.org/subscriber', - 'display_name' => rand_str(), - 'nickname' => rand_str(), - 'nicename' => rand_str(), - 'bio' => rand_str( 200 ), + 'display_name' => 'displayname', + 'nickname' => 'nickname', + 'nicename' => 'nicename', + 'bio' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', ); $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'subscriber', 'subscriber', $new_data ) ); $this->assertNotIXRError( $result ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getComment.php b/tests/phpunit/tests/xmlrpc/wp/getComment.php index e43a733910..08cd4a5b00 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComment.php @@ -18,7 +18,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { 'comment_author' => 'Test commenter', 'comment_author_url' => 'http://example.com/', 'comment_author_email' => 'example@example.com', - 'comment_content' => rand_str( 100 ), + 'comment_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', ); self::$parent_comment_id = wp_insert_comment( self::$parent_comment_data ); @@ -28,7 +28,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { 'comment_author_url' => 'http://example.org/', 'comment_author_email' => 'example@example.org', 'comment_parent' => self::$parent_comment_id, - 'comment_content' => rand_str( 100 ), + 'comment_content' => 'Duis non neque cursus, commodo massa in, bibendum nisl.', ); self::$child_comment_id = wp_insert_comment( self::$child_comment_data ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php index 0fd81ada8a..be25ca2770 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -14,9 +14,9 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $this->post_date_ts = strtotime( '+1 day' ); $this->post_data = array( - 'post_title' => rand_str(), - 'post_content' => rand_str( 2000 ), - 'post_excerpt' => rand_str( 100 ), + 'post_title' => 'Post Title', + 'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + 'post_excerpt' => 'Post Excerpt', 'post_author' => $this->make_user_by_role( 'author' ), 'post_date' => date_format( date_create( "@{$this->post_date_ts}" ), 'Y-m-d H:i:s' ), ); diff --git a/tests/phpunit/tests/xmlrpc/wp/newComment.php b/tests/phpunit/tests/xmlrpc/wp/newComment.php index 6cc6c30160..7c2eacc6b1 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/newComment.php @@ -55,7 +55,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 'administrator', self::$posts['publish']->ID, array( - 'content' => rand_str( 100 ), + 'content' => 'Content', ), ) ); @@ -155,7 +155,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 'administrator', $post->ID, array( - 'content' => rand_str( 100 ), + 'content' => 'Content', ), ) ); @@ -171,7 +171,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { 'administrator', self::$posts['publish']->ID, array( - 'content' => rand_str( 100 ), + 'content' => 'Content', ), );