diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index ebfd6dad5a..9bafdcadd6 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -144,8 +144,8 @@ class Tests_Actions extends WP_UnitTestCase { } function test_did_action() { - $tag1 = rand_str(); - $tag2 = rand_str(); + $tag1 = 'action1'; + $tag2 = 'action2'; // do action tag1 but not tag2 do_action($tag1); diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index 1805d2db03..317be9bac0 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -186,7 +186,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { * @ticket 19828 */ function test_help_tabs_priority() { - $tab_1 = rand_str(); + $tab_1 = 'tab1'; $tab_1_args = array( 'title' => 'Help!', 'id' => $tab_1, @@ -195,7 +195,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { 'priority' => 10, ); - $tab_2 = rand_str(); + $tab_2 = 'tab2'; $tab_2_args = array( 'title' => 'Help!', 'id' => $tab_2, @@ -203,7 +203,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { 'callback' => false, 'priority' => 2, ); - $tab_3 = rand_str(); + $tab_3 = 'tab3'; $tab_3_args = array( 'title' => 'help!', 'id' => $tab_3, @@ -211,7 +211,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { 'callback' => false, 'priority' => 40, ); - $tab_4 = rand_str(); + $tab_4 = 'tab4'; $tab_4_args = array( 'title' => 'help!', 'id' => $tab_4, diff --git a/tests/phpunit/tests/cron.php b/tests/phpunit/tests/cron.php index b411a5be1e..ecd60be402 100644 --- a/tests/phpunit/tests/cron.php +++ b/tests/phpunit/tests/cron.php @@ -39,16 +39,16 @@ class Tests_Cron extends WP_UnitTestCase { function test_schedule_event_single_args() { // schedule an event with arguments and make sure it's returned by wp_next_scheduled - $hook = rand_str(); + $hook = 'event'; $timestamp = strtotime('+1 hour'); - $args = array(rand_str()); + $args = array('foo'); wp_schedule_single_event( $timestamp, $hook, $args ); // this returns the timestamp only if we provide matching args $this->assertEquals( $timestamp, wp_next_scheduled($hook, $args) ); // these don't match so return nothing $this->assertEquals( false, wp_next_scheduled($hook) ); - $this->assertEquals( false, wp_next_scheduled($hook, array(rand_str())) ); + $this->assertEquals( false, wp_next_scheduled($hook, array('bar')) ); // it's a non recurring event $this->assertEquals( '', wp_get_schedule($hook, $args) ); @@ -69,17 +69,17 @@ class Tests_Cron extends WP_UnitTestCase { function test_schedule_event_args() { // schedule an event and make sure it's returned by wp_next_scheduled - $hook = rand_str(); + $hook = 'event'; $timestamp = strtotime('+1 hour'); $recur = 'hourly'; - $args = array(rand_str()); + $args = array('foo'); wp_schedule_event( $timestamp, 'hourly', $hook, $args ); // this returns the timestamp only if we provide matching args $this->assertEquals( $timestamp, wp_next_scheduled($hook, $args) ); // these don't match so return nothing $this->assertEquals( false, wp_next_scheduled($hook) ); - $this->assertEquals( false, wp_next_scheduled($hook, array(rand_str())) ); + $this->assertEquals( false, wp_next_scheduled($hook, array('bar')) ); $this->assertEquals( $recur, wp_get_schedule($hook, $args) ); diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php index 97d9b26b7d..f8591c260f 100644 --- a/tests/phpunit/tests/db/charset.php +++ b/tests/phpunit/tests/db/charset.php @@ -543,8 +543,8 @@ class Tests_DB_Charset extends WP_UnitTestCase { $table_name = 'test_get_table_charset'; $vars = array(); - foreach( $this->table_and_column_defs as $value ) { - $this_table_name = $table_name . '_' . rand_str( 5 ); + foreach( $this->table_and_column_defs as $i => $value ) { + $this_table_name = $table_name . '_' . $i; $drop = "DROP TABLE IF EXISTS $this_table_name"; $create = "CREATE TABLE $this_table_name {$value['definition']}"; $vars[] = array( $drop, $create, $this_table_name, $value['table_expected'] ); @@ -583,8 +583,8 @@ class Tests_DB_Charset extends WP_UnitTestCase { $table_name = 'test_get_column_charset'; $vars = array(); - foreach( $this->table_and_column_defs as $value ) { - $this_table_name = $table_name . '_' . rand_str( 5 ); + foreach( $this->table_and_column_defs as $i => $value ) { + $this_table_name = $table_name . '_' . $i; $drop = "DROP TABLE IF EXISTS $this_table_name"; $create = "CREATE TABLE $this_table_name {$value['definition']}"; $vars[] = array( $drop, $create, $this_table_name, $value['column_expected'] ); @@ -687,8 +687,8 @@ class Tests_DB_Charset extends WP_UnitTestCase { ), ); - foreach( $data as &$value ) { - $this_table_name = $table_name . '_' . rand_str( 5 ); + foreach( $data as $i => &$value ) { + $this_table_name = $table_name . '_' . $i; $value[0] = "CREATE TABLE $this_table_name {$value[0]}"; $value[1] = "INSERT INTO $this_table_name VALUES {$value[1]}"; @@ -801,8 +801,8 @@ class Tests_DB_Charset extends WP_UnitTestCase { ), ); - foreach( $data as &$value ) { - $this_table_name = $table_name . '_' . rand_str( 5 ); + foreach( $data as $i => &$value ) { + $this_table_name = $table_name . '_' . $i; $value[0] = "CREATE TABLE $this_table_name {$value[0]}"; $value[2] = "SELECT * FROM $this_table_name WHERE a='\xf0\x9f\x98\x88'"; diff --git a/tests/phpunit/tests/option/option.php b/tests/phpunit/tests/option/option.php index a02f8d1bcf..fea674dd53 100644 --- a/tests/phpunit/tests/option/option.php +++ b/tests/phpunit/tests/option/option.php @@ -10,10 +10,10 @@ class Tests_Option_Option extends WP_UnitTestCase { } function test_the_basics() { - $key = rand_str(); - $key2 = rand_str(); - $value = rand_str(); - $value2 = rand_str(); + $key = 'key1'; + $key2 = 'key2'; + $value = 'value1'; + $value2 = 'value2'; $this->assertFalse( get_option( 'doesnotexist' ) ); $this->assertTrue( add_option( $key, $value ) ); @@ -35,7 +35,7 @@ class Tests_Option_Option extends WP_UnitTestCase { } function test_default_filter() { - $random = rand_str(); + $value = 'value'; $this->assertFalse( get_option( 'doesnotexist' ) ); @@ -48,10 +48,10 @@ class Tests_Option_Option extends WP_UnitTestCase { $this->assertEquals( 'bar', get_option( 'doesnotexist', 'bar' ) ); // Once the option exists, the $default arg and the default filter are ignored. - add_option( 'doesnotexist', $random ); - $this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) ); + add_option( 'doesnotexist', $value ); + $this->assertEquals( $value, get_option( 'doesnotexist', 'foo' ) ); add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); - $this->assertEquals( $random, get_option( 'doesnotexist', 'foo' ) ); + $this->assertEquals( $value, get_option( 'doesnotexist', 'foo' ) ); remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); // Cleanup diff --git a/tests/phpunit/tests/option/siteOption.php b/tests/phpunit/tests/option/siteOption.php index 8d76399d8c..b5f178c734 100644 --- a/tests/phpunit/tests/option/siteOption.php +++ b/tests/phpunit/tests/option/siteOption.php @@ -92,9 +92,9 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { } function test_update_site_option_returns_true_for_new_value() { - $key = rand_str(); - $value = rand_str(); - $new_value = rand_str(); + $key = 'key'; + $value = 'value1'; + $new_value = 'value2'; add_site_option( $key, $value ); $this->assertTrue( update_site_option( $key, $new_value ) ); } diff --git a/tests/phpunit/tests/option/siteTransient.php b/tests/phpunit/tests/option/siteTransient.php index 62cf77512a..29aab46ac6 100644 --- a/tests/phpunit/tests/option/siteTransient.php +++ b/tests/phpunit/tests/option/siteTransient.php @@ -14,9 +14,9 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase { } function test_the_basics() { - $key = rand_str(); - $value = rand_str(); - $value2 = rand_str(); + $key = 'key1'; + $value = 'value1'; + $value2 = 'value2'; $this->assertFalse( get_site_transient( 'doesnotexist' ) ); $this->assertTrue( set_site_transient( $key, $value ) ); diff --git a/tests/phpunit/tests/option/transient.php b/tests/phpunit/tests/option/transient.php index 759a9b4f7e..f946852b03 100644 --- a/tests/phpunit/tests/option/transient.php +++ b/tests/phpunit/tests/option/transient.php @@ -14,9 +14,9 @@ class Tests_Option_Transient extends WP_UnitTestCase { } function test_the_basics() { - $key = rand_str(); - $value = rand_str(); - $value2 = rand_str(); + $key = 'key1'; + $value = 'value1'; + $value2 = 'value2'; $this->assertFalse( get_transient( 'doesnotexist' ) ); $this->assertTrue( set_transient( $key, $value ) ); diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index fa544319b1..40fe44759c 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -456,17 +456,17 @@ class Tests_Query_Results extends WP_UnitTestCase { * @ticket 16854 */ function test_query_author_vars() { - $author_1 = self::factory()->user->create( array( 'user_login' => 'admin1', 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_1 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_1 = self::factory()->user->create( array( 'user_login' => 'author1', 'role' => 'author' ) ); + $post_1 = self::factory()->post->create( array( 'post_title' => 'Post 1', 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); - $author_2 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_2 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_2 = self::factory()->user->create( array( 'user_login' => 'author2', 'role' => 'author' ) ); + $post_2 = self::factory()->post->create( array( 'post_title' => 'Post 2', 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); - $author_3 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_3 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_3 = self::factory()->user->create( array( 'user_login' => 'author3', 'role' => 'author' ) ); + $post_3 = self::factory()->post->create( array( 'post_title' => 'Post 3', 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); - $author_4 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) ); - $post_4 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); + $author_4 = self::factory()->user->create( array( 'user_login' => 'author4', 'role' => 'author' ) ); + $post_4 = self::factory()->post->create( array( 'post_title' => 'Post 4', 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); $posts = $this->q->query( array( 'author' => '', @@ -549,7 +549,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertEqualSets( array( $author_3, $author_4 ), $author_ids ); $posts = $this->q->query( array( - 'author_name' => 'admin1', + 'author_name' => 'author1', 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) ) ); $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index 1537370332..6d199c0747 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -2314,8 +2314,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { protected function set_up_three_posts_and_tags() { $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) ); - foreach ( $posts as $post ) { - wp_set_object_terms( $post, rand_str(), 'post_tag' ); + foreach ( $posts as $i => $post ) { + wp_set_object_terms( $post, "term_{$i}", 'post_tag' ); } wp_cache_delete( 'last_changed', 'terms' ); diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index f636092095..fd219f5e70 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -10,7 +10,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { _clean_term_filters(); // insert one term into every post taxonomy // otherwise term_ids and term_taxonomy_ids might be identical, which could mask bugs - $term = rand_str(); + $term = 'seed_term'; foreach(get_object_taxonomies('post') as $tax) wp_insert_term( $term, $tax ); } @@ -20,7 +20,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { register_taxonomy( $taxonomy, 'post' ); // a new unused term - $term = rand_str(); + $term = 'term'; $this->assertNull( term_exists($term) ); $initial_count = wp_count_terms( $taxonomy ); diff --git a/tests/phpunit/tests/term/wpSetObjectTerms.php b/tests/phpunit/tests/term/wpSetObjectTerms.php index f14516b119..248c7bf28e 100644 --- a/tests/phpunit/tests/term/wpSetObjectTerms.php +++ b/tests/phpunit/tests/term/wpSetObjectTerms.php @@ -110,7 +110,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { $terms = array(); for ($i=0; $i<3; $i++ ) { - $term = rand_str(); + $term = "term_{$i}"; $result = wp_insert_term( $term, $this->taxonomy ); $this->assertInternalType( 'array', $result ); $term_id[$term] = $result['term_id']; @@ -245,7 +245,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // first set: 3 terms $terms_1 = array(); for ($i=0; $i<3; $i++ ) { - $term = rand_str(); + $term = "term_{$i}"; $result = wp_insert_term( $term, $this->taxonomy ); $this->assertInternalType( 'array', $result ); $terms_1[$i] = $result['term_id']; @@ -255,7 +255,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { $terms_2 = array(); $terms_2[0] = $terms_1[1]; - $term = rand_str(); + $term = 'term'; $result = wp_insert_term( $term, $this->taxonomy ); $terms_2[1] = $result['term_id']; diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index 481fe6922e..a114e8fc2f 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -103,8 +103,8 @@ class Tests_User extends WP_UnitTestCase { // simple tests for usermeta functions function test_usermeta() { - $key = rand_str(); - $val = rand_str(); + $key = 'key'; + $val = 'value1'; // get a meta key that doesn't exist $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) ); @@ -114,7 +114,7 @@ class Tests_User extends WP_UnitTestCase { $this->assertEquals( $val, get_user_meta( self::$author_id, $key, true ) ); // change and get again - $val2 = rand_str(); + $val2 = 'value2'; update_user_meta( self::$author_id, $key, $val2 ); $this->assertEquals( $val2, get_user_meta( self::$author_id, $key, true ) ); @@ -581,14 +581,14 @@ class Tests_User extends WP_UnitTestCase { */ function test_user_update_email_error() { $id1 = wp_insert_user( array( - 'user_login' => rand_str(), + 'user_login' => 'blackburn', 'user_pass' => 'password', 'user_email' => 'blackburn@battlefield4.com', ) ); $this->assertEquals( $id1, email_exists( 'blackburn@battlefield4.com' ) ); $id2 = wp_insert_user( array( - 'user_login' => rand_str(), + 'user_login' => 'miller', 'user_pass' => 'password', 'user_email' => 'miller@battlefield4.com', ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php index 3d8dff4bdb..3119fea61f 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPosts.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPosts.php @@ -136,11 +136,11 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { function test_search() { $this->make_user_by_role( 'editor' ); - $post_ids[] = self::factory()->post->create( array( 'post_title' => 'First: ' . rand_str() ) ); - $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Second: ' . rand_str() ) ); + $post_ids[] = self::factory()->post->create( array( 'post_title' => 'First: Hello, World!' ) ); + $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Second: Hello, World!' ) ); // Search for none of them - $filter = array( 's' => rand_str() ); + $filter = array( 's' => 'Third' ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); $this->assertNotInstanceOf( 'IXR_Error', $results ); $this->assertEquals( 0, count( $results ) ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php index e5c633615f..794c709d53 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerms.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerms.php @@ -66,7 +66,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $num_terms = 12; register_taxonomy( $tax_name, 'post' ); for( $i = 0; $i < $num_terms; $i++ ) - wp_insert_term( rand_str( 10 ), $tax_name ); + wp_insert_term( "term_{$i}", $tax_name ); // test fetching all terms diff --git a/tests/phpunit/tests/xmlrpc/wp/newPost.php b/tests/phpunit/tests/xmlrpc/wp/newPost.php index a8dae54e6e..3092aef637 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/newPost.php @@ -233,11 +233,11 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { function test_terms() { $this->make_user_by_role( 'editor' ); - $tag1 = wp_create_tag ( rand_str( 30 ) ); + $tag1 = wp_create_tag( 'tag1' ); $this->assertInternalType( 'array', $tag1 ); - $tag2 = wp_create_tag ( rand_str( 30 ) ); + $tag2 = wp_create_tag( 'tag2' ); $this->assertInternalType( 'array', $tag2 ); - $tag3 = wp_create_tag ( rand_str( 30 ) ); + $tag3 = wp_create_tag( 'tag3' ); $this->assertInternalType( 'array', $tag3 ); $post = array( @@ -258,13 +258,13 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { function test_terms_names() { $this->make_user_by_role( 'editor' ); - $ambiguous_name = rand_str( 30 ); + $ambiguous_name = 'foo'; $parent_cat = wp_create_category( $ambiguous_name ); $child_cat = wp_create_category( $ambiguous_name, $parent_cat ); - $cat1_name = rand_str( 30 ); + $cat1_name = 'cat1'; $cat1 = wp_create_category( $cat1_name, $parent_cat ); - $cat2_name = rand_str( 30 ); + $cat2_name = 'cat2'; // first a post with valid categories; one that already exists and one to be created $post = array(