Skip to content

Refactor some integration tests#2670

Merged
acicovic merged 2 commits into
developfrom
update/refactor-some-integration-tests
Jul 26, 2024
Merged

Refactor some integration tests#2670
acicovic merged 2 commits into
developfrom
update/refactor-some-integration-tests

Conversation

@acicovic

@acicovic acicovic commented Jul 26, 2024

Copy link
Copy Markdown
Collaborator

Description

This PR refactors some integration test functions, as a groundwork for more integration tests work to come.

The most notable change is the introduction of $user_login and $user_role arguments in assert_enqueued_status() functions. This is due to the introduction of the User Role permissions system we've introduced for PCH recently.

Motivation and context

Lay the groundwork to write some more integration tests, and accommodate for the PCH's User Role permissions system.

How has this been tested?

Integration tests pass! 🙂

Summary by CodeRabbit

  • New Features

    • Introduced enhanced user role management in tests with clearer method names.
    • Updated asset enqueueing tests to consider user context, improving validation based on user roles and login status.
  • Bug Fixes

    • Adjusted test methods to utilize updated user setup methods, ensuring consistent behavior across tests.
  • Refactor

    • Streamlined user management methods and parameters, improving clarity and maintainability of test code.
  • Documentation

    • Enhanced test descriptions and assertions to reflect new parameters and functionality.

@acicovic acicovic added the Maintenance & Fixes Ticket/PR related to codebase maintenance tasks label Jul 26, 2024
@acicovic acicovic added this to the Summer 2024 milestone Jul 26, 2024
@acicovic acicovic self-assigned this Jul 26, 2024
@coderabbitai

coderabbitai Bot commented Jul 26, 2024

Copy link
Copy Markdown
Contributor
Walkthrough

Walkthrough

The recent changes focus on enhancing test clarity and maintainability by renaming user management methods across various test classes. Key modifications include replacing methods like set_admin_user() with more descriptive alternatives such as set_current_user_to_admin(), and adding parameters to assert methods to accommodate user roles and logins. This refactor improves code readability, ensuring that user context is explicitly defined in tests, which is crucial for accurate validation of asset enqueueing and API calls.

Changes

Files Change Summary
tests/Integration/BaseUserMetaEndpointTest.php Renamed set_admin_user() to set_current_user_to_admin() for clarity in user role management.
tests/Integration/ContentHelperFeatureTest.php Enhanced assert_enqueued_status method with user context parameters; added assert_enqueued_status_default.
tests/Integration/Endpoints/AnalyticsPostsProxyEndpointTest.php Replaced set_admin_user() with set_current_user_to_admin() in multiple test methods for clarity.
tests/Integration/Endpoints/EditorSidebarSettingsEndpointTest.php Renamed set_admin_user() to set_current_user_to_admin() for clarity.
tests/Integration/Endpoints/ReferrersPostDetailProxyEndpointTest.php Updated method names for setting admin user across multiple tests for improved clarity.
tests/Integration/Endpoints/StatsPostDetailProxyEndpointTest.php Consistently renamed set_admin_user() to set_current_user_to_admin() across test methods.
tests/Integration/ProxyEndpointTest.php Changed login_as_contributor() to set_current_user_to_contributor() for better clarity.
tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php Replaced login_as_contributor() with set_current_user_to_contributor() in API tests for consistency.
tests/Integration/ScriptsTest.php Renamed set_admin_user() to set_current_user_to_admin() in several test cases for better readability.
tests/Integration/TestCase.php Introduced set_current_user_to() method for user management; refactored existing methods for clarity.
tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php Updated assert_enqueued_status for explicit user parameters.
tests/Integration/content-helper/ContentHelperEditorSidebarTest.php Adjusted assert_enqueued_status to include user context parameters; refactored for clarity.
tests/Integration/content-helper/ContentHelperPostListStatsTest.php Modified set_up and assert_enqueued_status to improve clarity with new parameters for user context.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test Cases
    participant U as User Management
    participant A as Asset Management

    T->>U: set_current_user_to_admin()
    U->>U: Verify or create admin user
    U->>T: Admin user context set
    T->>A: assert_enqueued_status(user_context)
    A-->>T: Enqueueing status validated
Loading
sequenceDiagram
    participant T as Test Cases
    participant U as User Management

    T->>U: set_current_user_to_contributor()
    U->>U: Verify or create contributor user
    U->>T: Contributor user context set
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@acicovic acicovic marked this pull request as ready for review July 26, 2024 09:06
@acicovic acicovic requested a review from a team as a code owner July 26, 2024 09:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (2)
tests/Integration/content-helper/ContentHelperEditorSidebarTest.php (1)

36-38: Function calls to assert_enqueued_status do not match the new signature.

