Changeset 38763
- Timestamp:
- 10/09/2016 01:29:04 AM (9 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/actions.php
r38571 r38763 10 10 function test_simple_action() { 11 11 $a = new MockAction(); 12 $tag = 'test_action';12 $tag = __FUNCTION__; 13 13 14 14 add_action($tag, array(&$a, 'action')); … … 27 27 function test_remove_action() { 28 28 $a = new MockAction(); 29 $tag = rand_str();29 $tag = __FUNCTION__; 30 30 31 31 add_action($tag, array(&$a, 'action')); … … 45 45 46 46 function test_has_action() { 47 $tag = rand_str();48 $func = rand_str();47 $tag = __FUNCTION__; 48 $func = __FUNCTION__ . '_func'; 49 49 50 50 $this->assertFalse( has_action($tag, $func) ); … … 62 62 $a1 = new MockAction(); 63 63 $a2 = new MockAction(); 64 $tag = rand_str();64 $tag = __FUNCTION__; 65 65 66 66 // add both actions to the hook … … 77 77 function test_action_args_1() { 78 78 $a = new MockAction(); 79 $tag = rand_str();80 $val = rand_str();79 $tag = __FUNCTION__; 80 $val = __FUNCTION__ . '_val'; 81 81 82 82 add_action($tag, array(&$a, 'action')); … … 93 93 $a1 = new MockAction(); 94 94 $a2 = new MockAction(); 95 $tag = rand_str();96 $val1 = rand_str();97 $val2 = rand_str();95 $tag = __FUNCTION__; 96 $val1 = __FUNCTION__ . '_val1'; 97 $val2 = __FUNCTION__ . '_val2'; 98 98 99 99 // a1 accepts two arguments, a2 doesn't … … 126 126 $a2 = new MockAction(); 127 127 $a3 = new MockAction(); 128 $tag = rand_str();129 $val1 = rand_str();130 $val2 = rand_str();128 $tag = __FUNCTION__; 129 $val1 = __FUNCTION__ . '_val1'; 130 $val2 = __FUNCTION__ . '_val2'; 131 131 132 132 // a1 accepts two arguments, a2 doesn't, a3 accepts two arguments … … 156 156 function test_action_priority() { 157 157 $a = new MockAction(); 158 $tag = rand_str();158 $tag = __FUNCTION__; 159 159 160 160 add_action($tag, array(&$a, 'action'), 10); … … 205 205 function test_all_action() { 206 206 $a = new MockAction(); 207 $tag1 = rand_str();208 $tag2 = rand_str();207 $tag1 = __FUNCTION__ . '_1'; 208 $tag2 = __FUNCTION__ . '_2'; 209 209 210 210 // add an 'all' action … … 229 229 function test_remove_all_action() { 230 230 $a = new MockAction(); 231 $tag = rand_str();231 $tag = __FUNCTION__; 232 232 233 233 add_action('all', array(&$a, 'action')); … … 250 250 $obj = new stdClass(); 251 251 $a = new MockAction(); 252 $tag = rand_str();252 $tag = __FUNCTION__; 253 253 254 254 add_action($tag, array(&$a, 'action')); … … 269 269 $a = new MockAction(); 270 270 271 $tag = rand_str();271 $tag = __FUNCTION__; 272 272 273 273 add_action($tag, array(&$a, 'action')); 274 274 275 $context = array( rand_str() => rand_str());275 $context = array( 'key1' => 'val1' ); 276 276 do_action($tag, $context); 277 277 … … 279 279 $this->assertSame($args[0][0], $context); 280 280 281 $context2 = array( rand_str() => rand_str(), rand_str() => rand_str());281 $context2 = array( 'key2' => 'val2', 'key3' => 'val3' ); 282 282 do_action($tag, $context2); 283 283 … … 301 301 */ 302 302 function test_action_recursion() { 303 $tag = rand_str();303 $tag = __FUNCTION__; 304 304 $a = new MockAction(); 305 305 $b = new MockAction(); … … 328 328 */ 329 329 function test_action_callback_manipulation_while_running() { 330 $tag = rand_str();330 $tag = __FUNCTION__; 331 331 $a = new MockAction(); 332 332 $b = new MockAction(); … … 363 363 */ 364 364 function test_remove_anonymous_callback() { 365 $tag = rand_str();365 $tag = __FUNCTION__; 366 366 $a = new MockAction(); 367 367 add_action( $tag, array( $a, 'action' ), 12, 1 ); … … 397 397 function test_array_access_of_wp_filter_global() { 398 398 global $wp_filter; 399 $tag = rand_str();399 $tag = __FUNCTION__; 400 400 401 401 add_action( $tag, '__return_null', 11, 1 ); -
trunk/tests/phpunit/tests/actions/closures.php
r25002 r38763 18 18 $this->assertSame( 10, has_action($tag, $closure) ); 19 19 20 $context = array( rand_str(), rand_str());20 $context = array( 'val1', 'val2' ); 21 21 do_action($tag, $context[0], $context[1]); 22 22 -
trunk/tests/phpunit/tests/admin/includesScreen.php
r38382 r38763 155 155 156 156 function test_help_tabs() { 157 $tab = rand_str();157 $tab = __FUNCTION__; 158 158 $tab_args = array( 159 159 'id' => $tab, … … 279 279 */ 280 280 function test_options() { 281 $option = rand_str();281 $option = __FUNCTION__; 282 282 $option_args = array( 283 283 'label' => 'Option', -
trunk/tests/phpunit/tests/cache.php
r37954 r38763 28 28 29 29 function test_miss() { 30 $this->assertEquals( NULL, $this->cache->get(rand_str()));30 $this->assertEquals( NULL, $this->cache->get( 'test_miss' ) ); 31 31 } 32 32 33 33 function test_add_get() { 34 $key = rand_str();35 $val = rand_str();34 $key = __FUNCTION__; 35 $val = 'val'; 36 36 37 37 $this->cache->add($key, $val); … … 40 40 41 41 function test_add_get_0() { 42 $key = rand_str();42 $key = __FUNCTION__; 43 43 $val = 0; 44 44 … … 49 49 50 50 function test_add_get_null() { 51 $key = rand_str();51 $key = __FUNCTION__; 52 52 $val = null; 53 53 … … 58 58 59 59 function test_add() { 60 $key = rand_str();61 $val1 = rand_str();62 $val2 = rand_str();60 $key = __FUNCTION__; 61 $val1 = 'val1'; 62 $val2 = 'val2'; 63 63 64 64 // add $key to the cache … … 71 71 72 72 function test_replace() { 73 $key = rand_str();74 $val = rand_str();75 $val2 = rand_str();73 $key = __FUNCTION__; 74 $val = 'val1'; 75 $val2 = 'val2'; 76 76 77 77 // memcached rejects replace() if the key does not exist … … 85 85 86 86 function test_set() { 87 $key = rand_str();88 $val1 = rand_str();89 $val2 = rand_str();87 $key = __FUNCTION__; 88 $val1 = 'val1'; 89 $val2 = 'val2'; 90 90 91 91 // memcached accepts set() if the key does not exist … … 103 103 return; 104 104 105 $key = rand_str();106 $val = rand_str();105 $key = __FUNCTION__; 106 $val = 'val'; 107 107 108 108 $this->cache->add($key, $val); … … 116 116 // Make sure objects are cloned going to and from the cache 117 117 function test_object_refs() { 118 $key = rand_str();118 $key = __FUNCTION__ . '_1'; 119 119 $object_a = new stdClass; 120 120 $object_a->foo = 'alpha'; … … 126 126 $this->assertEquals( 'bravo', $object_a->foo ); 127 127 128 $key = rand_str();128 $key = __FUNCTION__ . '_2'; 129 129 $object_a = new stdClass; 130 130 $object_a->foo = 'alpha'; … … 138 138 139 139 function test_incr() { 140 $key = rand_str();140 $key = __FUNCTION__; 141 141 142 142 $this->assertFalse( $this->cache->incr( $key ) ); … … 151 151 152 152 function test_wp_cache_incr() { 153 $key = rand_str();153 $key = __FUNCTION__; 154 154 155 155 $this->assertFalse( wp_cache_incr( $key ) ); … … 164 164 165 165 function test_decr() { 166 $key = rand_str();166 $key = __FUNCTION__; 167 167 168 168 $this->assertFalse( $this->cache->decr( $key ) ); … … 184 184 */ 185 185 function test_wp_cache_decr() { 186 $key = rand_str();186 $key = __FUNCTION__; 187 187 188 188 $this->assertFalse( wp_cache_decr( $key ) ); … … 201 201 202 202 function test_delete() { 203 $key = rand_str();204 $val = rand_str();203 $key = __FUNCTION__; 204 $val = 'val'; 205 205 206 206 // Verify set … … 216 216 217 217 function test_wp_cache_delete() { 218 $key = rand_str();219 $val = rand_str();218 $key = __FUNCTION__; 219 $val = 'val'; 220 220 221 221 // Verify set … … 238 238 return; 239 239 240 $key = rand_str();241 $val = rand_str();242 $val2 = rand_str();240 $key = __FUNCTION__; 241 $val = 'val1'; 242 $val2 = 'val2'; 243 243 244 244 if ( ! is_multisite() ) { -
trunk/tests/phpunit/tests/comment-submission.php
r36272 r38763 623 623 $data = array( 624 624 'comment_post_ID' => $post->ID, 625 'comment' => rand_str(),625 'comment' => 'Comment', 626 626 'author' => rand_long_str( 255 ), 627 627 'email' => 'comment@example.org', … … 643 643 $data = array( 644 644 'comment_post_ID' => $post->ID, 645 'comment' => rand_str(),645 'comment' => 'Comment', 646 646 'author' => 'Comment Author', 647 647 'email' => rand_long_str( 90 ) . '@example.com', … … 662 662 $data = array( 663 663 'comment_post_ID' => $post->ID, 664 'comment' => rand_str(),664 'comment' => 'Comment', 665 665 'author' => 'Comment Author', 666 666 'email' => 'comment@example.org', -
trunk/tests/phpunit/tests/comment.php
r38398 r38763 128 128 $data = array( 129 129 'comment_post_ID' => self::$post_id, 130 'comment_author' => rand_str(),130 'comment_author' => 'Comment Author', 131 131 'comment_author_url' => '', 132 132 'comment_author_email' => '', 133 133 'comment_type' => '', 134 'comment_content' => rand_str(),134 'comment_content' => 'Comment', 135 135 'comment_date' => '2011-01-01 10:00:00', 136 136 'comment_date_gmt' => '2011-01-01 10:00:00', … … 151 151 $data = array( 152 152 'comment_post_ID' => self::$post_id, 153 'comment_author' => rand_str(),153 'comment_author' => 'Comment Author', 154 154 'comment_author_IP' => '192.168.1.1', 155 155 'comment_author_url' => '', 156 156 'comment_author_email' => '', 157 157 'comment_type' => '', 158 'comment_content' => rand_str(),158 'comment_content' => 'Comment', 159 159 ); 160 160 … … 172 172 $data = array( 173 173 'comment_post_ID' => self::$post_id, 174 'comment_author' => rand_str(),174 'comment_author' => 'Comment Author', 175 175 'comment_author_IP' => '', 176 176 'comment_author_url' => '', 177 177 'comment_author_email' => '', 178 178 'comment_type' => '', 179 'comment_content' => rand_str(),179 'comment_content' => 'Comment', 180 180 ); 181 181 … … 193 193 $data = array( 194 194 'comment_post_ID' => self::$post_id, 195 'comment_author' => rand_str(),195 'comment_author' => 'Comment Author', 196 196 'comment_author_IP' => '', 197 197 'comment_author_url' => '', … … 199 199 'comment_agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53', 200 200 'comment_type' => '', 201 'comment_content' => rand_str(),201 'comment_content' => 'Comment', 202 202 ); 203 203 … … 215 215 $data = array( 216 216 'comment_post_ID' => self::$post_id, 217 'comment_author' => rand_str(),217 'comment_author' => 'Comment Author', 218 218 'comment_author_IP' => '', 219 219 'comment_author_url' => '', … … 221 221 'comment_agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.4pre) Gecko/20070511 Camino/1.6pre', 222 222 'comment_type' => '', 223 'comment_content' => rand_str(),223 'comment_content' => 'Comment', 224 224 ); 225 225 … … 237 237 $data = array( 238 238 'comment_post_ID' => self::$post_id, 239 'comment_author' => rand_str(),239 'comment_author' => 'Comment Author', 240 240 'comment_author_IP' => '', 241 241 'comment_author_url' => '', … … 243 243 'comment_agent' => '', 244 244 'comment_type' => '', 245 'comment_content' => rand_str(),245 'comment_content' => 'Comment', 246 246 ); 247 247 … … 257 257 $data = array( 258 258 'comment_post_ID' => self::$post_id, 259 'comment_author' => rand_str(),259 'comment_author' => 'Comment Author', 260 260 'comment_author_url' => '', 261 261 'comment_author_email' => '', … … 539 539 $data = array( 540 540 'comment_post_ID' => $post, 541 'comment_author' => rand_str(),541 'comment_author' => 'Comment Author', 542 542 'comment_author_url' => '', 543 543 'comment_author_email' => '', 544 544 'comment_type' => '', 545 'comment_content' => rand_str(),545 'comment_content' => 'Comment', 546 546 ); 547 547 wp_new_comment( $data ); … … 589 589 $data = array( 590 590 'comment_post_ID' => $post, 591 'comment_author' => rand_str(),591 'comment_author' => 'Comment Author', 592 592 'comment_author_url' => '', 593 593 'comment_author_email' => '', 594 594 'comment_type' => '', 595 'comment_content' => rand_str(),595 'comment_content' => 'Comment', 596 596 ); 597 597 wp_new_comment( $data ); … … 639 639 $default_data = array( 640 640 'comment_post_ID' => self::$post_id, 641 'comment_author' => rand_str(),641 'comment_author' => 'Comment Author', 642 642 'comment_author_IP' => '192.168.0.1', 643 643 'comment_agent' => 'WRONG_AGENT', … … 645 645 'comment_author_email' => '', 646 646 'comment_type' => '', 647 'comment_content' => rand_str(),647 'comment_content' => 'Comment', 648 648 ); 649 649 -
trunk/tests/phpunit/tests/comment/getCommentAuthorEmailLink.php
r38398 r38763 41 41 unset( $GLOBALS['comment'] ); 42 42 43 $linktext = rand_str( 10 );44 $before = rand_str( 5 );45 $after = rand_str( 6 );43 $linktext = 'linktext'; 44 $before = 'before'; 45 $after = 'after'; 46 46 $comment = self::factory()->comment->create_and_get( array( 47 47 'comment_author_email' => $email = 'baz@example.org' … … 54 54 55 55 public function test_all_parameters_with_global_comment() { 56 $linktext = rand_str( 10 );57 $before = rand_str( 5 );58 $after = rand_str( 6 );56 $linktext = 'linktext'; 57 $before = 'before'; 58 $after = 'after'; 59 59 60 60 $expected = sprintf( '%1$s<a href="mailto:foo@example.org">%2$s</a>%3$s', $before, $linktext, $after ); … … 64 64 65 65 public function test_linktext() { 66 $expected = sprintf( '<a href="mailto:foo@example.org">%1$s</a>', $linktext = rand_str( 12 ));66 $expected = sprintf( '<a href="mailto:foo@example.org">%1$s</a>', $linktext = 'linktext' ); 67 67 68 68 $this->assertEquals( $expected, get_comment_author_email_link( $linktext ) ); … … 70 70 71 71 public function test_before() { 72 $expected = sprintf( '%1$s<a href="mailto:foo@example.org">foo@example.org</a>', $before = rand_str( 5 ));72 $expected = sprintf( '%1$s<a href="mailto:foo@example.org">foo@example.org</a>', $before = 'before' ); 73 73 74 74 $this->assertEquals( $expected, get_comment_author_email_link( '', $before ) ); … … 76 76 77 77 public function test_after() { 78 $expected = sprintf( '<a href="mailto:foo@example.org">foo@example.org</a>%1$s', $after = rand_str( 5 ));78 $expected = sprintf( '<a href="mailto:foo@example.org">foo@example.org</a>%1$s', $after = 'after' ); 79 79 80 80 $this->assertEquals( $expected, get_comment_author_email_link( '', '', $after ) ); -
trunk/tests/phpunit/tests/cron.php
r38382 r38763 21 21 function test_wp_get_schedule_empty() { 22 22 // nothing scheduled 23 $hook = rand_str();23 $hook = __FUNCTION__; 24 24 $this->assertFalse(wp_get_schedule($hook)); 25 25 } … … 27 27 function test_schedule_event_single() { 28 28 // schedule an event and make sure it's returned by wp_next_scheduled 29 $hook = rand_str();29 $hook = __FUNCTION__; 30 30 $timestamp = strtotime('+1 hour'); 31 31 … … 57 57 function test_schedule_event() { 58 58 // schedule an event and make sure it's returned by wp_next_scheduled 59 $hook = rand_str();59 $hook = __FUNCTION__; 60 60 $recur = 'hourly'; 61 61 $timestamp = strtotime('+1 hour'); … … 88 88 function test_unschedule_event() { 89 89 // schedule an event and make sure it's returned by wp_next_scheduled 90 $hook = rand_str();90 $hook = __FUNCTION__; 91 91 $timestamp = strtotime('+1 hour'); 92 92 … … 100 100 101 101 function test_clear_schedule() { 102 $hook = rand_str();103 $args = array( rand_str());102 $hook = __FUNCTION__; 103 $args = array( 'arg1' ); 104 104 105 105 // schedule several events with and without arguments … … 126 126 127 127 function test_clear_schedule_multiple_args() { 128 $hook = rand_str();129 $args = array( rand_str(), rand_str());128 $hook = __FUNCTION__; 129 $args = array( 'arg1', 'arg2' ); 130 130 131 131 // schedule several events with and without arguments … … 155 155 */ 156 156 function test_clear_schedule_new_args() { 157 $hook = rand_str();158 $args = array( rand_str());159 $multi_hook = rand_str();160 $multi_args = array( rand_str(), rand_str());157 $hook = __FUNCTION__; 158 $args = array( 'arg1' ); 159 $multi_hook = __FUNCTION__ . '_multi'; 160 $multi_args = array( 'arg2', 'arg3' ); 161 161 162 162 // schedule several events with and without arguments … … 195 195 function test_duplicate_event() { 196 196 // duplicate events close together should be skipped 197 $hook = rand_str();198 $args = array( rand_str());197 $hook = __FUNCTION__; 198 $args = array( 'arg1' ); 199 199 $ts1 = strtotime('+5 minutes'); 200 200 $ts2 = strtotime('+3 minutes'); … … 214 214 function test_not_duplicate_event() { 215 215 // duplicate events far apart should work normally 216 $hook = rand_str();217 $args = array( rand_str());216 $hook = __FUNCTION__; 217 $args = array( 'arg1' ); 218 218 $ts1 = strtotime( '+30 minutes' ); 219 219 $ts2 = strtotime( '+3 minutes' ); … … 233 233 function test_not_duplicate_event_reversed() { 234 234 // duplicate events far apart should work normally regardless of order 235 $hook = rand_str();236 $args = array( rand_str());235 $hook = __FUNCTION__; 236 $args = array( 'arg1' ); 237 237 $ts1 = strtotime( '+3 minutes' ); 238 238 $ts2 = strtotime( '+30 minutes' ); … … 275 275 function test_run_schedule_single() { 276 276 // schedule an event, run it, and make sure the hook is called 277 $hook = rand_str();277 $hook = __FUNCTION__; 278 278 $args = array(rand_str()); 279 279 $timestamp = strtotime('-1 second'); … … 301 301 function test_run_schedule_recurring() { 302 302 // schedule a recurring event, run it, and make sure the hook is called 303 $hook = rand_str();303 $hook = __FUNCTION__; 304 304 $args = array(rand_str()); 305 305 $timestamp = strtotime('-1 second'); -
trunk/tests/phpunit/tests/customize/setting.php
r37982 r38763 481 481 $type = 'option'; 482 482 $name = 'blogname'; 483 $post_value = rand_str();483 $post_value = __FUNCTION__; 484 484 $this->manager->set_post_value( $name, $post_value ); 485 485 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) ); … … 505 505 $type = 'option'; 506 506 $name = 'blogdescription'; 507 $post_value = rand_str();507 $post_value = __FUNCTION__; 508 508 $this->manager->set_post_value( $name, $post_value ); 509 509 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type' ) );
Note: See TracChangeset
for help on using the changeset viewer.