Skip to content

Unit tests - #33

Closed
richardkorthuis wants to merge 14 commits into
masterfrom
develop
Closed

richardkorthuis wants to merge 14 commits into
masterfrom
develop

Conversation

@richardkorthuis

Copy link
Copy Markdown
Collaborator

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.

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

🚫 175 errors

⚠️ 25 warnings


hashes-api-scanning skipped

Posting will continue in further review(s)

Comment thread tests/test-class-util.php
);
}

public function test_get_home_url_does_not_leak_the_skip_convert_filter_after_returning() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_get_home_url_does_not_leak_the_skip_convert_filter_after_returning() (Squiz.Commenting.FunctionComment.Missing).

Comment thread tests/test-class-util.php
add_filter(
'home_url',
function ( $home_url ) use ( &$skip_value_during_call ) {
$skip_value_during_call = apply_filters( 'wpml_skip_convert_url_string', false );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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).

Comment thread tests/test-class-util.php
$this->assertSame( get_home_url(), Util::get_home_url() );
}

public function test_get_home_url_applies_the_wpml_skip_convert_filter_during_the_call() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_get_home_url_applies_the_wpml_skip_convert_filter_during_the_call() (Squiz.Commenting.FunctionComment.Missing).

Comment thread tests/test-class-util.php
*/
class Test_Util extends Caching_Test_Case {

public function test_get_home_url_returns_the_wordpress_home_url() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_get_home_url_returns_the_wordpress_home_url() (Squiz.Commenting.FunctionComment.Missing).

Comment thread tests/test-class-util.php
/**
* @covers \WP_Rest_Cache_Plugin\Includes\Util
*/
class Test_Util extends Caching_Test_Case {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Classes declared by a theme/plugin should start with the theme/plugin prefix. Found: "Test_Util" (WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound).

Comment thread tests/test-class-util.php

use WP_Rest_Cache_Plugin\Includes\Util;

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

);
}

public function test_global_cacheable_request_headers_input_reflects_stored_value() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function render() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

/**
* @covers \WP_Rest_Cache_Plugin\Admin\Admin
*/
class Test_Sub_Settings_Partial extends Caching_Test_Case {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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
*/

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$method" missing (Squiz.Commenting.FunctionComment.MissingParamTag).


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$class" missing (Squiz.Commenting.FunctionComment.MissingParamTag).


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).

);
}

public function test_oembed_api_processes_cache_relations() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_oembed_api_processes_cache_relations() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

);
}

public function test_object_type_determination_has_both_endpoint_and_oembed_handlers() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).

);
}

public function test_regenerate_cron_event_runs_regenerate_expired_caches() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_set_object_terms_is_hooked() (Squiz.Commenting.FunctionComment.Missing).

);
}

public function test_transition_post_status_is_hooked() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_transition_post_status_is_hooked() (Squiz.Commenting.FunctionComment.Missing).

);
}

public function test_delete_post_is_hooked() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_delete_post_is_hooked() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

);
}

public function test_save_post_is_hooked_at_priority_999() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

);
}

private function assertRelationExists( $cache_id, $object_id, $object_type ) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function assertRelationExists() (Squiz.Commenting.FunctionComment.Missing).

);
}

private function count_relations_for( $cache_id ) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function count_relations_for() (Squiz.Commenting.FunctionComment.Missing).


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_oembed_request_post_id_filter_can_override_post_resolution() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

);
}

public function test_add_oembed_endpoint_preserves_other_namespaces() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).

/** @var Oembed_Api */
private $api;

public function set_up() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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';

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

/**
* @covers \WP_Rest_Cache_Plugin\Includes\API\Oembed_Api
*/
class Test_Oembed_Api extends Caching_Test_Case {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

);
}

private function should_use_custom_class( $class_name, $type ) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function should_use_custom_class() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 26 spaces but found 1 space (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

$this->assertSame( 'WC_REST_Products_Controller', $result['rest_controller_class'] );
}

public function test_post_type_args_are_returned_unchanged_apart_from_controller_swap() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_already_custom_attachment_controller_remains_attachment_controller() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

$this->assertSame( Attachment_Controller::class, $result['rest_controller_class'] );
}

public function test_already_custom_post_controller_remains_post_controller() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).

/** @var Item_Api */
private $api;

public function set_up() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function set_up() (Squiz.Commenting.FunctionComment.Missing).

*/
class Test_Item_Api extends Caching_Test_Case {

/** @var Item_Api */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_success_message_includes_count_of_affected_caches() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

$this->assertStringNotContainsString( 'Deleted ', $this->logger->stdout );
}

public function test_success_message_uses_deleted_verb_when_delete_flag_is_set() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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' ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 4 spaces but found 6 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

// ---------- 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' ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 1 space but found 3 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).


// ---------- With object_type AND --related: per-object relation flush ----------

public function test_flush_with_object_type_and_related_flushes_only_that_object_relation() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: When a multi-item array uses associative keys, each value should start on a new line (WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.


// ---------- With object_type but no --related: per-type sweep ----------

public function test_flush_with_object_type_targets_only_that_type() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function tear_down() (Squiz.Commenting.FunctionComment.Missing).

/** @var \WP_CLI\Loggers\Execution */
private $logger;

public function set_up() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function set_up() (Squiz.Commenting.FunctionComment.Missing).

/** @var Flush_Command */
private $command;

/** @var \WP_CLI\Loggers\Execution */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

*/
class Test_Flush_Command extends Caching_Test_Case {

/** @var Flush_Command */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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';

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.


$this->assertTrue( true );

unset( $_GET['sub'] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).

unset( $_GET['sub'] );
}

public function test_settings_page_treats_path_traversal_sub_value_as_default_settings() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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'] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).

unset( $_GET['sub'] );
}