The function calls to assert_enqueued_status in the following files need to be updated to include the new parameter array $additional_args = array():

  • tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php
  • tests/Integration/content-helper/ContentHelperEditorSidebarTest.php
  • tests/Integration/content-helper/ContentHelperPostListStatsTest.php
  • tests/Integration/ContentHelperFeatureTest.php

Please ensure that all function calls match the new signature:

protected function assert_enqueued_status(
    $global_filter_value,
    $feature_filter_value,
    bool $expected,
    string $user_login,
    string $user_role,
    array $additional_args = array()
)
Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to assert_enqueued_status match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `assert_enqueued_status` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type php -A 5 $'assert_enqueued_status'

Length of output: 12153


Script:

#!/bin/bash
# Description: Verify all function calls to `assert_enqueued_status` match the new signature including the additional arguments.

# Test: Search for the function usage and check if they include the new parameters.
rg --type php -A 5 'assert_enqueued_status\('

Length of output: 11122

tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php (1)

43-45: Ensure all function calls to assert_enqueued_status match the new signature.

From the search results, it appears that the function assert_enqueued_status is used in multiple test files. However, none of the occurrences include the new argument array $additional_args = array().

  • tests/Integration/content-helper/ContentHelperEditorSidebarTest.php
  • tests/Integration/content-helper/ContentHelperPostListStatsTest.php
  • tests/Integration/ContentHelperFeatureTest.php
  • tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php

Please update all these occurrences to match the new function signature.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to assert_enqueued_status match the new signature.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `assert_enqueued_status` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type php -A 5 $'assert_enqueued_status'

Length of output: 12153

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d0db110 and 0e2a654.

Files selected for processing (13)
  • tests/Integration/BaseUserMetaEndpointTest.php (2 hunks)
  • tests/Integration/ContentHelperFeatureTest.php (23 hunks)
  • tests/Integration/Endpoints/AnalyticsPostsProxyEndpointTest.php (3 hunks)
  • tests/Integration/Endpoints/EditorSidebarSettingsEndpointTest.php (1 hunks)
  • tests/Integration/Endpoints/ReferrersPostDetailProxyEndpointTest.php (3 hunks)
  • tests/Integration/Endpoints/StatsPostDetailProxyEndpointTest.php (3 hunks)
  • tests/Integration/ProxyEndpointTest.php (2 hunks)
  • tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php (3 hunks)
  • tests/Integration/ScriptsTest.php (3 hunks)
  • tests/Integration/TestCase.php (2 hunks)
  • tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php (3 hunks)
  • tests/Integration/content-helper/ContentHelperEditorSidebarTest.php (1 hunks)
  • tests/Integration/content-helper/ContentHelperPostListStatsTest.php (5 hunks)
Files skipped from review due to trivial changes (6)
  • tests/Integration/BaseUserMetaEndpointTest.php
  • tests/Integration/Endpoints/AnalyticsPostsProxyEndpointTest.php
  • tests/Integration/Endpoints/EditorSidebarSettingsEndpointTest.php
  • tests/Integration/Endpoints/ReferrersPostDetailProxyEndpointTest.php
  • tests/Integration/Endpoints/StatsPostDetailProxyEndpointTest.php
  • tests/Integration/ScriptsTest.php
Additional context used
Path-based instructions (7)
tests/Integration/content-helper/ContentHelperEditorSidebarTest.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/ProxyEndpointTest.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/TestCase.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/ContentHelperFeatureTest.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
tests/Integration/content-helper/ContentHelperPostListStatsTest.php (1)

