-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Excerpt Suggestions integration tests #2671
Conversation
WalkthroughWalkthroughThe changes introduce a new integration test class, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Test
participant ContentHelper
User->>Test: Initiates test for asset enqueueing
Test->>ContentHelper: Checks user role and filter values
ContentHelper-->>Test: Returns enqueue status
Test->>User: Asserts expected enqueue status
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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 (3)
tests/Integration/content-helper/ContentHelperExcerptSuggestionsTest.php (3)
1-6
: Ensure the file header adheres to WordPress coding standards.The file header comment should follow the WordPress PHP coding standards.
- /** - * Integration Tests: PCH Excerpt Suggestions - * - * @package Parsely\Tests - */ + /** + * Integration Tests: PCH Excerpt Suggestions. + * + * @package Parsely\Tests + */
19-31
: Ensure the method docstring adheres to WordPress coding standards.The method docstring should follow the WordPress PHP coding standards.
- * @param mixed $global_filter_value The value of the global filter. - * @param mixed $feature_filter_value The value of the feature filter. - * @param bool $expected Whether the assets should be enqueued. - * @param string $user_login The current user's login. - * @param string $user_role The current user's role. - * @param array<string, mixed> $additional_args Any required additional arguments. + * @param mixed $global_filter_value The value of the global filter. + * @param mixed $feature_filter_value The value of the feature filter. + * @param bool $expected Whether the assets should be enqueued. + * @param string $user_login The current user's login. + * @param string $user_role The current user's role. + * @param array $additional_args Any required additional arguments.
50-74
: Ensure the method docstring adheres to WordPress coding standards.The method docstring should follow the WordPress PHP coding standards.
- * @covers \Parsely\Content_Helper\Content_Helper_Feature::can_enable_feature - * @covers \Parsely\Content_Helper\Excerpt_Generator::run - * @covers \Parsely\Permissions::current_user_can_use_pch_feature - * @covers \Parsely\Permissions::get_user_roles_with_edit_posts_cap - * @uses \Parsely\Content_Helper\Content_Helper_Feature::get_global_filter_name - * @uses \Parsely\Content_Helper\Excerpt_Generator::__construct - * @uses \Parsely\Content_Helper\Excerpt_Generator::can_enable_feature - * @uses \Parsely\Content_Helper\Excerpt_Generator::get_feature_filter_name - * @uses \Parsely\Content_Helper\Excerpt_Generator::get_script_id - * @uses \Parsely\Content_Helper\Excerpt_Generator::get_style_id - * @uses \Parsely\Parsely::__construct - * @uses \Parsely\Parsely::allow_parsely_remote_requests - * @uses \Parsely\Parsely::are_credentials_managed - * @uses \Parsely\Parsely::get_managed_credentials - * @uses \Parsely\Parsely::get_options - * @uses \Parsely\Parsely::set_default_full_metadata_in_non_posts - * @uses \Parsely\Parsely::set_default_track_as_values - * @uses \Parsely\Parsely::set_managed_options + * @covers \Parsely\Content_Helper\Content_Helper_Feature::can_enable_feature. + * @covers \Parsely\Content_Helper\Excerpt_Generator::run. + * @covers \Parsely\Permissions::current_user_can_use_pch_feature. + * @covers \Parsely\Permissions::get_user_roles_with_edit_posts_cap. + * @uses \Parsely\Content_Helper\Content_Helper_Feature::get_global_filter_name. + * @uses \Parsely\Content_Helper\Excerpt_Generator::__construct. + * @uses \Parsely\Content_Helper\Excerpt_Generator::can_enable_feature. + * @uses \Parsely\Content_Helper\Excerpt_Generator::get_feature_filter_name. + * @uses \Parsely\Content_Helper\Excerpt_Generator::get_script_id. + * @uses \Parsely\Content_Helper\Excerpt_Generator::get_style_id. + * @uses \Parsely\Parsely::__construct. + * @uses \Parsely\Parsely::allow_parsely_remote_requests. + * @uses \Parsely\Parsely::are_credentials_managed. + * @uses \Parsely\Parsely::get_managed_credentials. + * @uses \Parsely\Parsely::get_options. + * @uses \Parsely\Parsely::set_default_full_metadata_in_non_posts. + * @uses \Parsely\Parsely::set_default_track_as_values. + * @uses \Parsely\Parsely::set_managed_options.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- tests/Integration/content-helper/ContentHelperExcerptSuggestionsTest.php (1 hunks)
Additional context used
Path-based instructions (1)
tests/Integration/content-helper/ContentHelperExcerptSuggestionsTest.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 (4)
tests/Integration/content-helper/ContentHelperExcerptSuggestionsTest.php (4)
8-8
: Ensure strict types declaration is necessary.The
declare(strict_types=1);
directive enforces strict type checking. Confirm that this is necessary for the integration tests.
10-14
: Optimize imports.Ensure that only necessary classes are imported. Verify if all imported classes are used within the file.
32-48
: LGTM! Ensure parent method functionality.The code changes are approved.
However, ensure that the parent method
assert_enqueued_status_default
is correctly implemented and utilized.Verification successful
Parent method
assert_enqueued_status_default
is correctly implemented and utilized.The method performs the necessary actions to set the user, apply filters, deregister assets, and assert the expected script and style status, ensuring the functionality required by the derived method.
tests/Integration/ContentHelperFeatureTest.php
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the parent method `assert_enqueued_status_default`. # Test: Search for the parent method implementation. Expect: Correct implementation and usage. rg --type php -A 5 $'function assert_enqueued_status_default'Length of output: 520
Script:
#!/bin/bash # Description: Retrieve the full implementation of the parent method `assert_enqueued_status_default`. # Extract the full implementation of the method. rg --type php -A 20 'function assert_enqueued_status_default' tests/Integration/ContentHelperFeatureTest.phpLength of output: 701
75-83
: LGTM! Ensure comprehensive test coverage.The code changes are approved.
However, ensure that the test covers all necessary scenarios and that the assertions are valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Description
This PR adds integration tests for the Excerpt Suggestions feature. It runs all the tests defined in the
ContentHelperFeatureTest
class, plus a test to confirm that PCH User Role permission settings work.Motivation and context
Add more tests.
How has this been tested?
Tests logic has been validated, and tests pass.
Summary by CodeRabbit