public function test_settings_page_falls_back_to_default_for_unknown_sub() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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'] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).

$this->assertSame( '0', $cleaned );
}

public function test_settings_page_loads_known_sub_partial() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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' ] ];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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' ] ];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: ini_set('error_log', $previous_log) found. Changing configuration values at runtime is strongly discouraged (WordPress.PHP.IniSet.Risky).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: file_get_contents() is discouraged. Use wp_remote_get() for remote URLs instead (WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents).

$payload = [ 'data' => [ 'id' => 1 ] ];

$log_file = tempnam( sys_get_temp_dir(), 'wprc-errlog-' );
$previous_log = ini_set( 'error_log', $log_file );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: ini_set('error_log', $log_file) found. Changing configuration values at runtime is strongly discouraged (WordPress.PHP.IniSet.Risky).

*/
class Test_Final_Fillers extends Caching_Test_Case {

public function test_set_cache_logs_to_error_log_when_set_transient_returns_false() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 );
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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';

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 11 spaces but found 12 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

$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';

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 10 spaces but found 11 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

wp_set_current_user( $user_id );

$nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' );
$_POST['wp_rest_cache_nonce'] = $nonce;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 4 spaces but found 5 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

$user_id = self::factory()->user->create( [ 'role' => 'administrator' ] );
wp_set_current_user( $user_id );

$nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 27 spaces but found 28 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

( new Admin( 'wp-rest-cache', '2026.2.0' ) )->flush_caches();
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

wp_set_current_user( $user_id );

$nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' );
$_POST['wp_rest_cache_nonce'] = $nonce;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 4 spaces but found 5 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

$user_id = self::factory()->user->create( [ 'role' => 'subscriber' ] );
wp_set_current_user( $user_id );

$nonce = wp_create_nonce( 'wp_rest_cache_clear_cache_ajax' );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 27 spaces but found 28 spaces (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

unset( $_SERVER['HTTP_ORIGIN'] );
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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' ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned correctly; expected 1 space but found 5 spaces (Generic.Formatting.MultipleStatementAlignment.IncorrectWarning).

$_SERVER['HTTP_ORIGIN'] = 'null';
$_SERVER['REQUEST_METHOD'] = 'POST';

$api = new Endpoint_Api();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

unset( $_SERVER['HTTP_ORIGIN'] );
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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' ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned correctly; expected 1 space but found 5 spaces (Generic.Formatting.MultipleStatementAlignment.IncorrectWarning).

$_SERVER['HTTP_ORIGIN'] = 'https://allowed.example';
$_SERVER['REQUEST_METHOD'] = 'GET';

$api = new Endpoint_Api();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space (Generic.Formatting.MultipleStatementAlignment.NotSameWarning).

$this->assertSame( 'payload', $result, 'rest_send_cors_headers returns its input unchanged' );
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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' ] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Equals sign not aligned correctly; expected 1 space but found 5 spaces (Generic.Formatting.MultipleStatementAlignment.IncorrectWarning).

// 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.

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

// after WP test-lib output begins.
}

private function count_cache_rows() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function count_cache_rows() (Squiz.Commenting.FunctionComment.Missing).

return $this->get_private_property( $api, 'cache_key' );
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$method" missing (Squiz.Commenting.FunctionComment.MissingParamTag).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

return $this->get_private_property( $api, 'cache_key' );
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$uri" missing (Squiz.Commenting.FunctionComment.MissingParamTag).

return $this->get_private_property( $api, 'cache_key' );
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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' ];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_save_cache_headers_passes_served_value_through_unchanged() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.


// ---------- save_cache_headers ----------

public function test_save_cache_headers_captures_response_headers_into_endpoint_state() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_build_request_uri_sorts_query_parameters_alphabetically() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.


// ---------- build_request_uri ----------

public function test_build_request_uri_strips_trailing_slash() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: You must use "/**" style comments for a function comment (Squiz.Commenting.FunctionComment.WrongStyle).

];
}

public function tear_down() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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. */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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;

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing short description in doc comment (Generic.Commenting.DocComment.MissingShort).

return $api;
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$endpoint" missing (Squiz.Commenting.FunctionComment.MissingParamTag).

return $api;
}

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$namespace" missing (Squiz.Commenting.FunctionComment.MissingParamTag).


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$nonce" missing (Squiz.Commenting.FunctionComment.MissingParamTag).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$method" missing (Squiz.Commenting.FunctionComment.MissingParamTag).


// ----- helpers -----

/**

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Doc comment for parameter "$request_uri" missing (Squiz.Commenting.FunctionComment.MissingParamTag).


$this->assertFalse( $api->skip_caching() );

unset( $_GET['skip_cache'] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).

unset( $_GET['skip_cache'] );
}

public function test_skip_cache_param_can_be_disabled_via_allow_skip_cache_filter() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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'] );

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).


// ---------- skip_cache GET param (documented gap) ----------

public function test_skip_cache_query_param_short_circuits_to_skip() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function test_uri_matching_an_allowed_endpoint_does_not_skip_caching() (Squiz.Commenting.FunctionComment.Missing).

@acato-plugins acato-plugins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous scan continued.

$this->assertTrue( $api->skip_caching() );
}

public function test_uri_outside_configured_endpoints_skips_caching() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Error: Missing doc comment for function tear_down() (Squiz.Commenting.FunctionComment.Missing).

Comment thread bin/install-wp-tests.sh
set -ex

install_wp() {
if [ -d "$WP_CORE_DIR" ]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason not to use wp core download --version=x.y.z here? (just curious)

Comment thread .gitattributes Outdated
/.wordpress-org export-ignore
/.github export-ignore
/vendor export-ignore
/test export-ignore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ) ) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regression? if WP_Filesystem fails, what then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants