- Timestamp:
- 11/06/2017 09:03:28 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php
r6076 r6078 20 20 $tests_failed += test_get_location(); 21 21 $tests_failed += test_get_events(); 22 $tests_failed += test_add_regional_wordcamps(); 22 23 $tests_failed += test_build_response(); 23 24 $query_count = count( $wpdb->queries ); … … 1019 1020 1020 1021 /** 1022 * Test `add_regional_events()` 1023 * 1024 * @return int 1025 */ 1026 function test_add_regional_wordcamps() { 1027 $failed = 0; 1028 1029 $local_events = get_events( array( 1030 'number' => '5', 1031 'nearby' => array( 1032 'latitude' => '-33.849951', 1033 'longitude' => '18.426246', 1034 ), 1035 ) ); 1036 1037 // Make sure there's at least one event, otherwise there could be false positives. 1038 if ( ! $local_events ) { 1039 $local_events[] = array( 'title' => 'Mock Event' ); 1040 } 1041 1042 printf( "\n\nRunning %d add_regional_wordcamps() tests\n", 2 ); 1043 1044 // Test that no changes were made if the user agent isn't Core. 1045 $events_no_user_agent = add_regional_wordcamps( $local_events, '' ); 1046 1047 if ( $events_no_user_agent !== $local_events ) { 1048 $failed++; 1049 output_results( 'no-user-agent', false, $local_events, $events_no_user_agent ); 1050 } 1051 1052 /* 1053 * Test that local events were unharmed if the user agent is Core. 1054 * 1055 * There isn't an easy way to mock time(), so this doesn't test that the events were added 1056 * correctly. It just makes sure that local events weren't removed. 1057 */ 1058 $events_core_user_agent = add_regional_wordcamps( $local_events, 'WordPress/4.9; https://example.org' ); 1059 1060 if ( 1061 count( $events_core_user_agent ) < count( $local_events ) || 1062 ! in_array( $local_events[0], $events_core_user_agent, true ) 1063 ) { 1064 $failed++; 1065 output_results( 'core-user-agent', false, 'local events were not affected', $events_core_user_agent ); 1066 } 1067 1068 return $failed; 1069 } 1070 1071 /** 1021 1072 * Stub to simulate cache misses, so that the tests always get fresh results 1022 1073 *
Note: See TracChangeset
for help on using the changeset viewer.