Making WordPress.org


Ignore:
Timestamp:
12/03/2017 05:28:28 PM (6 years ago)
Author:
iandunn
Message:

Events: Abstract the Core user agent check, to allow reuse.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/events/1.0/tests/test-index.php

    r6180 r6208  
    2222    $tests_failed += test_add_regional_wordcamps();
    2323    $tests_failed += test_build_response();
     24    $tests_failed += test_is_client_core();
    2425    $query_count  = count( $wpdb->queries );
    2526    $query_time   = array_sum( array_column( $wpdb->queries, 1 ) );
     
    10211022
    10221023/**
     1024 * Test `is_client_core()`.
     1025 *
     1026 * @return int
     1027 */
     1028function test_is_client_core() {
     1029    $failed = 0;
     1030    $cases  = array(
     1031        ''                                   => false,
     1032        'Contains WordPress but no slash'    => false,
     1033        'WordPress/4.9; https://example.org' => true,
     1034        'WordPress/10.0'                     => true,
     1035    );
     1036
     1037    printf( "\n\nRunning %d is_client_core() tests\n", count( $cases ) );
     1038
     1039    foreach ( $cases as $user_agent => $expected_result ) {
     1040        $actual_result = is_client_core( $user_agent );
     1041
     1042        $passed = $expected_result === $actual_result;
     1043
     1044        output_results( $user_agent, $passed, $expected_result, $actual_result );
     1045
     1046        if ( ! $passed ) {
     1047            $failed++;
     1048        }
     1049    }
     1050
     1051    return $failed;
     1052}
     1053
     1054/**
    10231055 * Test `add_regional_events()`
    10241056 *
Note: See TracChangeset for help on using the changeset viewer.