Unit tests - #33
Unit tests#33richardkorthuis wants to merge 14 commits into
Conversation
…er on post-type re-registration
…ouble-prefixing with home_url
…e sanitization is reachable in CLI contexts and better testable
…hen no row matches
acato-plugins
left a comment
There was a problem hiding this comment.
phpcs scanning turned up:
🚫 175 errors
hashes-api-scanning skipped
Posting will continue in further review(s)
| ); | ||
| } | ||
|
|
||
| public function test_get_home_url_does_not_leak_the_skip_convert_filter_after_returning() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_get_home_url_does_not_leak_the_skip_convert_filter_after_returning() (Squiz.Commenting.FunctionComment.Missing).
| add_filter( | ||
| 'home_url', | ||
| function ( $home_url ) use ( &$skip_value_during_call ) { | ||
| $skip_value_during_call = apply_filters( 'wpml_skip_convert_url_string', false ); |
There was a problem hiding this comment.
🚫 Error: Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "wpml_skip_convert_url_string" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound).
| $this->assertSame( get_home_url(), Util::get_home_url() ); | ||
| } | ||
|
|
||
| public function test_get_home_url_applies_the_wpml_skip_convert_filter_during_the_call() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_get_home_url_applies_the_wpml_skip_convert_filter_during_the_call() (Squiz.Commenting.FunctionComment.Missing).
| */ | ||
| class Test_Util extends Caching_Test_Case { | ||
|
|
||
| public function test_get_home_url_returns_the_wordpress_home_url() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_get_home_url_returns_the_wordpress_home_url() (Squiz.Commenting.FunctionComment.Missing).
| /** | ||
| * @covers \WP_Rest_Cache_Plugin\Includes\Util | ||
| */ | ||
| class Test_Util extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Util" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
|
|
||
| use WP_Rest_Cache_Plugin\Includes\Util; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| $this->assertStringContainsString( 'plugins.acato.nl', $html ); | ||
| } | ||
|
|
||
| public function test_sidebar_renders_support_panel_link_to_wordpress_org() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_sidebar_renders_support_panel_link_to_wordpress_org() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Sidebar (Pro / support panels) ---------- | ||
|
|
||
| public function test_sidebar_renders_pro_upgrade_panel() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertStringNotContainsString( 'name="wp_rest_cache_memcache_used"', $html ); | ||
| } | ||
|
|
||
| public function test_memcache_row_is_not_rendered_without_a_memcache_class_present() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_memcache_row_is_not_rendered_without_a_memcache_class_present() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Memcache row visibility ---------- | ||
|
|
||
| public function test_memcache_row_is_not_rendered_when_external_object_cache_is_off() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| ); | ||
| } | ||
|
|
||
| public function test_global_cacheable_request_headers_input_reflects_stored_value() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_global_cacheable_request_headers_input_reflects_stored_value() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_regenerate_number_input_reflects_stored_value() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_regenerate_number_input_reflects_stored_value() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_regenerate_interval_dropdown_marks_stored_schedule_as_selected() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_regenerate_interval_dropdown_marks_stored_schedule_as_selected() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_regenerate_checkbox_is_unchecked_when_setting_is_disabled() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_regenerate_checkbox_is_unchecked_when_setting_is_disabled() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertMatchesRegularExpression( $pattern, $html ); | ||
| } | ||
|
|
||
| public function test_regenerate_checkbox_is_checked_when_setting_is_enabled() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_regenerate_checkbox_is_checked_when_setting_is_enabled() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_timeout_interval_dropdown_marks_stored_value_as_selected() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_timeout_interval_dropdown_marks_stored_value_as_selected() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Current-value reflection ---------- | ||
|
|
||
| public function test_timeout_input_reflects_stored_option_value() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertStringContainsString( 'name="_wpnonce"', $html ); | ||
| } | ||
|
|
||
| public function test_form_has_a_submit_button() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_form_has_a_submit_button() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Form skeleton ---------- | ||
|
|
||
| public function test_form_posts_to_options_php_and_includes_settings_fields_nonce() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
|
|
||
| const PARTIAL = __DIR__ . '/../admin/partials/sub-settings.php'; | ||
|
|
||
| private function render() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function render() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| /** | ||
| * @covers \WP_Rest_Cache_Plugin\Admin\Admin | ||
| */ | ||
| class Test_Sub_Settings_Partial extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Sub_Settings_Partial" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| * @package WP_Rest_Cache_Plugin | ||
| */ | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$method" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$class" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$hook" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
| $this->assert_filter_registered( 'wp_ajax_flush_caches', Admin::class, 'flush_caches' ); | ||
| } | ||
|
|
||
| public function test_admin_cli_command_registration_is_hooked_on_cli_init() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_admin_cli_command_registration_is_hooked_on_cli_init() (Squiz.Commenting.FunctionComment.Missing).
| $this->assert_filter_registered( 'admin_init', Admin::class, 'register_settings' ); | ||
| } | ||
|
|
||
| public function test_admin_ajax_flush_caches_handler_is_registered() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_admin_ajax_flush_caches_handler_is_registered() (Squiz.Commenting.FunctionComment.Missing).
| $this->assert_filter_registered( 'admin_menu', Admin::class, 'create_menu' ); | ||
| } | ||
|
|
||
| public function test_admin_registers_settings_on_admin_init() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_admin_registers_settings_on_admin_init() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Admin hooks ---------- | ||
|
|
||
| public function test_admin_creates_settings_menu() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| ); | ||
| } | ||
|
|
||
| public function test_oembed_api_processes_cache_relations() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_oembed_api_processes_cache_relations() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| ); | ||
| } | ||
|
|
||
| public function test_object_type_determination_has_both_endpoint_and_oembed_handlers() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_object_type_determination_has_both_endpoint_and_oembed_handlers() (Squiz.Commenting.FunctionComment.Missing).
| $this->assert_filter_registered( 'rest_api_init', Endpoint_Api::class, 'save_options' ); | ||
| } | ||
|
|
||
| public function test_oembed_api_adds_its_endpoint_to_the_allowed_list() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_oembed_api_adds_its_endpoint_to_the_allowed_list() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_endpoint_api_saves_options_on_init_and_rest_api_init() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_endpoint_api_saves_options_on_init_and_rest_api_init() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_item_api_swaps_taxonomy_rest_controller() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_item_api_swaps_taxonomy_rest_controller() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- API hooks ---------- | ||
|
|
||
| public function test_item_api_swaps_post_type_rest_controller() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| ); | ||
| } | ||
|
|
||
| public function test_regenerate_cron_event_runs_regenerate_expired_caches() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_regenerate_cron_event_runs_regenerate_expired_caches() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_cleanup_cron_event_runs_cleanup_deleted_caches() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_cleanup_cron_event_runs_cleanup_deleted_caches() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_set_object_terms_is_hooked() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_set_object_terms_is_hooked() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_transition_post_status_is_hooked() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_transition_post_status_is_hooked() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| public function test_delete_post_is_hooked() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_delete_post_is_hooked() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| ); | ||
| } | ||
|
|
||
| public function test_save_post_is_hooked_at_priority_999() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_save_post_is_hooked_at_priority_999() (Squiz.Commenting.FunctionComment.Missing).
| // directly. The other classes don't expose their instance, so we use the | ||
| // assert_action_registered helper for those. | ||
|
|
||
| public function test_init_runs_update_database_structure() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertSame( 'wp-rest-cache', $plugin->get_plugin_name() ); | ||
| } | ||
|
|
||
| public function test_get_version_returns_a_calver_string() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_get_version_returns_a_calver_string() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Identity getters ---------- | ||
|
|
||
| public function test_get_plugin_name_returns_wp_rest_cache() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| /** | ||
| * @covers \WP_Rest_Cache_Plugin\Includes\Plugin | ||
| */ | ||
| class Test_Plugin extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Plugin" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| use WP_Rest_Cache_Plugin\Includes\Caching\Caching; | ||
| use WP_Rest_Cache_Plugin\Includes\Plugin; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| ); | ||
| } | ||
|
|
||
| private function assertRelationExists( $cache_id, $object_id, $object_type ) { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function assertRelationExists() (Squiz.Commenting.FunctionComment.Missing).
| ); | ||
| } | ||
|
|
||
| private function count_relations_for( $cache_id ) { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function count_relations_for() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$post_id" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
| $this->assertSame( 'page', $result ); | ||
| } | ||
|
|
||
| public function test_oembed_request_post_id_filter_can_override_post_resolution() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_oembed_request_post_id_filter_can_override_post_resolution() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| $this->assertSame( 0, $this->count_relations_for( $cache_id ) ); | ||
| } | ||
|
|
||
| public function test_get_oembed_post_id_resolves_a_full_url_param_via_url_to_postid() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_get_oembed_post_id_resolves_a_full_url_param_via_url_to_postid() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( 0, $this->count_relations_for( $cache_id ) ); | ||
| } | ||
|
|
||
| public function test_process_cache_relations_does_nothing_when_no_matching_post() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_process_cache_relations_does_nothing_when_no_matching_post() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertRelationExists( $cache_id, $post_id, 'page' ); | ||
| } | ||
|
|
||
| public function test_process_cache_relations_does_nothing_when_uri_is_not_oembed() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_process_cache_relations_does_nothing_when_uri_is_not_oembed() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- process_cache_relations ---------- | ||
|
|
||
| public function test_process_cache_relations_inserts_relation_with_resolved_post_type() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertTrue( $this->api->is_single_oembed_item( true, [], self::OEMBED_URI ) ); | ||
| } | ||
|
|
||
| public function test_is_single_oembed_item_passes_through_for_non_oembed_uri() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_is_single_oembed_item_passes_through_for_non_oembed_uri() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- is_single_oembed_item ---------- | ||
|
|
||
| public function test_is_single_oembed_item_returns_true_for_oembed_uri() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertSame( 'unknown', $result ); | ||
| } | ||
|
|
||
| public function test_determine_object_type_returns_unknown_when_uri_is_not_oembed() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_determine_object_type_returns_unknown_when_uri_is_not_oembed() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( 'page', $result ); | ||
| } | ||
|
|
||
| public function test_determine_object_type_returns_unknown_when_no_matching_post() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_determine_object_type_returns_unknown_when_no_matching_post() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( 'post', $result ); | ||
| } | ||
|
|
||
| public function test_determine_object_type_resolves_to_post_type_for_oembed_uri_with_post() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_determine_object_type_resolves_to_post_type_for_oembed_uri_with_post() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- determine_object_type ---------- | ||
|
|
||
| public function test_determine_object_type_passes_through_already_determined_type() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| ); | ||
| } | ||
|
|
||
| public function test_add_oembed_endpoint_preserves_other_namespaces() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_add_oembed_endpoint_preserves_other_namespaces() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( $existing, $result ); | ||
| } | ||
|
|
||
| public function test_add_oembed_endpoint_appends_to_existing_oembed_namespace() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_add_oembed_endpoint_appends_to_existing_oembed_namespace() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( [ 'oembed/1.0' => [ 'embed' ] ], $result ); | ||
| } | ||
|
|
||
| public function test_add_oembed_endpoint_is_idempotent_when_already_present() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_add_oembed_endpoint_is_idempotent_when_already_present() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- add_oembed_endpoint ---------- | ||
|
|
||
| public function test_add_oembed_endpoint_adds_to_empty_allowlist() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| /** @var Oembed_Api */ | ||
| private $api; | ||
|
|
||
| public function set_up() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function set_up() (Squiz.Commenting.FunctionComment.Missing).
| const OEMBED_URI = '/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fexample.org%2Fhello'; | ||
| const NON_OEMBED_URI = '/wp-json/wp/v2/posts/42'; | ||
|
|
||
| /** @var Oembed_Api */ |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| */ | ||
| class Test_Oembed_Api extends Caching_Test_Case { | ||
|
|
||
| const OEMBED_URI = '/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fexample.org%2Fhello'; |
There was a problem hiding this comment.
| /** | ||
| * @covers \WP_Rest_Cache_Plugin\Includes\API\Oembed_Api | ||
| */ | ||
| class Test_Oembed_Api extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Oembed_Api" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| use WP_Rest_Cache_Plugin\Includes\API\Oembed_Api; | ||
| use WP_Rest_Cache_Plugin\Includes\Caching\Caching; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| ); | ||
| } | ||
|
|
||
| private function should_use_custom_class( $class_name, $type ) { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function should_use_custom_class() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| $this->assertTrue( $this->should_use_custom_class( null, 'taxonomy' ) ); | ||
| } | ||
|
|
||
| public function test_should_use_custom_class_default_branch_treats_unknown_type_like_post_type() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_should_use_custom_class_default_branch_treats_unknown_type_like_post_type() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- should_use_custom_class (protected, via reflection for the edge cases) ---------- | ||
|
|
||
| public function test_should_use_custom_class_returns_true_for_null_input_regardless_of_type() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertSame( Term_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_foreign_taxonomy_controller_is_left_alone() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_foreign_taxonomy_controller_is_left_alone() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( Term_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_already_custom_term_controller_remains_term_controller() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_already_custom_term_controller_remains_term_controller() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( Term_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_core_terms_controller_is_swapped_for_custom_term_controller() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_core_terms_controller_is_swapped_for_custom_term_controller() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- set_taxonomy_rest_controller ---------- | ||
|
|
||
| public function test_taxonomy_with_no_controller_set_gets_custom_term_controller() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $result = $this->api->set_post_type_rest_controller( $args ); | ||
|
|
||
| // Only rest_controller_class changes; everything else is preserved. | ||
| $expected = $args; |
There was a problem hiding this comment.
| $this->assertSame( 'WC_REST_Products_Controller', $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_post_type_args_are_returned_unchanged_apart_from_controller_swap() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_post_type_args_are_returned_unchanged_apart_from_controller_swap() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( Attachment_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_foreign_rest_controller_is_left_alone() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_foreign_rest_controller_is_left_alone() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( Post_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_already_custom_attachment_controller_remains_attachment_controller() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_already_custom_attachment_controller_remains_attachment_controller() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| $this->assertSame( Attachment_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_already_custom_post_controller_remains_post_controller() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_already_custom_post_controller_remains_post_controller() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( Post_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_core_attachments_controller_is_swapped_for_custom_attachment_controller() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_core_attachments_controller_is_swapped_for_custom_attachment_controller() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( Post_Controller::class, $result['rest_controller_class'] ); | ||
| } | ||
|
|
||
| public function test_core_posts_controller_is_swapped_for_custom_post_controller() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_core_posts_controller_is_swapped_for_custom_post_controller() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- set_post_type_rest_controller ---------- | ||
|
|
||
| public function test_post_type_with_no_controller_set_gets_custom_post_controller() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| /** @var Item_Api */ | ||
| private $api; | ||
|
|
||
| public function set_up() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function set_up() (Squiz.Commenting.FunctionComment.Missing).
| */ | ||
| class Test_Item_Api extends Caching_Test_Case { | ||
|
|
||
| /** @var Item_Api */ |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| /** | ||
| * @covers \WP_Rest_Cache_Plugin\Includes\API\Item_Api | ||
| */ | ||
| class Test_Item_Api extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Item_Api" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| use WP_Rest_Cache_Plugin\Includes\Controller\Post_Controller; | ||
| use WP_Rest_Cache_Plugin\Includes\Controller\Term_Controller; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$value" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
| $this->assertStringContainsString( 'Deleted', $this->logger->stdout ); | ||
| } | ||
|
|
||
| public function test_success_message_includes_count_of_affected_caches() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_success_message_includes_count_of_affected_caches() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| $this->assertStringNotContainsString( 'Deleted ', $this->logger->stdout ); | ||
| } | ||
|
|
||
| public function test_success_message_uses_deleted_verb_when_delete_flag_is_set() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_success_message_uses_deleted_verb_when_delete_flag_is_set() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Success-message verbs ---------- | ||
|
|
||
| public function test_success_message_uses_flushed_verb_when_delete_flag_is_absent() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
|
|
||
| // ---------- Invalid combination ---------- | ||
|
|
||
| public function test_flush_with_related_but_no_object_type_aborts_with_wp_cli_error() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
|
|
||
| public function test_flush_with_object_type_and_related_flushes_only_that_object_relation() { | ||
| $linked_cache = $this->insert_cache( [ 'object_type' => 'post' ] ); | ||
| $unrelated = $this->insert_cache( [ 'object_type' => 'post' ] ); |
There was a problem hiding this comment.
| // ---------- With object_type AND --related: per-object relation flush ---------- | ||
|
|
||
| public function test_flush_with_object_type_and_related_flushes_only_that_object_relation() { | ||
| $linked_cache = $this->insert_cache( [ 'object_type' => 'post' ] ); |
There was a problem hiding this comment.
|
|
||
| // ---------- With object_type AND --related: per-object relation flush ---------- | ||
|
|
||
| public function test_flush_with_object_type_and_related_flushes_only_that_object_relation() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| } | ||
|
|
||
| public function test_flush_with_object_type_and_delete_marks_them_deleted_not_just_flushed() { | ||
| $cache_id = $this->insert_cache( [ 'object_type' => 'post', 'is_single' => 0 ] ); |
There was a problem hiding this comment.
🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).
| $this->assertNotExpired( $page_cache ); | ||
| } | ||
|
|
||
| public function test_flush_with_object_type_and_delete_marks_them_deleted_not_just_flushed() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_flush_with_object_type_and_delete_marks_them_deleted_not_just_flushed() (Squiz.Commenting.FunctionComment.Missing).
| public function test_flush_with_object_type_targets_only_that_type() { | ||
| // `delete_object_type_caches` flushes non-single caches matching object_type. | ||
| $post_cache = $this->insert_cache( [ 'object_type' => 'post', 'is_single' => 0 ] ); | ||
| $page_cache = $this->insert_cache( [ 'object_type' => 'page', 'is_single' => 0 ] ); |
There was a problem hiding this comment.
🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).
|
|
||
| public function test_flush_with_object_type_targets_only_that_type() { | ||
| // `delete_object_type_caches` flushes non-single caches matching object_type. | ||
| $post_cache = $this->insert_cache( [ 'object_type' => 'post', 'is_single' => 0 ] ); |
There was a problem hiding this comment.
🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
|
|
||
| // ---------- With object_type but no --related: per-type sweep ---------- | ||
|
|
||
| public function test_flush_with_object_type_targets_only_that_type() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertExpired( $cache_id ); | ||
| } | ||
|
|
||
| public function test_flush_with_delete_flag_marks_every_cache_deleted() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_flush_with_delete_flag_marks_every_cache_deleted() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertExpired( $b ); | ||
| } | ||
|
|
||
| public function test_flush_with_explicit_all_arg_also_runs_full_sweep() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_flush_with_explicit_all_arg_also_runs_full_sweep() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- No object_type: full sweep ---------- | ||
|
|
||
| public function test_flush_with_no_args_flushes_every_cache() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->set_wp_cli_capture_exit( true ); | ||
| } | ||
|
|
||
| public function tear_down() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function tear_down() (Squiz.Commenting.FunctionComment.Missing).
| /** @var \WP_CLI\Loggers\Execution */ | ||
| private $logger; | ||
|
|
||
| public function set_up() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function set_up() (Squiz.Commenting.FunctionComment.Missing).
| /** @var Flush_Command */ | ||
| private $command; | ||
|
|
||
| /** @var \WP_CLI\Loggers\Execution */ |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| */ | ||
| class Test_Flush_Command extends Caching_Test_Case { | ||
|
|
||
| /** @var Flush_Command */ |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| /** | ||
| * @covers \WP_Rest_Cache_Plugin\Includes\CLI\Flush_Command | ||
| */ | ||
| class Test_Flush_Command extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Flush_Command" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| // can call get_flag_value() at runtime. | ||
| require_once dirname( __DIR__ ) . '/vendor/wp-cli/wp-cli/php/utils.php'; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
|
|
||
| $this->assertTrue( true ); | ||
|
|
||
| unset( $_GET['sub'] ); |
There was a problem hiding this comment.
| unset( $_GET['sub'] ); | ||
| } | ||
|
|
||
| public function test_settings_page_treats_path_traversal_sub_value_as_default_settings() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_settings_page_treats_path_traversal_sub_value_as_default_settings() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| $this->assertTrue( true ); | ||
|
|
||
| unset( $_GET['sub'] ); |
There was a problem hiding this comment.
| unset( $_GET['sub'] ); | ||
| } | ||
|
|
||
| public function test_settings_page_falls_back_to_default_for_unknown_sub() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_settings_page_falls_back_to_default_for_unknown_sub() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| $this->assertTrue( $applied ); | ||
|
|
||
| unset( $_GET['sub'] ); |
There was a problem hiding this comment.
| $this->assertSame( '0', $cleaned ); | ||
| } | ||
|
|
||
| public function test_settings_page_loads_known_sub_partial() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_settings_page_loads_known_sub_partial() (Squiz.Commenting.FunctionComment.Missing).
| public function test_set_cache_twice_with_same_key_updates_instead_of_inserting() { | ||
| $cache_key = 'reused-key'; | ||
| $payload_1 = [ 'data' => [ 'id' => 1, 'type' => 'post', 'slug' => 'x' ] ]; | ||
| $payload_2 = [ 'data' => [ 'id' => 1, 'type' => 'post', 'slug' => 'y' ] ]; |
There was a problem hiding this comment.
🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).
|
|
||
| public function test_set_cache_twice_with_same_key_updates_instead_of_inserting() { | ||
| $cache_key = 'reused-key'; | ||
| $payload_1 = [ 'data' => [ 'id' => 1, 'type' => 'post', 'slug' => 'x' ] ]; |
There was a problem hiding this comment.
🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).
| $this->assertStringContainsString( 'cache_key: errorlog-key', $contents ); | ||
| } | ||
|
|
||
| public function test_set_cache_twice_with_same_key_updates_instead_of_inserting() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_set_cache_twice_with_same_key_updates_instead_of_inserting() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| $contents = file_get_contents( $log_file ); | ||
| } finally { | ||
| ini_set( 'error_log', $previous_log ); |
There was a problem hiding this comment.
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| Caching::get_instance()->set_cache( $cache_key, $payload, 'endpoint', '/log-uri' ); | ||
| Caching::get_instance()->set_cache( $cache_key, $payload, 'endpoint', '/log-uri' ); | ||
|
|
||
| $contents = file_get_contents( $log_file ); |
There was a problem hiding this comment.
| $payload = [ 'data' => [ 'id' => 1 ] ]; | ||
|
|
||
| $log_file = tempnam( sys_get_temp_dir(), 'wprc-errlog-' ); | ||
| $previous_log = ini_set( 'error_log', $log_file ); |
There was a problem hiding this comment.
| */ | ||
| class Test_Final_Fillers extends Caching_Test_Case { | ||
|
|
||
| public function test_set_cache_logs_to_error_log_when_set_transient_returns_false() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_set_cache_logs_to_error_log_when_set_transient_returns_false() (Squiz.Commenting.FunctionComment.Missing).
| * @covers \WP_Rest_Cache_Plugin\Includes\Caching\Caching | ||
| * @covers \WP_Rest_Cache_Plugin\Admin\Admin | ||
| */ | ||
| class Test_Final_Fillers extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Final_Fillers" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| use WP_Rest_Cache_Plugin\Admin\Admin; | ||
| use WP_Rest_Cache_Plugin\Includes\Caching\Caching; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| // Intentionally NO cache_filter — delete_all_caches must run fully through. | ||
|
|
||
| $base_level = ob_get_level(); | ||
| ob_start(); // capture the JSON wp_send_json echoes so it doesn't pollute test stdout |
There was a problem hiding this comment.
🚫 Error: Inline comments must end in full-stops, exclamation marks, or question marks (Squiz.Commenting.InlineComment.InvalidEndChar).
| // we register the AJAX die handler ourselves. Process-isolated so DOING_AJAX and | ||
| // the handler don't leak. | ||
| if ( ! defined( 'DOING_AJAX' ) ) { | ||
| define( 'DOING_AJAX', true ); |
There was a problem hiding this comment.
🚫 Error: Global constants defined by a theme/plugin should start with the theme/plugin prefix. Found: "DOING_AJAX" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound).
| $this->assertSame( [ [], 'my-filter' ], $filter_received_args ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| $_POST['wp_rest_cache_nonce'] = $nonce; | ||
| $_REQUEST['wp_rest_cache_nonce'] = $nonce; | ||
| $_POST['delete_caches'] = 'true'; | ||
| $_POST['cache_filter'] = 'my-filter'; |
There was a problem hiding this comment.
| $nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' ); | ||
| $_POST['wp_rest_cache_nonce'] = $nonce; | ||
| $_REQUEST['wp_rest_cache_nonce'] = $nonce; | ||
| $_POST['delete_caches'] = 'true'; |
There was a problem hiding this comment.
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
|
|
||
| $nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' ); | ||
| $_POST['wp_rest_cache_nonce'] = $nonce; | ||
| $_REQUEST['wp_rest_cache_nonce'] = $nonce; |
There was a problem hiding this comment.
| wp_set_current_user( $user_id ); | ||
|
|
||
| $nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' ); | ||
| $_POST['wp_rest_cache_nonce'] = $nonce; |
There was a problem hiding this comment.
| $user_id = self::factory()->user->create( [ 'role' => 'administrator' ] ); | ||
| wp_set_current_user( $user_id ); | ||
|
|
||
| $nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' ); |
There was a problem hiding this comment.
| ( new Admin( 'wp-rest-cache', '2026.2.0' ) )->flush_caches(); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
|
|
||
| $nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' ); | ||
| $_POST['wp_rest_cache_nonce'] = $nonce; | ||
| $_REQUEST['wp_rest_cache_nonce'] = $nonce; |
There was a problem hiding this comment.
| wp_set_current_user( $user_id ); | ||
|
|
||
| $nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' ); | ||
| $_POST['wp_rest_cache_nonce'] = $nonce; |
There was a problem hiding this comment.
| $user_id = self::factory()->user->create( [ 'role' => 'subscriber' ] ); | ||
| wp_set_current_user( $user_id ); | ||
|
|
||
| $nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' ); |
There was a problem hiding this comment.
| unset( $_SERVER['HTTP_ORIGIN'] ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| $reflection = new ReflectionClass( $api ); | ||
| $method = $reflection->getMethod( 'rest_send_cors_headers' ); | ||
| $method->setAccessible( true ); | ||
| $result = $method->invokeArgs( $api, [ 'x' ] ); |
There was a problem hiding this comment.
| $_SERVER['HTTP_ORIGIN'] = 'null'; | ||
| $_SERVER['REQUEST_METHOD'] = 'POST'; | ||
|
|
||
| $api = new Endpoint_Api(); |
There was a problem hiding this comment.
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| unset( $_SERVER['HTTP_ORIGIN'] ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| $reflection = new ReflectionClass( $api ); | ||
| $method = $reflection->getMethod( 'rest_send_cors_headers' ); | ||
| $method->setAccessible( true ); | ||
| $result = $method->invokeArgs( $api, [ 'payload' ] ); |
There was a problem hiding this comment.
| $_SERVER['HTTP_ORIGIN'] = 'https://allowed.example'; | ||
| $_SERVER['REQUEST_METHOD'] = 'GET'; | ||
|
|
||
| $api = new Endpoint_Api(); |
There was a problem hiding this comment.
| $this->assertSame( 'payload', $result, 'rest_send_cors_headers returns its input unchanged' ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| $reflection = new ReflectionClass( $api ); | ||
| $method = $reflection->getMethod( 'rest_send_cors_headers' ); | ||
| $method->setAccessible( true ); | ||
| $result = $method->invokeArgs( $api, [ 'payload' ] ); |
There was a problem hiding this comment.
| // transitively pinned. Admin::flush_caches IS covered up to the echo+exit by way of | ||
| // the wp_rest_cache/filtered_cache_keys throw-from-filter interceptor below. | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| * @covers \WP_Rest_Cache_Plugin\Includes\API\Endpoint_Api | ||
| * @covers \WP_Rest_Cache_Plugin\Admin\Admin | ||
| */ | ||
| class Test_Exit_Paths extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Exit_Paths" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| use WP_Rest_Cache_Plugin\Includes\API\Endpoint_Api; | ||
| use WP_Rest_Cache_Plugin\Includes\Caching\Caching; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| // after WP test-lib output begins. | ||
| } | ||
|
|
||
| private function count_cache_rows() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function count_cache_rows() (Squiz.Commenting.FunctionComment.Missing).
| return $this->get_private_property( $api, 'cache_key' ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$method" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| return $this->get_private_property( $api, 'cache_key' ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$uri" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
| return $this->get_private_property( $api, 'cache_key' ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$api" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
| $this->assertSame( 1, $this->count_cache_rows() ); | ||
| } | ||
|
|
||
| public function test_save_cache_caches_non_get_method_when_arranged() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_save_cache_caches_non_get_method_when_arranged() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( 0, $this->count_cache_rows() ); | ||
| } | ||
|
|
||
| public function test_save_cache_caches_empty_result_when_skip_filter_returns_false() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_save_cache_caches_empty_result_when_skip_filter_returns_false() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( 'endpoint', $row['cache_type'] ); | ||
| } | ||
|
|
||
| public function test_save_cache_skips_empty_result_set_by_default() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_save_cache_skips_empty_result_set_by_default() (Squiz.Commenting.FunctionComment.Missing).
| } | ||
|
|
||
| public function test_save_cache_caches_a_normal_200_response() { | ||
| $result = [ 'id' => 1, 'title' => 'hello' ]; |
There was a problem hiding this comment.
🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).
| $this->assertSame( 0, $this->count_cache_rows() ); | ||
| } | ||
|
|
||
| public function test_save_cache_caches_a_normal_200_response() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_save_cache_caches_a_normal_200_response() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- save_cache ---------- | ||
|
|
||
| public function test_save_cache_does_not_persist_when_data_status_is_not_200() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertTrue( $api->save_cache_headers( true, $response ) ); | ||
| } | ||
|
|
||
| public function test_cache_headers_filter_can_replace_headers_before_capture() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_cache_headers_filter_can_replace_headers_before_capture() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( '42', $captured['X-Total'] ); | ||
| } | ||
|
|
||
| public function test_save_cache_headers_passes_served_value_through_unchanged() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_save_cache_headers_passes_served_value_through_unchanged() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
|
|
||
| // ---------- save_cache_headers ---------- | ||
|
|
||
| public function test_save_cache_headers_captures_response_headers_into_endpoint_state() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertNotSame( $key_get, $key_post ); | ||
| } | ||
|
|
||
| public function test_cache_key_filter_can_override_the_generated_key() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_cache_key_filter_can_override_the_generated_key() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( $key_get, $key_unset ); | ||
| } | ||
|
|
||
| public function test_build_cache_key_differs_for_non_get_methods() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_build_cache_key_differs_for_non_get_methods() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertNotSame( $key_a, $key_b ); | ||
| } | ||
|
|
||
| public function test_build_cache_key_treats_get_method_as_empty_for_backward_compat() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_build_cache_key_treats_get_method_as_empty_for_backward_compat() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertMatchesRegularExpression( '/^[a-f0-9]{32}$/', $key_a ); | ||
| } | ||
|
|
||
| public function test_build_cache_key_differs_when_uri_differs() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_build_cache_key_differs_when_uri_differs() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- build_cache_key ---------- | ||
|
|
||
| public function test_build_cache_key_is_stable_for_identical_requests() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertSame( '/wp-json/wp/v2/posts', $result ); | ||
| } | ||
|
|
||
| public function test_build_request_uri_strips_home_url_prefix() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_build_request_uri_strips_home_url_prefix() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( '/wp-json/wp/v2/posts?a=1&b=2', $result ); | ||
| } | ||
|
|
||
| public function test_build_request_uri_collapses_leading_double_slash() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_build_request_uri_collapses_leading_double_slash() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( '/wp-json/wp/v2/posts?context=view&page=2&per_page=10', $result ); | ||
| } | ||
|
|
||
| public function test_build_request_uri_drops_uncached_parameters_from_query_string() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_build_request_uri_drops_uncached_parameters_from_query_string() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertSame( '/wp-json/wp/v2/posts', $result ); | ||
| } | ||
|
|
||
| public function test_build_request_uri_sorts_query_parameters_alphabetically() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_build_request_uri_sorts_query_parameters_alphabetically() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
|
|
||
| // ---------- build_request_uri ---------- | ||
|
|
||
| public function test_build_request_uri_strips_trailing_slash() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| ]; | ||
| } | ||
|
|
||
| public function tear_down() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function tear_down() (Squiz.Commenting.FunctionComment.Missing).
| public function set_up() { | ||
| parent::set_up(); | ||
| $this->server_backup = [ | ||
| 'REQUEST_URI' => $_SERVER['REQUEST_URI'] ?? null, |
There was a problem hiding this comment.
🚫 Error: Expected 1 space before "??"; 4 found (WordPress.WhiteSpace.OperatorSpacing.SpacingBefore).
| /** @var array<string,mixed> Snapshot of $_SERVER keys we mutate, restored in tear_down. */ | ||
| private $server_backup = []; | ||
|
|
||
| public function set_up() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function set_up() (Squiz.Commenting.FunctionComment.Missing).
| */ | ||
| class Test_Endpoint_Api extends Caching_Test_Case { | ||
|
|
||
| /** @var array<string,mixed> Snapshot of $_SERVER keys we mutate, restored in tear_down. */ |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| /** | ||
| * @covers \WP_Rest_Cache_Plugin\Includes\API\Endpoint_Api | ||
| */ | ||
| class Test_Endpoint_Api extends Caching_Test_Case { |
There was a problem hiding this comment.
🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Endpoint_Api" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).
| use WP_Rest_Cache_Plugin\Includes\Caching\Caching; | ||
| use WP_Rest_Cache_Plugin\Includes\Util; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).
| return $api; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$endpoint" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
| return $api; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$namespace" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$nonce" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$method" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
|
|
||
| // ----- helpers ----- | ||
|
|
||
| /** |
There was a problem hiding this comment.
🚫 Error: Doc comment for parameter "$request_uri" missing (Squiz.Commenting.FunctionComment.MissingParamTag).
|
|
||
| $this->assertFalse( $api->skip_caching() ); | ||
|
|
||
| unset( $_GET['skip_cache'] ); |
There was a problem hiding this comment.
| unset( $_GET['skip_cache'] ); | ||
| } | ||
|
|
||
| public function test_skip_cache_param_can_be_disabled_via_allow_skip_cache_filter() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_skip_cache_param_can_be_disabled_via_allow_skip_cache_filter() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| $this->assertTrue( $api->skip_caching() ); | ||
|
|
||
| unset( $_GET['skip_cache'] ); |
There was a problem hiding this comment.
|
|
||
| // ---------- skip_cache GET param (documented gap) ---------- | ||
|
|
||
| public function test_skip_cache_query_param_short_circuits_to_skip() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
|
|
||
| // ---------- Custom REST prefix ---------- | ||
|
|
||
| public function test_custom_rest_prefix_option_is_used_for_matching() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertTrue( $api->skip_caching() ); | ||
| } | ||
|
|
||
| public function test_disallowed_entry_for_unrelated_endpoint_does_not_affect_match() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_disallowed_entry_for_unrelated_endpoint_does_not_affect_match() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertFalse( $api->skip_caching() ); | ||
| } | ||
|
|
||
| public function test_disallowed_endpoint_overrides_allowed_match_and_skips_caching() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_disallowed_endpoint_overrides_allowed_match_and_skips_caching() (Squiz.Commenting.FunctionComment.Missing).
| $this->assertTrue( $api->skip_caching() ); | ||
| } | ||
|
|
||
| public function test_uri_matching_an_allowed_endpoint_does_not_skip_caching() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_uri_matching_an_allowed_endpoint_does_not_skip_caching() (Squiz.Commenting.FunctionComment.Missing).
acato-plugins
left a comment
There was a problem hiding this comment.
Previous scan continued.
| $this->assertTrue( $api->skip_caching() ); | ||
| } | ||
|
|
||
| public function test_uri_outside_configured_endpoints_skips_caching() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_uri_outside_configured_endpoints_skips_caching() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Allowed / disallowed endpoint matching ---------- | ||
|
|
||
| public function test_no_configured_allowed_endpoints_skips_caching() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertTrue( $api->skip_caching() ); | ||
| } | ||
|
|
||
| public function test_rest_route_parameter_form_is_recognized_as_rest_request() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_rest_route_parameter_form_is_recognized_as_rest_request() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- REST prefix detection ---------- | ||
|
|
||
| public function test_non_rest_request_uri_skips_caching() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertTrue( $api->skip_caching() ); | ||
| } | ||
|
|
||
| public function test_request_method_added_to_allowlist_is_not_a_skip_reason() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_request_method_added_to_allowlist_is_not_a_skip_reason() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Allowed request methods ---------- | ||
|
|
||
| public function test_request_method_not_in_allowlist_skips_caching() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->assertTrue( $api->skip_caching() ); | ||
| } | ||
|
|
||
| public function test_nonce_header_present_does_not_skip_when_nonce_filter_disabled() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function test_nonce_header_present_does_not_skip_when_nonce_filter_disabled() (Squiz.Commenting.FunctionComment.Missing).
|
|
||
| // ---------- Nonce header ---------- | ||
|
|
||
| public function test_nonce_header_present_skips_caching_by_default() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
|
|
||
| // ---------- Top-of-tree filter ---------- | ||
|
|
||
| public function test_skip_caching_filter_true_short_circuits_immediately() { |
There was a problem hiding this comment.
🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).
| $this->server_backup = [ 'REQUEST_METHOD' => $_SERVER['REQUEST_METHOD'] ?? null ]; | ||
| } | ||
|
|
||
| public function tear_down() { |
There was a problem hiding this comment.
🚫 Error: Missing doc comment for function tear_down() (Squiz.Commenting.FunctionComment.Missing).
| set -ex | ||
|
|
||
| install_wp() { | ||
| if [ -d "$WP_CORE_DIR" ]; then |
There was a problem hiding this comment.
any particular reason not to use wp core download --version=x.y.z here? (just curious)
| /.wordpress-org export-ignore | ||
| /.github export-ignore | ||
| /vendor export-ignore | ||
| /test export-ignore |
There was a problem hiding this comment.
should this not be /tests (plural) as the folder is tests and not test (singular)
| $request_uri = filter_var( $_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL ); | ||
| $url = Util::get_home_url() . $request_uri; | ||
| $creds = request_filesystem_credentials( $url ); | ||
| if ( ! WP_Filesystem( $creds ) ) { |
There was a problem hiding this comment.
regression? if WP_Filesystem fails, what then?
Ik heb unit tests toegevoegd voor de complete plugin. Dat is misschien wat veel om te controleren. Wat wel de moeite waard is voor een review zijn de voorafgaande losse commits, die allemaal kleine code verbeteringen zijn.