Making WordPress.org

Changeset 6262


Ignore:
Timestamp:
12/13/2017 07:27:11 PM (7 years ago)
Author:
danielbachhuber
Message:

phpunit-test-reporter: Clean up formatting with phpcbf

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/parts/result-set.php

    r5806 r6262  
    2525            </tr>
    2626            <?php
    27             $query_args = array(
    28                 'posts_per_page'   => 10,
    29                 'post_type'        => 'result',
    30                 'post_parent'      => $revision->ID,
    31                 'orderby'          => 'post_title',
    32                 'order'            => 'ASC',
     27            $query_args   = array(
     28                'posts_per_page' => 10,
     29                'post_type'      => 'result',
     30                'post_parent'    => $revision->ID,
     31                'orderby'        => 'post_title',
     32                'order'          => 'ASC',
    3333            );
    3434            $report_query = new WP_Query( $query_args );
    3535            if ( ! empty( $report_query->posts ) ) :
    3636                foreach ( $report_query->posts as $report ) :
    37                     $status = 'Errored';
     37                    $status       = 'Errored';
    3838                    $status_title = 'No results found for test.';
    39                     $results = get_post_meta( $report->ID, 'results', true );
     39                    $results      = get_post_meta( $report->ID, 'results', true );
    4040                    if ( isset( $results['failures'] ) ) {
    41                         $status = 0 === (int) $results['failures'] && 0 === (int) $results['errors'] ? 'Passed' : 'Failed';
     41                        $status       = 0 === (int) $results['failures'] && 0 === (int) $results['errors'] ? 'Passed' : 'Failed';
    4242                        $status_title = (int) $results['tests'] . ' tests, ' . (int) $results['failures'] . ' failed, ' . (int) $results['errors'] . ' errors';
    4343                    }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/parts/single-result.php

    r5806 r6262  
    22use PTR\Display;
    33
    4 $status = 'Errored';
     4$status       = 'Errored';
    55$status_title = 'No results found for test.';
    6 $results = get_post_meta( $report->ID, 'results', true );
     6$results      = get_post_meta( $report->ID, 'results', true );
    77if ( isset( $results['failures'] ) ) {
    8     $status = 0 === (int) $results['failures'] && 0 === (int) $results['errors'] ? 'Passed' : 'Failed';
     8    $status       = 0 === (int) $results['failures'] && 0 === (int) $results['errors'] ? 'Passed' : 'Failed';
    99    $status_title = (int) $results['tests'] . ' tests, ' . (int) $results['failures'] . ' failed, ' . (int) $results['errors'] . ' errors';
    1010}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/readme.txt

    r5828 r6262  
    1414Captures and displays test results from the PHPUnit Test Runner
    1515
     16For more details, [please read through the project overview](https://make.wordpress.org/hosting/test-results-getting-started/).
     17
    1618== Changelog ==
    1719
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-content-model.php

    r5806 r6262  
    1010     */
    1111    public static function action_init_register_post_type() {
    12         register_post_type( 'result',
     12        register_post_type(
     13            'result',
    1314            array(
    14                 'labels' => array(
    15                     'name' => __( 'Test Results', 'ptr' ),
     15                'labels'       => array(
     16                    'name'          => __( 'Test Results', 'ptr' ),
    1617                    'singular_name' => __( 'Test Result', 'ptr' ),
    1718                ),
    18                 'public' => true,
    19                 'has_archive' => false,
     19                'public'       => true,
     20                'has_archive'  => false,
    2021                'show_in_rest' => true,
    2122                'hierarchical' => true,
    22                 'rewrite' => array(
     23                'rewrite'      => array(
    2324                    'slug' => 'test-results',
    2425                ),
    25                 'supports' => array(
     26                'supports'     => array(
    2627                    'title',
    2728                    'editor',
     
    3233                'map_meta_cap' => true,
    3334                'capabilities' => array(
    34                     'edit_post' => 'edit_result',
    35                     'edit_posts' => 'edit_results',
    36                     'edit_others_posts' => 'edit_others_results',
    37                     'publish_posts' => 'publish_results',
    38                     'read_post' => 'read_result',
     35                    'edit_post'          => 'edit_result',
     36                    'edit_posts'         => 'edit_results',
     37                    'edit_others_posts'  => 'edit_others_results',
     38                    'publish_posts'      => 'publish_results',
     39                    'read_post'          => 'read_result',
    3940                    'read_private_posts' => 'read_private_results',
    40                     'delete_post' => 'delete_result',
     41                    'delete_post'        => 'delete_result',
    4142                ),
    4243            )
     
    4950    public static function action_init_register_role() {
    5051        if ( ! get_role( 'test-reporter' ) ) {
    51             add_role( 'test-reporter', __( 'Test Reporter', 'ptr' ), array(
    52                 'read' => true,
    53             ) );
     52            add_role(
     53                'test-reporter', __( 'Test Reporter', 'ptr' ), array(
     54                    'read' => true,
     55                )
     56            );
    5457        }
    5558        $role = get_role( 'test-reporter' );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-display.php

    r5833 r6262  
    2222            return $check;
    2323        }
    24         $template = 'page-templates/full-width.php';
     24        $template   = 'page-templates/full-width.php';
    2525        $full_width = get_stylesheet_directory() . '/' . $template;
    2626        if ( ! file_exists( $full_width ) ) {
     
    6767
    6868        if ( get_queried_object()->post_parent ) {
    69             $content = ptr_get_template_part( 'single-result', array(
    70                 'report' => get_queried_object(),
    71             ) );
     69            $content = ptr_get_template_part(
     70                'single-result', array(
     71                    'report' => get_queried_object(),
     72                )
     73            );
    7274        } else {
    73             $content = ptr_get_template_part( 'result-set', array(
    74                 'revisions' => array(
    75                     get_queried_object(),
    76                 ),
    77             ) );
     75            $content = ptr_get_template_part(
     76                'result-set', array(
     77                    'revisions' => array(
     78                        get_queried_object(),
     79                    ),
     80                )
     81            );
    7882            $content = '<p><a href="' . esc_url( home_url( 'test-results/' ) ) . '">&larr; Test Results</a></p>' . PHP_EOL . PHP_EOL . $content;
    7983        }
     
    8791    public static function render_results( $atts ) {
    8892
    89         $output = '';
     93        $output     = '';
    9094        $query_args = array(
    91             'posts_per_page'   => 5,
    92             'post_type'        => 'result',
    93             'post_parent'      => 0,
    94             'orderby'          => 'post_name',
    95             'order'            => 'DESC',
     95            'posts_per_page' => 5,
     96            'post_type'      => 'result',
     97            'post_parent'    => 0,
     98            'orderby'        => 'post_name',
     99            'order'          => 'DESC',
    96100        );
    97         $paged = isset( $_GET['rpage'] ) ? (int) $_GET['rpage'] : 0;
     101        $paged      = isset( $_GET['rpage'] ) ? (int) $_GET['rpage'] : 0;
    98102        if ( $paged ) {
    99103            $query_args['paged'] = $paged;
     
    105109        }
    106110        $output .= self::get_display_css();
    107         $output .= ptr_get_template_part( 'result-set', array(
    108             'revisions' => $rev_query->posts,
    109         ) );
     111        $output .= ptr_get_template_part(
     112            'result-set', array(
     113                'revisions' => $rev_query->posts,
     114            )
     115        );
    110116        ob_start();
    111117        self::pagination( $rev_query );
     
    182188    public static function get_display_php_version( $report_id ) {
    183189        $php_version = 'Unknown';
    184         $env = get_post_meta( $report_id, 'env', true );
     190        $env         = get_post_meta( $report_id, 'env', true );
    185191        if ( ! empty( $env['php_version'] ) ) {
    186192            $php_version = 'PHP ' . $env['php_version'];
     
    197203    public static function get_display_mysql_version( $report_id ) {
    198204        $mysql_version = 'Unknown';
    199         $env = get_post_meta( $report_id, 'env', true );
     205        $env           = get_post_meta( $report_id, 'env', true );
    200206        if ( ! empty( $env['mysql_version'] ) ) {
    201             $bits = explode( ',', $env['mysql_version'] );
     207            $bits          = explode( ',', $env['mysql_version'] );
    202208            $mysql_version = $bits[0];
    203209        }
     
    213219    public static function get_display_extensions( $report_id ) {
    214220        $extensions = array();
    215         $env = get_post_meta( $report_id, 'env', true );
     221        $env        = get_post_meta( $report_id, 'env', true );
    216222        if ( ! empty( $env['php_modules'] ) ) {
    217223            foreach ( $env['php_modules'] as $module => $version ) {
     
    233239    private static function pagination( $query ) {
    234240        global $wp;
    235         $bignum = 999999999;
    236         $base_link = add_query_arg( 'rpage', '%#%', home_url( trailingslashit( $wp->request ) ) );
    237         $max_num_pages = $query->max_num_pages;
    238         $current_page = max( 1, $query->get( 'paged' ) );
     241        $bignum          = 999999999;
     242        $base_link       = add_query_arg( 'rpage', '%#%', home_url( trailingslashit( $wp->request ) ) );
     243        $max_num_pages   = $query->max_num_pages;
     244        $current_page    = max( 1, $query->get( 'paged' ) );
    239245        $prev_page_label = '&lsaquo;';
    240246        $next_page_label = '&rsaquo;';
    241         $args = array(
    242             'base'          => $base_link,
    243             'format'        => '',
    244             'current'       => $current_page,
    245             'total'         => $max_num_pages,
    246             'prev_text'     => $prev_page_label,
    247             'next_text'     => $next_page_label,
    248             'type'          => 'array',
    249             'end_size'      => 1,
    250             'mid_size'      => 2,
     247        $args            = array(
     248            'base'      => $base_link,
     249            'format'    => '',
     250            'current'   => $current_page,
     251            'total'     => $max_num_pages,
     252            'prev_text' => $prev_page_label,
     253            'next_text' => $next_page_label,
     254            'type'      => 'array',
     255            'end_size'  => 1,
     256            'mid_size'  => 2,
    251257        );
    252258
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-restapi.php

    r5825 r6262  
    1414        register_rest_route(
    1515            'wp-unit-test-api/v1', 'results', array(
    16                 'methods' => 'POST',
    17                 'callback' => array( __CLASS__, 'add_results_callback' ),
    18                 'args' => array(
    19                     'commit' => array(
    20                         'required' => true,
    21                         'description' => 'The SVN commit changeset number.',
    22                         'type' => 'numeric',
     16                'methods'             => 'POST',
     17                'callback'            => array( __CLASS__, 'add_results_callback' ),
     18                'args'                => array(
     19                    'commit'  => array(
     20                        'required'          => true,
     21                        'description'       => 'The SVN commit changeset number.',
     22                        'type'              => 'numeric',
    2323                        'validate_callback' => array( __CLASS__, 'validate_callback' ),
    2424                    ),
    2525                    'results' => array(
    26                         'required' => true,
    27                         'description' => 'phpunit results in JSON format.',
    28                         'type' => 'string',
     26                        'required'          => true,
     27                        'description'       => 'phpunit results in JSON format.',
     28                        'type'              => 'string',
    2929                        'validate_callback' => array( __CLASS__, 'validate_callback' ),
    3030                    ),
    3131                    'message' => array(
    32                         'required' => true,
    33                         'description' => 'The SVN commit message.',
    34                         'type' => 'string',
     32                        'required'          => true,
     33                        'description'       => 'The SVN commit message.',
     34                        'type'              => 'string',
    3535                        'validate_callback' => array( __CLASS__, 'validate_callback' ),
    3636                    ),
    37                     'env' => array(
    38                         'required' => true,
    39                         'description' => 'JSON blob containing information about the environment.',
    40                         'type' => 'string',
     37                    'env'     => array(
     38                        'required'          => true,
     39                        'description'       => 'JSON blob containing information about the environment.',
     40                        'type'              => 'string',
    4141                        'validate_callback' => array( __CLASS__, 'validate_callback' ),
    4242                    ),
     
    5151            case 'commit':
    5252                if ( ! is_numeric( $value ) ) {
    53                     return new WP_Error( 'rest_invalid', __( 'Value must be numeric.', 'ptr' ), array(
    54                         'status' => 400,
    55                     ) );
     53                    return new WP_Error(
     54                        'rest_invalid', __( 'Value must be numeric.', 'ptr' ), array(
     55                            'status' => 400,
     56                        )
     57                    );
    5658                }
    5759                return true;
    5860            case 'message':
    5961                if ( empty( $value ) || ! is_string( $value ) ) {
    60                     return new WP_Error( 'rest_invalid', __( 'Value must be a non-empty string.', 'ptr' ), array(
    61                         'status' => 400,
    62                     ) );
     62                    return new WP_Error(
     63                        'rest_invalid', __( 'Value must be a non-empty string.', 'ptr' ), array(
     64                            'status' => 400,
     65                        )
     66                    );
    6367                }
    6468                return true;
     
    6670            case 'results':
    6771                if ( null === json_decode( $value ) ) {
    68                     return new WP_Error( 'rest_invalid', __( 'Value must be encoded JSON.', 'ptr' ), array(
    69                         'status' => 400,
    70                     ) );
     72                    return new WP_Error(
     73                        'rest_invalid', __( 'Value must be encoded JSON.', 'ptr' ), array(
     74                            'status' => 400,
     75                        )
     76                    );
    7177                }
    7278                return true;
    7379        }
    74         return new WP_Error( 'rest_invalid', __( 'Invalid key specified.', 'ptr' ), array(
    75             'status' => 400,
    76         ) );
     80        return new WP_Error(
     81            'rest_invalid', __( 'Invalid key specified.', 'ptr' ), array(
     82                'status' => 400,
     83            )
     84        );
    7785    }
    7886
    7987    public static function permission() {
    8088        if ( ! current_user_can( 'edit_results' ) ) {
    81             return new WP_Error( 'rest_unauthorized', __( 'Sorry, you are not allowed to create results.', 'ptr' ), array(
    82                 'status' => is_user_logged_in() ? 403 : 401,
    83             ) );
     89            return new WP_Error(
     90                'rest_unauthorized', __( 'Sorry, you are not allowed to create results.', 'ptr' ), array(
     91                    'status' => is_user_logged_in() ? 403 : 401,
     92                )
     93            );
    8494        }
    8595        return true;
     
    94104            $parent_id = $post->ID;
    95105        } else {
    96             $parent_id = wp_insert_post( array(
    97                 'post_title' => $parameters['message'],
    98                 'post_name' => $slug,
    99                 'post_status' => 'publish',
    100                 'post_type' => 'result',
    101             ) );
     106            $parent_id = wp_insert_post(
     107                array(
     108                    'post_title'  => $parameters['message'],
     109                    'post_name'   => $slug,
     110                    'post_status' => 'publish',
     111                    'post_type'   => 'result',
     112                )
     113            );
    102114        }
    103115
     
    106118        $args = array(
    107119            'post_parent' => $parent_id,
    108             'post_type' => 'result',
     120            'post_type'   => 'result',
    109121            'numberposts' => 1,
    110             'author' => $current_user->ID,
     122            'author'      => $current_user->ID,
    111123        );
    112124
     
    117129        } else {
    118130            $results = array(
    119                 'post_title' => $current_user->user_login . ' - ' . $slug,
     131                'post_title'   => $current_user->user_login . ' - ' . $slug,
    120132                'post_content' => '',
    121                 'post_status' => 'publish',
    122                 'post_author' => $current_user->ID,
    123                 'post_type' => 'result',
    124                 'post_parent' => $parent_id,
     133                'post_status'  => 'publish',
     134                'post_author'  => $current_user->ID,
     135                'post_type'    => 'result',
     136                'post_parent'  => $parent_id,
    125137            );
    126138
     
    133145        }
    134146
    135         $env = isset( $parameters['env'] ) ? json_decode( $parameters['env'], true ) : array();
     147        $env     = isset( $parameters['env'] ) ? json_decode( $parameters['env'], true ) : array();
    136148        $results = isset( $parameters['results'] ) ? json_decode( $parameters['results'], true ) : array();
    137149
     
    142154        $response = new \WP_REST_Response(
    143155            array(
    144                 'id'    => $post_id,
    145                 'link'  => get_permalink( $post_id ),
     156                'id'   => $post_id,
     157                'link' => get_permalink( $post_id ),
    146158            )
    147159        );
Note: See TracChangeset for help on using the changeset viewer.