diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7cae5d5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab diff --git a/parts/result-set-all.php b/parts/result-set-all.php new file mode 100644 index 0000000..1b3142a --- /dev/null +++ b/parts/result-set-all.php @@ -0,0 +1,50 @@ + + + + + + + + + + + + + post_name, 'r' ); + + $num_passed = ptr_count_test_results( $revision->ID ); + $num_failed = ptr_count_test_results( $revision->ID, 'failed' ); + ?> + + + + + + + + + +
RevisionPassedFailed➡️
+ + r + + + + + + + + + + + + View + +
diff --git a/parts/result-set.php b/parts/result-set-single.php similarity index 51% rename from parts/result-set.php rename to parts/result-set-single.php index 4aa9211..29b6cd6 100644 --- a/parts/result-set.php +++ b/parts/result-set-single.php @@ -1,36 +1,53 @@ +echo Display::get_display_css(); - +foreach ( $revisions as $revision ) : + + $rev_id = (int) ltrim( $revision->post_name, 'r' ); +?> + +
+ + r + : post_title ) ); ?> +
+ +
- - - + + - post_name, 'r' ); - ?> - - - + $posts_per_page, + 'author' => $post_author ?? null, 'post_type' => 'result', 'post_parent' => $revision->ID, - 'orderby' => 'post_title', - 'order' => 'ASC', + 'orderby' => [ 'author' => 'ASC', 'env_name_clause' => 'ASC' ], + 'meta_query' => array( + 'relation' => 'OR', + 'env_name_clause' => array( + 'key' => 'environment_name', + 'compare' => 'EXISTS', + ), + array( + 'key' => 'environment_name', + 'compare' => 'NOT EXISTS', + ) + ), ); $report_query = new WP_Query( $query_args ); if ( ! empty( $report_query->posts ) ) : + + $prev_author = null; + foreach ( $report_query->posts as $report ) : $status = 'Errored'; $status_title = 'No results found for test.'; @@ -55,35 +72,42 @@ 'extra_attr' => 'style="vertical-align: middle;margin-right:5px;"', ) ); - if ( ! empty( $user->user_url ) ) { - $host .= ''; - } - if ( ! empty( $user->user_url ) ) { - $host .= ''; - } - $host .= $user->display_name; + + $host .= Display::get_display_reporter_name( $report->post_author ); + if ( ! empty( $user->user_url ) ) { $host .= ''; } } ?> + + + + + + - - + - - -
RevisionHostPHP VersionStatusPHP Version Database Version
r: post_title ) ); ?>
+ +
+ + + + ID ) ); ?> ID ) ); ?>
+ No reports for changeset.
+ 'style="vertical-align: middle;margin-right:5px;"', ) ); - if ( ! empty( $user->user_url ) ) { - $host .= ''; - } - if ( ! empty( $user->user_url ) ) { - $host .= ''; - } $host .= $user->display_name; if ( ! empty( $user->user_url ) ) { $host .= ''; @@ -54,6 +48,25 @@ Host + + Test Date + + + + + + + Execution Time + + ID ) ); ?> + + + + Environment Name + + ID ) ); ?> + + PHP Version ID ) ); ?> diff --git a/phpunit-test-reporter.php b/phpunit-test-reporter.php index 9b7ee16..13bb230 100644 --- a/phpunit-test-reporter.php +++ b/phpunit-test-reporter.php @@ -29,7 +29,6 @@ add_action( 'post_class', array( 'PTR\Display', 'filter_post_class' ) ); add_action( 'the_content', array( 'PTR\Display', 'filter_the_content' ) ); add_action( 'rest_api_init', array( 'PTR\RestAPI', 'register_routes' ) ); - add_action( 'load-edit.php', 'ptr_load_edit_php' ); /** @@ -93,3 +92,35 @@ function ptr_get_template_part( $template, $vars = array() ) { include $full_path; return ob_get_clean(); } + +/** + * Counts the number of failing or passing test reports for a revision. + * + * @param int $revision_parent_id The current revision's post ID. + * @param string $status The status term slug to count. + * + * @return int The number of reports for the given revision. + */ +function ptr_count_test_results( $revision_parent_id, $status = 'passed' ) { + $report_query = new WP_Query( + array( + 'post_type' => 'result', + 'post_parent' => $revision_parent_id, + 'fields' => 'ids', + 'posts_per_page' => 1, + 'tax_query' => array( + array( + 'taxonomy' => 'report-result', + 'terms' => $status, + 'field' => 'slug', + ), + ) + ) + ); + + if ( ! $report_query->have_posts() ) { + return 0; + } + + return $report_query->found_posts; +} diff --git a/src/class-content-model.php b/src/class-content-model.php index 64a153f..f16b47c 100644 --- a/src/class-content-model.php +++ b/src/class-content-model.php @@ -42,6 +42,60 @@ public static function action_init_register_post_type() { ), ) ); + + register_taxonomy( + 'php-version', + array( 'result' ), + array( + 'labels' => array( + 'name' => __( 'PHP Versions', 'ptr' ), + 'singular_name' => __( 'PHP Version', 'ptr' ), + ), + 'hierarchical' => false, + 'public' => false, + 'show_ui' => true, + 'show_admin_column' => true, + 'show_in_nav_menus' => false, + 'show_tagcloud' => false, + 'show_in_rest' => true, + ) + ); + + register_taxonomy( + 'db-version', + array( 'result' ), + array( + 'labels' => array( + 'name' => __( 'Database Versions', 'ptr' ), + 'singular_name' => __( 'Database Version', 'ptr' ), + ), + 'hierarchical' => false, + 'public' => false, + 'show_ui' => true, + 'show_admin_column' => true, + 'show_in_nav_menus' => false, + 'show_tagcloud' => false, + 'show_in_rest' => true, + ) + ); + + register_taxonomy( + 'report-result', + array( 'result' ), + array( + 'labels' => array( + 'name' => __( 'Result Status', 'ptr' ), + 'singular_name' => __( 'Result Status', 'ptr' ), + ), + 'hierarchical' => false, + 'public' => false, + 'show_ui' => true, + 'show_admin_column' => true, + 'show_in_nav_menus' => false, + 'show_tagcloud' => false, + 'show_in_rest' => true, + ) + ); } /** diff --git a/src/class-display.php b/src/class-display.php index a1429c6..74493aa 100644 --- a/src/class-display.php +++ b/src/class-display.php @@ -74,7 +74,7 @@ public static function filter_the_content( $content ) { ); } else { $content = ptr_get_template_part( - 'result-set', + 'result-set-single', array( 'posts_per_page' => 500, 'revisions' => array( @@ -92,16 +92,16 @@ public static function filter_the_content( $content ) { * Render the test results. */ public static function render_results( $atts ) { - - $output = ''; - $query_args = array( - 'posts_per_page' => 3, + $current_user = null; + $output = ''; + $query_args = array( + 'posts_per_page' => 20, 'post_type' => 'result', 'post_parent' => 0, 'orderby' => 'post_name', 'order' => 'DESC', ); - $paged = isset( $_GET['rpage'] ) ? (int) $_GET['rpage'] : 0; + $paged = isset( $_GET['rpage'] ) ? (int) $_GET['rpage'] : 0; if ( $paged ) { $query_args['paged'] = $paged; } @@ -117,16 +117,18 @@ public static function render_results( $atts ) { return $output; } $output .= self::get_display_css(); - if ( $paged <= 1 ) { + + if ($paged <= 1) { $output .= self::get_reporter_avatars(); } + $output .= ptr_get_template_part( - 'result-set', - array( - 'posts_per_page' => 50, - 'revisions' => $rev_query->posts, - ) + 'result-set-all', + array( + 'revisions' => $rev_query->posts, + ) ); + ob_start(); self::pagination( $rev_query ); $output .= ob_get_clean(); @@ -142,8 +144,9 @@ public static function get_display_css() { ob_start(); ?>