From 8e5a395fab2de26509ca9e1b82783c01e4e410ff Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Tue, 27 Feb 2024 20:46:16 -0300 Subject: [PATCH] Add self-tests for Activation Tests loopback --- _tests/QITSelfTests.php | 14 +- _tests/activation/loopback/env.php | 6 + .../woocommerce-product-feeds.php | 22 + ...rc_56cb8125a086442517f8d92efc8fecf5__1.php | 384 ++++++++++++++++++ 4 files changed, 423 insertions(+), 3 deletions(-) create mode 100644 _tests/activation/loopback/env.php create mode 100644 _tests/activation/loopback/woocommerce-product-feeds/woocommerce-product-feeds.php create mode 100644 _tests/tests/__snapshots__/ActivationTest__test_activation_loopback_woorc_php74_wprc_56cb8125a086442517f8d92efc8fecf5__1.php diff --git a/_tests/QITSelfTests.php b/_tests/QITSelfTests.php index 9b3753e4..7f2b741e 100644 --- a/_tests/QITSelfTests.php +++ b/_tests/QITSelfTests.php @@ -290,6 +290,9 @@ function run_test_runs( array $test_runs ) { $qit_run_processes = []; + // If running a lot of tests, wait between any remote request to prevent 429. + $should_wait = count( $test_runs ) > 3; + // Dispatch all tests in parallel using the qit binary. foreach ( $test_runs as $test_type => &$test_type_test_runs ) { foreach ( $test_type_test_runs as &$t ) { @@ -364,15 +367,20 @@ function run_test_runs( array $test_runs ) { $t['non_json_output_file'] = tempnam( sys_get_temp_dir(), 'qit_non_json_' ); - $qit_process->setEnv( [ + $env = [ 'QIT_TEST_PATH' => $t['path'], 'QIT_TEST_TYPE' => $test_type, 'QIT_TEST_FUNCTION_NAME' => $t['test_function_name'], - 'QIT_WAIT_BEFORE_REQUEST' => 'yes', 'QIT_RAN_TEST' => false, 'QIT_REMOVE_FROM_SNAPSHOT' => $t['remove_from_snapshot'], 'QIT_NON_JSON_OUTPUT' => $t['non_json_output_file'], - ] ); + ]; + + if ( $should_wait ) { + $env['QIT_WAIT_BEFORE_REQUEST'] = 'yes'; + } + + $qit_process->setEnv( $env ); add_task_id_to_process( $qit_process, $t ); diff --git a/_tests/activation/loopback/env.php b/_tests/activation/loopback/env.php new file mode 100644 index 00000000..f239da23 --- /dev/null +++ b/_tests/activation/loopback/env.php @@ -0,0 +1,6 @@ + '7.4', + 'wp' => 'rc', + 'woo' => 'rc', +]; \ No newline at end of file diff --git a/_tests/activation/loopback/woocommerce-product-feeds/woocommerce-product-feeds.php b/_tests/activation/loopback/woocommerce-product-feeds/woocommerce-product-feeds.php new file mode 100644 index 00000000..ccae84f0 --- /dev/null +++ b/_tests/activation/loopback/woocommerce-product-feeds/woocommerce-product-feeds.php @@ -0,0 +1,22 @@ +get_error_message() ); + } else { + $data = json_decode( wp_remote_retrieve_body( $response ), true ); + + if ( isset( $data['name'] ) ) { + trigger_error( 'Site name from wp-json: ' . $data['name'] ); + } else { + trigger_error( 'Site name not found in wp-json response' ); + } + } +} ); diff --git a/_tests/tests/__snapshots__/ActivationTest__test_activation_loopback_woorc_php74_wprc_56cb8125a086442517f8d92efc8fecf5__1.php b/_tests/tests/__snapshots__/ActivationTest__test_activation_loopback_woorc_php74_wprc_56cb8125a086442517f8d92efc8fecf5__1.php new file mode 100644 index 00000000..a7c0a16a --- /dev/null +++ b/_tests/tests/__snapshots__/ActivationTest__test_activation_loopback_woorc_php74_wprc_56cb8125a086442517f8d92efc8fecf5__1.php @@ -0,0 +1,384 @@ +" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/plugin.php", + "line": 565, + "function": "do_action", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp.php", + "line": 830, + "function": "do_action_ref_array" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/functions.php", + "line": 1336, + "function": "main", + "class": "WP", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-blog-header.php", + "line": 16, + "function": "wp" + } + ], + "db_error": "" + }, + "1": { + "activated_alongside": "", + "context": "\\/", + "is_fatal": "No", + "error_type": "E_USER_NOTICE", + "error_message": "Site name from wp-json: WooCommerce Core E2E Test Suite", + "error_file": "woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "error_line": 17, + "backtrace": [ + { + "file": "\\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "line": 17, + "function": "trigger_error" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 324, + "function": "{closure}" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 348, + "function": "apply_filters", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/plugin.php", + "line": 565, + "function": "do_action", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp.php", + "line": 830, + "function": "do_action_ref_array" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/functions.php", + "line": 1336, + "function": "main", + "class": "WP", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-blog-header.php", + "line": 16, + "function": "wp" + } + ], + "db_error": "" + }, + "2": { + "activated_alongside": "", + "context": "\\/cart\\/", + "is_fatal": "No", + "error_type": "E_USER_NOTICE", + "error_message": "Site URL: http:\\/\\/qit-runner.test", + "error_file": "woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "error_line": 8, + "backtrace": [ + { + "file": "\\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "line": 8, + "function": "trigger_error" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 324, + "function": "{closure}" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 348, + "function": "apply_filters", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/plugin.php", + "line": 565, + "function": "do_action", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp.php", + "line": 830, + "function": "do_action_ref_array" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/functions.php", + "line": 1336, + "function": "main", + "class": "WP", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-blog-header.php", + "line": 16, + "function": "wp" + } + ], + "db_error": "" + }, + "3": { + "activated_alongside": "", + "context": "\\/cart\\/", + "is_fatal": "No", + "error_type": "E_USER_NOTICE", + "error_message": "Site name from wp-json: WooCommerce Core E2E Test Suite", + "error_file": "woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "error_line": 17, + "backtrace": [ + { + "file": "\\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "line": 17, + "function": "trigger_error" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 324, + "function": "{closure}" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 348, + "function": "apply_filters", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/plugin.php", + "line": 565, + "function": "do_action", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp.php", + "line": 830, + "function": "do_action_ref_array" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/functions.php", + "line": 1336, + "function": "main", + "class": "WP", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-blog-header.php", + "line": 16, + "function": "wp" + } + ], + "db_error": "" + }, + "4": { + "activated_alongside": "", + "context": "\\/my-account\\/", + "is_fatal": "No", + "error_type": "E_USER_NOTICE", + "error_message": "Site URL: http:\\/\\/qit-runner.test", + "error_file": "woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "error_line": 8, + "backtrace": [ + { + "file": "\\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "line": 8, + "function": "trigger_error" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 324, + "function": "{closure}" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 348, + "function": "apply_filters", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/plugin.php", + "line": 565, + "function": "do_action", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp.php", + "line": 830, + "function": "do_action_ref_array" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/functions.php", + "line": 1336, + "function": "main", + "class": "WP", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-blog-header.php", + "line": 16, + "function": "wp" + } + ], + "db_error": "" + }, + "5": { + "activated_alongside": "", + "context": "\\/my-account\\/", + "is_fatal": "No", + "error_type": "E_USER_NOTICE", + "error_message": "Site name from wp-json: WooCommerce Core E2E Test Suite", + "error_file": "woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "error_line": 17, + "backtrace": [ + { + "file": "\\/var\\/www\\/html\\/wp-content\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php", + "line": 17, + "function": "trigger_error" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 324, + "function": "{closure}" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp-hook.php", + "line": 348, + "function": "apply_filters", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/plugin.php", + "line": 565, + "function": "do_action", + "class": "WP_Hook", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/class-wp.php", + "line": 830, + "function": "do_action_ref_array" + }, + { + "file": "\\/var\\/www\\/html\\/wp-includes\\/functions.php", + "line": 1336, + "function": "main", + "class": "WP", + "type": "->" + }, + { + "file": "\\/var\\/www\\/html\\/wp-blog-header.php", + "line": 16, + "function": "wp" + } + ], + "db_error": "" + } + } + } + ] +]';