Ticket #37371: 37371.patch
File 37371.patch, 17.4 KB (added by , 5 years ago) |
---|
-
tests/phpunit/tests/actions.php
144 144 } 145 145 146 146 function test_did_action() { 147 $tag1 = rand_str();148 $tag2 = rand_str();147 $tag1 = 'action1'; 148 $tag2 = 'action2'; 149 149 150 150 // do action tag1 but not tag2 151 151 do_action($tag1); -
tests/phpunit/tests/admin/includesScreen.php
186 186 * @ticket 19828 187 187 */ 188 188 function test_help_tabs_priority() { 189 $tab_1 = rand_str();189 $tab_1 = 'tab1'; 190 190 $tab_1_args = array( 191 191 'title' => 'Help!', 192 192 'id' => $tab_1, … … 195 195 'priority' => 10, 196 196 ); 197 197 198 $tab_2 = rand_str();198 $tab_2 = 'tab2'; 199 199 $tab_2_args = array( 200 200 'title' => 'Help!', 201 201 'id' => $tab_2, … … 203 203 'callback' => false, 204 204 'priority' => 2, 205 205 ); 206 $tab_3 = rand_str();206 $tab_3 = 'tab3'; 207 207 $tab_3_args = array( 208 208 'title' => 'help!', 209 209 'id' => $tab_3, … … 211 211 'callback' => false, 212 212 'priority' => 40, 213 213 ); 214 $tab_4 = rand_str();214 $tab_4 = 'tab4'; 215 215 $tab_4_args = array( 216 216 'title' => 'help!', 217 217 'id' => $tab_4, -
tests/phpunit/tests/cron.php
39 39 40 40 function test_schedule_event_single_args() { 41 41 // schedule an event with arguments and make sure it's returned by wp_next_scheduled 42 $hook = rand_str();42 $hook = 'event'; 43 43 $timestamp = strtotime('+1 hour'); 44 $args = array( rand_str());44 $args = array('foo'); 45 45 46 46 wp_schedule_single_event( $timestamp, $hook, $args ); 47 47 // this returns the timestamp only if we provide matching args 48 48 $this->assertEquals( $timestamp, wp_next_scheduled($hook, $args) ); 49 49 // these don't match so return nothing 50 50 $this->assertEquals( false, wp_next_scheduled($hook) ); 51 $this->assertEquals( false, wp_next_scheduled($hook, array( rand_str())) );51 $this->assertEquals( false, wp_next_scheduled($hook, array('bar')) ); 52 52 53 53 // it's a non recurring event 54 54 $this->assertEquals( '', wp_get_schedule($hook, $args) ); … … 69 69 70 70 function test_schedule_event_args() { 71 71 // schedule an event and make sure it's returned by wp_next_scheduled 72 $hook = rand_str();72 $hook = 'event'; 73 73 $timestamp = strtotime('+1 hour'); 74 74 $recur = 'hourly'; 75 $args = array( rand_str());75 $args = array('foo'); 76 76 77 77 wp_schedule_event( $timestamp, 'hourly', $hook, $args ); 78 78 // this returns the timestamp only if we provide matching args 79 79 $this->assertEquals( $timestamp, wp_next_scheduled($hook, $args) ); 80 80 // these don't match so return nothing 81 81 $this->assertEquals( false, wp_next_scheduled($hook) ); 82 $this->assertEquals( false, wp_next_scheduled($hook, array( rand_str())) );82 $this->assertEquals( false, wp_next_scheduled($hook, array('bar')) ); 83 83 84 84 $this->assertEquals( $recur, wp_get_schedule($hook, $args) ); 85 85 -
tests/phpunit/tests/db/charset.php
543 543 $table_name = 'test_get_table_charset'; 544 544 545 545 $vars = array(); 546 foreach( $this->table_and_column_defs as $ value ) {547 $this_table_name = $table_name . '_' . rand_str( 5 );546 foreach( $this->table_and_column_defs as $i => $value ) { 547 $this_table_name = $table_name . '_' . $i; 548 548 $drop = "DROP TABLE IF EXISTS $this_table_name"; 549 549 $create = "CREATE TABLE $this_table_name {$value['definition']}"; 550 550 $vars[] = array( $drop, $create, $this_table_name, $value['table_expected'] ); … … 583 583 $table_name = 'test_get_column_charset'; 584 584 585 585 $vars = array(); 586 foreach( $this->table_and_column_defs as $ value ) {587 $this_table_name = $table_name . '_' . rand_str( 5 );586 foreach( $this->table_and_column_defs as $i => $value ) { 587 $this_table_name = $table_name . '_' . $i; 588 588 $drop = "DROP TABLE IF EXISTS $this_table_name"; 589 589 $create = "CREATE TABLE $this_table_name {$value['definition']}"; 590 590 $vars[] = array( $drop, $create, $this_table_name, $value['column_expected'] ); … … 687 687 ), 688 688 ); 689 689 690 foreach( $data as &$value ) {691 $this_table_name = $table_name . '_' . rand_str( 5 );690 foreach( $data as $i => &$value ) { 691 $this_table_name = $table_name . '_' . $i; 692 692 693 693 $value[0] = "CREATE TABLE $this_table_name {$value[0]}"; 694 694 $value[1] = "INSERT INTO $this_table_name VALUES {$value[1]}"; … … 801 801 ), 802 802 ); 803 803 804 foreach( $data as &$value ) {805 $this_table_name = $table_name . '_' . rand_str( 5 );804 foreach( $data as $i => &$value ) { 805 $this_table_name = $table_name . '_' . $i; 806 806 807 807 $value[0] = "CREATE TABLE $this_table_name {$value[0]}"; 808 808 $value[2] = "SELECT * FROM $this_table_name WHERE a='\xf0\x9f\x98\x88'"; -
tests/phpunit/tests/option/option.php
10 10 } 11 11 12 12 function test_the_basics() { 13 $key = rand_str();14 $key2 = rand_str();15 $value = rand_str();16 $value2 = rand_str();13 $key = 'key1'; 14 $key2 = 'key2'; 15 $value = 'value1'; 16 $value2 = 'value2'; 17 17 18 18 $this->assertFalse( get_option( 'doesnotexist' ) ); 19 19 $this->assertTrue( add_option( $key, $value ) ); … … 35 35 } 36 36 37 37 function test_default_filter() { 38 $ random = rand_str();38 $value = 'value'; 39 39 40 40 $this->assertFalse( get_option( 'doesnotexist' ) ); 41 41 … … 48 48 $this->assertEquals( 'bar', get_option( 'doesnotexist', 'bar' ) ); 49 49 50 50 // Once the option exists, the $default arg and the default filter are ignored. 51 add_option( 'doesnotexist', $ random);52 $this->assertEquals( $ random, get_option( 'doesnotexist', 'foo' ) );51 add_option( 'doesnotexist', $value ); 52 $this->assertEquals( $value, get_option( 'doesnotexist', 'foo' ) ); 53 53 add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); 54 $this->assertEquals( $ random, get_option( 'doesnotexist', 'foo' ) );54 $this->assertEquals( $value, get_option( 'doesnotexist', 'foo' ) ); 55 55 remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); 56 56 57 57 // Cleanup -
tests/phpunit/tests/option/siteOption.php
92 92 } 93 93 94 94 function test_update_site_option_returns_true_for_new_value() { 95 $key = rand_str();96 $value = rand_str();97 $new_value = rand_str();95 $key = 'key'; 96 $value = 'value1'; 97 $new_value = 'value2'; 98 98 add_site_option( $key, $value ); 99 99 $this->assertTrue( update_site_option( $key, $new_value ) ); 100 100 } -
tests/phpunit/tests/option/siteTransient.php
14 14 } 15 15 16 16 function test_the_basics() { 17 $key = rand_str();18 $value = rand_str();19 $value2 = rand_str();17 $key = 'key1'; 18 $value = 'value1'; 19 $value2 = 'value2'; 20 20 21 21 $this->assertFalse( get_site_transient( 'doesnotexist' ) ); 22 22 $this->assertTrue( set_site_transient( $key, $value ) ); -
tests/phpunit/tests/option/transient.php
14 14 } 15 15 16 16 function test_the_basics() { 17 $key = rand_str();18 $value = rand_str();19 $value2 = rand_str();17 $key = 'key1'; 18 $value = 'value1'; 19 $value2 = 'value2'; 20 20 21 21 $this->assertFalse( get_transient( 'doesnotexist' ) ); 22 22 $this->assertTrue( set_transient( $key, $value ) ); -
tests/phpunit/tests/query/results.php
456 456 * @ticket 16854 457 457 */ 458 458 function test_query_author_vars() { 459 $author_1 = self::factory()->user->create( array( 'user_login' => 'a dmin1', 'user_pass' => rand_str(), 'role' => 'author' ) );460 $post_1 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) );459 $author_1 = self::factory()->user->create( array( 'user_login' => 'author1', 'role' => 'author' ) ); 460 $post_1 = self::factory()->post->create( array( 'post_title' => 'Post 1', 'post_author' => $author_1, 'post_date' => '2007-01-01 00:00:00' ) ); 461 461 462 $author_2 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );463 $post_2 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) );462 $author_2 = self::factory()->user->create( array( 'user_login' => 'author2', 'role' => 'author' ) ); 463 $post_2 = self::factory()->post->create( array( 'post_title' => 'Post 2', 'post_author' => $author_2, 'post_date' => '2007-01-01 00:00:00' ) ); 464 464 465 $author_3 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );466 $post_3 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) );465 $author_3 = self::factory()->user->create( array( 'user_login' => 'author3', 'role' => 'author' ) ); 466 $post_3 = self::factory()->post->create( array( 'post_title' => 'Post 3', 'post_author' => $author_3, 'post_date' => '2007-01-01 00:00:00' ) ); 467 467 468 $author_4 = self::factory()->user->create( array( 'user_login' => rand_str(), 'user_pass' => rand_str(), 'role' => 'author' ) );469 $post_4 = self::factory()->post->create( array( 'post_title' => rand_str(), 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) );468 $author_4 = self::factory()->user->create( array( 'user_login' => 'author4', 'role' => 'author' ) ); 469 $post_4 = self::factory()->post->create( array( 'post_title' => 'Post 4', 'post_author' => $author_4, 'post_date' => '2007-01-01 00:00:00' ) ); 470 470 471 471 $posts = $this->q->query( array( 472 472 'author' => '', … … 549 549 $this->assertEqualSets( array( $author_3, $author_4 ), $author_ids ); 550 550 551 551 $posts = $this->q->query( array( 552 'author_name' => 'a dmin1',552 'author_name' => 'author1', 553 553 'post__in' => array( $post_1, $post_2, $post_3, $post_4 ) 554 554 ) ); 555 555 $author_ids = array_unique( wp_list_pluck( $posts, 'post_author' ) ); -
tests/phpunit/tests/term/getTerms.php
2291 2291 2292 2292 protected function set_up_three_posts_and_tags() { 2293 2293 $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) ); 2294 foreach ( $posts as $ post ) {2295 wp_set_object_terms( $post, rand_str(), 'post_tag' );2294 foreach ( $posts as $i => $post ) { 2295 wp_set_object_terms( $post, "term_{$i}", 'post_tag' ); 2296 2296 } 2297 2297 2298 2298 wp_cache_delete( 'last_changed', 'terms' ); -
tests/phpunit/tests/term/wpInsertTerm.php
10 10 _clean_term_filters(); 11 11 // insert one term into every post taxonomy 12 12 // otherwise term_ids and term_taxonomy_ids might be identical, which could mask bugs 13 $term = rand_str();13 $term = 'seed_term'; 14 14 foreach(get_object_taxonomies('post') as $tax) 15 15 wp_insert_term( $term, $tax ); 16 16 } … … 20 20 register_taxonomy( $taxonomy, 'post' ); 21 21 22 22 // a new unused term 23 $term = rand_str();23 $term = 'term'; 24 24 $this->assertNull( term_exists($term) ); 25 25 26 26 $initial_count = wp_count_terms( $taxonomy ); -
tests/phpunit/tests/term/wpSetObjectTerms.php
110 110 111 111 $terms = array(); 112 112 for ($i=0; $i<3; $i++ ) { 113 $term = rand_str();113 $term = "term_{$i}"; 114 114 $result = wp_insert_term( $term, $this->taxonomy ); 115 115 $this->assertInternalType( 'array', $result ); 116 116 $term_id[$term] = $result['term_id']; … … 245 245 // first set: 3 terms 246 246 $terms_1 = array(); 247 247 for ($i=0; $i<3; $i++ ) { 248 $term = rand_str();248 $term = "term_{$i}"; 249 249 $result = wp_insert_term( $term, $this->taxonomy ); 250 250 $this->assertInternalType( 'array', $result ); 251 251 $terms_1[$i] = $result['term_id']; … … 255 255 $terms_2 = array(); 256 256 $terms_2[0] = $terms_1[1]; 257 257 258 $term = rand_str();258 $term = 'term'; 259 259 $result = wp_insert_term( $term, $this->taxonomy ); 260 260 $terms_2[1] = $result['term_id']; 261 261 -
tests/phpunit/tests/user.php
103 103 104 104 // simple tests for usermeta functions 105 105 function test_usermeta() { 106 $key = rand_str();107 $val = rand_str();106 $key = 'key'; 107 $val = 'value1'; 108 108 109 109 // get a meta key that doesn't exist 110 110 $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) ); … … 114 114 $this->assertEquals( $val, get_user_meta( self::$author_id, $key, true ) ); 115 115 116 116 // change and get again 117 $val2 = rand_str();117 $val2 = 'value2'; 118 118 update_user_meta( self::$author_id, $key, $val2 ); 119 119 $this->assertEquals( $val2, get_user_meta( self::$author_id, $key, true ) ); 120 120 … … 578 578 */ 579 579 function test_user_update_email_error() { 580 580 $id1 = wp_insert_user( array( 581 'user_login' => rand_str(),581 'user_login' => 'blackburn', 582 582 'user_pass' => 'password', 583 583 'user_email' => 'blackburn@battlefield4.com', 584 584 ) ); 585 585 $this->assertEquals( $id1, email_exists( 'blackburn@battlefield4.com' ) ); 586 586 587 587 $id2 = wp_insert_user( array( 588 'user_login' => rand_str(),588 'user_login' => 'miller', 589 589 'user_pass' => 'password', 590 590 'user_email' => 'miller@battlefield4.com', 591 591 ) ); -
tests/phpunit/tests/xmlrpc/wp/getPosts.php
136 136 function test_search() { 137 137 $this->make_user_by_role( 'editor' ); 138 138 139 $post_ids[] = self::factory()->post->create( array( 'post_title' => 'First: ' . rand_str()) );140 $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Second: ' . rand_str()) );139 $post_ids[] = self::factory()->post->create( array( 'post_title' => 'First: Hello, World!' ) ); 140 $post_ids[] = self::factory()->post->create( array( 'post_title' => 'Second: Hello, World!' ) ); 141 141 142 142 // Search for none of them 143 $filter = array( 's' => rand_str());143 $filter = array( 's' => 'Third' ); 144 144 $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); 145 145 $this->assertNotInstanceOf( 'IXR_Error', $results ); 146 146 $this->assertEquals( 0, count( $results ) ); -
tests/phpunit/tests/xmlrpc/wp/getTerms.php
66 66 $num_terms = 12; 67 67 register_taxonomy( $tax_name, 'post' ); 68 68 for( $i = 0; $i < $num_terms; $i++ ) 69 wp_insert_term( rand_str( 10 ), $tax_name );69 wp_insert_term( "term_{$i}", $tax_name ); 70 70 71 71 72 72 // test fetching all terms -
tests/phpunit/tests/xmlrpc/wp/newPost.php
233 233 function test_terms() { 234 234 $this->make_user_by_role( 'editor' ); 235 235 236 $tag1 = wp_create_tag ( rand_str( 30 ));236 $tag1 = wp_create_tag( 'tag1' ); 237 237 $this->assertInternalType( 'array', $tag1 ); 238 $tag2 = wp_create_tag ( rand_str( 30 ));238 $tag2 = wp_create_tag( 'tag2' ); 239 239 $this->assertInternalType( 'array', $tag2 ); 240 $tag3 = wp_create_tag ( rand_str( 30 ));240 $tag3 = wp_create_tag( 'tag3' ); 241 241 $this->assertInternalType( 'array', $tag3 ); 242 242 243 243 $post = array( … … 258 258 function test_terms_names() { 259 259 $this->make_user_by_role( 'editor' ); 260 260 261 $ambiguous_name = rand_str( 30 );261 $ambiguous_name = 'foo'; 262 262 $parent_cat = wp_create_category( $ambiguous_name ); 263 263 $child_cat = wp_create_category( $ambiguous_name, $parent_cat ); 264 264 265 $cat1_name = rand_str( 30 );265 $cat1_name = 'cat1'; 266 266 $cat1 = wp_create_category( $cat1_name, $parent_cat ); 267 $cat2_name = rand_str( 30 );267 $cat2_name = 'cat2'; 268 268 269 269 // first a post with valid categories; one that already exists and one to be created 270 270 $post = array(