Pattern **/*.{html,php}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the HTML and PHP code to ensure it is well-structured and adheres to best practices.
  • Ensure the code follows WordPress coding standards and is well-documented.
  • Confirm the code is secure and free from vulnerabilities.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Verify code compatibility with the latest version of WordPress, avoiding deprecated functions or features."
Additional comments not posted (22)
tests/Integration/content-helper/ContentHelperEditorSidebarTest.php (2)

25-30: Update the docstring to reflect the new parameters.

The docstring accurately describes the new parameters and their purpose.


40-46: Ensure the new parameters are correctly passed.

The new parameters $user_login and $user_role are correctly passed to parent::assert_enqueued_status_default.

tests/Integration/RemoteAPI/AnalyticsPostsRemoteAPITest.php (3)

56-56: Improved clarity in user setup.

The change to set_current_user_to_contributor improves clarity by explicitly setting the current user context.


82-82: Improved clarity in user setup.

The change to set_current_user_to_contributor improves clarity by explicitly setting the current user context.


108-108: Improved clarity in user setup.

The change to set_current_user_to_contributor improves clarity by explicitly setting the current user context.

tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php (5)

30-35: Update the docstring to reflect the new parameters.

The docstring accurately describes the new parameters and their purpose.


47-48: Ensure the new parameters are correctly passed.

The new parameters $user_login and $user_role are correctly passed to set_current_user_to.


56-62: Ensure the screen context is correctly set.

The screen context is correctly set using set_current_screen and get_string_value_from_array.


97-97: Update the test case to reflect the new parameters.

The test case correctly passes the new parameters to assert_enqueued_status.


124-131: Update the test case to reflect the new parameters.

The test case correctly passes the new parameters to assert_enqueued_status.

tests/Integration/ProxyEndpointTest.php (2)

232-232: Verify the correctness of the new user login method.

Ensure that set_current_user_to_contributor() correctly sets the current user to a contributor.


213-213: Verify the correctness of the new user login method.

Ensure that set_current_user_to_contributor() correctly sets the current user to a contributor.

tests/Integration/TestCase.php (4)

448-449: Verify the parameters for setting the admin user.

Ensure that the parameters 'admin' and 'administrator' are correct for setting the current user to the admin account.

Verification successful

The parameters for setting the admin user are correct.

The parameters 'admin' and 'administrator' used in the set_current_user_to_admin method are consistent with the expected parameters of the set_current_user_to method.

  • set_current_user_to('admin', 'administrator') is used correctly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the parameters for setting the admin user.

# Test: Search for the method definition and usage. Expect: Correct parameters for setting the admin user.
rg --type php $'function set_current_user_to_admin'

Length of output: 136


Script:

#!/bin/bash
# Description: Verify the parameters for setting the admin user.

# Search for the definition of the `set_current_user_to` method to inspect its parameters.
rg --type php 'function set_current_user_to'

Length of output: 337


Script:

#!/bin/bash
# Description: Verify the parameters for setting the admin user.

# Search for the usage of the `set_current_user_to` method to confirm the correctness of the parameters.
rg --type php 'set_current_user_to'

Length of output: 2881


705-726: Verify the correctness of the get_string_value_from_array method.

Ensure that the method correctly retrieves a string value from an associative array and handles validation.

Verification successful

The get_string_value_from_array method is correctly implemented.

The method accurately retrieves a string value from an associative array and handles validation as expected:

  • Checks if the key exists in the array.
  • Ensures the value is a string.
  • Returns the default value if validation fails.

No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `get_string_value_from_array` method.

# Test: Search for the method definition. Expect: Correct implementation of retrieving and validating string values from an array.
rg --type php $'function get_string_value_from_array'

Length of output: 141


Script:

#!/bin/bash
# Description: Retrieve the full implementation of the `get_string_value_from_array` method for verification.

# Use ast-grep to extract the method implementation from the codebase.
ast-grep --lang php --pattern $'protected static function get_string_value_from_array(
	array $data,
	string $key,
	string $default_value
): string {
	$_
}'

Length of output: 264


Script:

#!/bin/bash
# Description: Retrieve the full implementation of the `get_string_value_from_array` method for verification.

# Use rg to search for the method definition and include context lines to capture the full implementation.
rg --type php 'protected static function get_string_value_from_array' -A 20

Length of output: 700


424-443: Verify the correctness of the set_current_user_to method.

Ensure that the method correctly creates the user if it doesn't exist and sets the current user.

Verification successful

The set_current_user_to method correctly creates and sets the current user.

  • The create_test_user method creates a user with the specified login and role.
  • The get_user_by and wp_set_current_user functions are standard WordPress functions and can be assumed to work correctly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `set_current_user_to` method.

# Test: Search for the method definition. Expect: Correct implementation of creating and setting the current user.
rg --type php $'function set_current_user_to'

Length of output: 337


Script:

#!/bin/bash
# Description: Verify the implementation details of the `set_current_user_to` method.

# Extract the implementation of the `create_test_user` method.
rg --type php -A 10 'function create_test_user'

# Extract the implementation of the `get_user_by` function.
rg --type php -A 10 'function get_user_by'

# Extract the implementation of the `wp_set_current_user` function.
rg --type php -A 10 'function wp_set_current_user'

Length of output: 737


Script:

#!/bin/bash
# Description: Verify the implementation details of the `set_current_user_to` method.

# Search for the implementation of the `get_user_by` function.
rg --type php -A 10 'function get_user_by'

# Search for the implementation of the `wp_set_current_user` function.
rg --type php -A 10 'function wp_set_current_user'

Length of output: 97


455-456: Verify the parameters for setting the contributor user.

Ensure that the parameters 'test_contributor' and 'contributor' are correct for setting the current user to a contributor account.

tests/Integration/ContentHelperFeatureTest.php (3)

23-40: Verify the correctness of the assert_enqueued_status method.

Ensure that the method correctly handles the new parameters for user login and role.


43-76: Verify the correctness of the assert_enqueued_status_default method.

Ensure that the method correctly sets the current user and performs assertions on the enqueueing status of assets.

Verification successful

The assert_enqueued_status_default method correctly sets the current user and performs assertions on the enqueueing status of assets.

  • The method sets the current user using $this->set_current_user_to( $user_login, $user_role ).
  • It applies the necessary filters with self::set_filters.
  • It deregisters the feature assets and runs the feature with self::deregister_feature_assets_and_run.
  • Finally, it asserts the enqueueing status of scripts and styles using self::assertSame.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `assert_enqueued_status_default` method.

# Test: Search for the method definition. Expect: Correct implementation of setting the current user and performing assertions.
rg --type php $'function assert_enqueued_status_default'

Length of output: 156


Script:

#!/bin/bash
# Extract the full implementation of the `assert_enqueued_status_default` method for review.
rg --type php -A 20 'function assert_enqueued_status_default' tests/Integration/ContentHelperFeatureTest.php

Length of output: 701


118-137: Verify the correctness of the deregister_feature_assets_and_run method.

Ensure that the method correctly deregisters the feature's assets and calls the run method.

Verification successful

Verify the correctness of the deregister_feature_assets_and_run method.

The method relies on get_script_id, get_style_id, and run methods, which are implemented in derived classes of Content_Helper_Feature. The implementations in derived classes such as src/content-helper/excerpt-generator/class-excerpt-generator.php appear to be correct and ensure the proper functioning of deregister_feature_assets_and_run.

  • src/content-helper/excerpt-generator/class-excerpt-generator.php: Implements get_script_id, get_style_id, and run methods.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `deregister_feature_assets_and_run` method.

# Test: Search for the method definition. Expect: Correct implementation of deregistering assets and calling the run method.
rg --type php $'function deregister_feature_assets_and_run'

Length of output: 169


Script:

#!/bin/bash
# Description: Verify the implementation of the `deregister_feature_assets_and_run` method by checking related methods in Content_Helper_Feature class.

# Find the Content_Helper_Feature class definition.
rg --type php --pattern 'class Content_Helper_Feature'

# Find the get_script_id method in the Content_Helper_Feature class.
rg --type php --pattern 'function get_script_id'

# Find the get_style_id method in the Content_Helper_Feature class.
rg --type php --pattern 'function get_style_id'

# Find the run method in the Content_Helper_Feature class.
rg --type php --pattern 'function run'

Length of output: 1846


Script:

#!/bin/bash
# Description: Verify the implementation of the `deregister_feature_assets_and_run` method by checking related methods in Content_Helper_Feature class.

# Find the Content_Helper_Feature class definition.
rg 'class Content_Helper_Feature' --type php

# Find the get_script_id method in the Content_Helper_Feature class.
rg 'function get_script_id' --type php

# Find the get_style_id method in the Content_Helper_Feature class.
rg 'function get_style_id' --type php

# Find the run method in the Content_Helper_Feature class.
rg 'function run' --type php

Length of output: 5319

tests/Integration/content-helper/ContentHelperPostListStatsTest.php (3)

56-56: LGTM! Improved method name clarity.

The change from set_admin_user() to set_current_user_to_admin() enhances readability.


136-136: LGTM! Updated test method to match new function signature.

The test method now provides explicit user context, improving the accuracy of the test.


74-79: LGTM! Enhanced parameter clarity and type safety.

The addition of user_login and user_role parameters and the replacement of the variadic argument with a typed array improve type safety and make the user context explicit.

However, ensure that all function calls to assert_enqueued_status match the new signature.

Verification successful

All function calls to assert_enqueued_status match the new signature.

The changes to the assert_enqueued_status method, including the addition of user_login and user_role parameters and the replacement of the variadic argument with a typed array, have been correctly applied throughout the codebase.

  • Verified instances in:
    • tests/Integration/ContentHelperFeatureTest.php
    • tests/Integration/content-helper/ContentHelperPostListStatsTest.php
    • tests/Integration/content-helper/ContentHelperDashboardWidgetTest.php
    • tests/Integration/content-helper/ContentHelperEditorSidebarTest.php
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `assert_enqueued_status` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type php -A 5 $'assert_enqueued_status'

Length of output: 12153

@vaurdan vaurdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thank you for improving the tests! 🙂

@acicovic acicovic merged commit e4c7d99 into develop Jul 26, 2024
@acicovic acicovic deleted the update/refactor-some-integration-tests branch July 26, 2024 14:39
@acicovic acicovic modified the milestones: Summer 2024, 3.17.0 Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance & Fixes Ticket/PR related to codebase maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants