Changeset 6262
- Timestamp:
- 12/13/2017 07:27:11 PM (7 years ago)
- 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 25 25 </tr> 26 26 <?php 27 $query_args = array(28 'posts_per_page' 29 'post_type' 30 'post_parent' 31 'orderby' 32 'order' 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', 33 33 ); 34 34 $report_query = new WP_Query( $query_args ); 35 35 if ( ! empty( $report_query->posts ) ) : 36 36 foreach ( $report_query->posts as $report ) : 37 $status = 'Errored';37 $status = 'Errored'; 38 38 $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 ); 40 40 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'; 42 42 $status_title = (int) $results['tests'] . ' tests, ' . (int) $results['failures'] . ' failed, ' . (int) $results['errors'] . ' errors'; 43 43 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/parts/single-result.php
r5806 r6262 2 2 use PTR\Display; 3 3 4 $status = 'Errored';4 $status = 'Errored'; 5 5 $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 ); 7 7 if ( 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'; 9 9 $status_title = (int) $results['tests'] . ' tests, ' . (int) $results['failures'] . ' failed, ' . (int) $results['errors'] . ' errors'; 10 10 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/readme.txt
r5828 r6262 14 14 Captures and displays test results from the PHPUnit Test Runner 15 15 16 For more details, [please read through the project overview](https://make.wordpress.org/hosting/test-results-getting-started/). 17 16 18 == Changelog == 17 19 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-content-model.php
r5806 r6262 10 10 */ 11 11 public static function action_init_register_post_type() { 12 register_post_type( 'result', 12 register_post_type( 13 'result', 13 14 array( 14 'labels' => array(15 'name' => __( 'Test Results', 'ptr' ),15 'labels' => array( 16 'name' => __( 'Test Results', 'ptr' ), 16 17 'singular_name' => __( 'Test Result', 'ptr' ), 17 18 ), 18 'public' => true,19 'has_archive' => false,19 'public' => true, 20 'has_archive' => false, 20 21 'show_in_rest' => true, 21 22 'hierarchical' => true, 22 'rewrite' => array(23 'rewrite' => array( 23 24 'slug' => 'test-results', 24 25 ), 25 'supports' => array(26 'supports' => array( 26 27 'title', 27 28 'editor', … … 32 33 'map_meta_cap' => true, 33 34 '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', 39 40 'read_private_posts' => 'read_private_results', 40 'delete_post' => 'delete_result',41 'delete_post' => 'delete_result', 41 42 ), 42 43 ) … … 49 50 public static function action_init_register_role() { 50 51 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 ); 54 57 } 55 58 $role = get_role( 'test-reporter' ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-display.php
r5833 r6262 22 22 return $check; 23 23 } 24 $template = 'page-templates/full-width.php';24 $template = 'page-templates/full-width.php'; 25 25 $full_width = get_stylesheet_directory() . '/' . $template; 26 26 if ( ! file_exists( $full_width ) ) { … … 67 67 68 68 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 ); 72 74 } 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 ); 78 82 $content = '<p><a href="' . esc_url( home_url( 'test-results/' ) ) . '">← Test Results</a></p>' . PHP_EOL . PHP_EOL . $content; 79 83 } … … 87 91 public static function render_results( $atts ) { 88 92 89 $output = '';93 $output = ''; 90 94 $query_args = array( 91 'posts_per_page' 92 'post_type' 93 'post_parent' 94 'orderby' 95 'order' 95 'posts_per_page' => 5, 96 'post_type' => 'result', 97 'post_parent' => 0, 98 'orderby' => 'post_name', 99 'order' => 'DESC', 96 100 ); 97 $paged = isset( $_GET['rpage'] ) ? (int) $_GET['rpage'] : 0;101 $paged = isset( $_GET['rpage'] ) ? (int) $_GET['rpage'] : 0; 98 102 if ( $paged ) { 99 103 $query_args['paged'] = $paged; … … 105 109 } 106 110 $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 ); 110 116 ob_start(); 111 117 self::pagination( $rev_query ); … … 182 188 public static function get_display_php_version( $report_id ) { 183 189 $php_version = 'Unknown'; 184 $env = get_post_meta( $report_id, 'env', true );190 $env = get_post_meta( $report_id, 'env', true ); 185 191 if ( ! empty( $env['php_version'] ) ) { 186 192 $php_version = 'PHP ' . $env['php_version']; … … 197 203 public static function get_display_mysql_version( $report_id ) { 198 204 $mysql_version = 'Unknown'; 199 $env = get_post_meta( $report_id, 'env', true );205 $env = get_post_meta( $report_id, 'env', true ); 200 206 if ( ! empty( $env['mysql_version'] ) ) { 201 $bits = explode( ',', $env['mysql_version'] );207 $bits = explode( ',', $env['mysql_version'] ); 202 208 $mysql_version = $bits[0]; 203 209 } … … 213 219 public static function get_display_extensions( $report_id ) { 214 220 $extensions = array(); 215 $env = get_post_meta( $report_id, 'env', true );221 $env = get_post_meta( $report_id, 'env', true ); 216 222 if ( ! empty( $env['php_modules'] ) ) { 217 223 foreach ( $env['php_modules'] as $module => $version ) { … … 233 239 private static function pagination( $query ) { 234 240 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' ) ); 239 245 $prev_page_label = '‹'; 240 246 $next_page_label = '›'; 241 $args = array(242 'base' 243 'format' 244 'current' 245 'total' 246 'prev_text' 247 'next_text' 248 'type' 249 'end_size' 250 'mid_size' 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, 251 257 ); 252 258 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/phpunit-test-reporter/src/class-restapi.php
r5825 r6262 14 14 register_rest_route( 15 15 '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', 23 23 'validate_callback' => array( __CLASS__, 'validate_callback' ), 24 24 ), 25 25 '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', 29 29 'validate_callback' => array( __CLASS__, 'validate_callback' ), 30 30 ), 31 31 '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', 35 35 'validate_callback' => array( __CLASS__, 'validate_callback' ), 36 36 ), 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', 41 41 'validate_callback' => array( __CLASS__, 'validate_callback' ), 42 42 ), … … 51 51 case 'commit': 52 52 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 ); 56 58 } 57 59 return true; 58 60 case 'message': 59 61 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 ); 63 67 } 64 68 return true; … … 66 70 case 'results': 67 71 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 ); 71 77 } 72 78 return true; 73 79 } 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 ); 77 85 } 78 86 79 87 public static function permission() { 80 88 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 ); 84 94 } 85 95 return true; … … 94 104 $parent_id = $post->ID; 95 105 } 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 ); 102 114 } 103 115 … … 106 118 $args = array( 107 119 'post_parent' => $parent_id, 108 'post_type' => 'result',120 'post_type' => 'result', 109 121 'numberposts' => 1, 110 'author' => $current_user->ID,122 'author' => $current_user->ID, 111 123 ); 112 124 … … 117 129 } else { 118 130 $results = array( 119 'post_title' => $current_user->user_login . ' - ' . $slug,131 'post_title' => $current_user->user_login . ' - ' . $slug, 120 132 '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, 125 137 ); 126 138 … … 133 145 } 134 146 135 $env = isset( $parameters['env'] ) ? json_decode( $parameters['env'], true ) : array();147 $env = isset( $parameters['env'] ) ? json_decode( $parameters['env'], true ) : array(); 136 148 $results = isset( $parameters['results'] ) ? json_decode( $parameters['results'], true ) : array(); 137 149 … … 142 154 $response = new \WP_REST_Response( 143 155 array( 144 'id' 145 'link' 156 'id' => $post_id, 157 'link' => get_permalink( $post_id ), 146 158 ) 147 159 );
Note: See TracChangeset
for help on using the changeset viewer.