- Timestamp:
- 05/17/2017 08:30:29 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
r5496 r5497 19 19 $tests_failed = 0; 20 20 $tests_failed += test_get_location(); 21 $tests_failed += test_get_city_from_coordinates();22 21 $query_count = count( $wpdb->queries ); 23 22 $query_time = array_sum( array_column( $wpdb->queries, 1 ) ); … … 698 697 ), 699 698 'expected' => array( 700 'description' => 'seattle',699 'description' => false, 701 700 'latitude' => '47.606', 702 701 'longitude' => '-122.332', … … 713 712 ), 714 713 'expected' => array( 715 'description' => 'otavi',714 'description' => false, 716 715 'latitude' => '-19.634', 717 716 'longitude' => '17.332', … … 792 791 } 793 792 794 /**795 * Test `get_city_from_coordinates()`796 *797 * @todo This can probably be refactored along with test_get_location() into a more abstract/DRY general-purpose798 * test runner.799 *800 * @return bool The number of failures801 */802 function test_get_city_from_coordinates() {803 $failed = 0;804 $cases = get_city_from_coordinates_test_cases();805 806 printf( "\n\nRunning %d city from coordinate tests\n", count( $cases ) );807 808 foreach ( $cases as $case_id => $case ) {809 $case['input'] = add_cachebusting_parameter( $case['input'] );810 $actual_result = get_city_from_coordinates( $case['input']['latitude'], $case['input']['longitude'] );811 $passed = $case['expected'] === $actual_result;812 813 output_results( $case_id, $passed, $case['expected'], $actual_result );814 815 if ( ! $passed ) {816 $failed++;817 }818 }819 820 return $failed;821 }822 823 /**824 * Get the cases for testing `get_city_from_coordinates()`825 *826 * @return array827 */828 function get_city_from_coordinates_test_cases() {829 $cases = array(830 'lower-latitude-higher-longitude' => array(831 'input' => array(832 'latitude' => '60.199',833 'longitude' => '24.660'834 ),835 'expected' => 'Espoo',836 ),837 838 'higher-latitude-lower-longitude' => array(839 'input' => array(840 'latitude' => '22.000',841 'longitude' => '95.900'842 ),843 'expected' => 'Mandalay',844 ),845 846 'middle-of-no-and-where' => array(847 'input' => array(848 'latitude' => '-23.121',849 'longitude' => '125.071'850 ),851 'expected' => false,852 ),853 );854 855 return $cases;856 }857 858 793 run_tests();
Note: See TracChangeset
for help on using the changeset viewer.