-
Notifications
You must be signed in to change notification settings - Fork 109
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
Improve Test Coverage for Speculation Rules Plugin #1845
base: trunk
Are you sure you want to change the base?
Changes from all commits
3af6650
04a08ac
ddc02d0
66eddb7
7519de2
8fd7597
66b31f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,6 @@ private function require_uninstall(): void { | |
|
||
/** | ||
* Test option deletion. | ||
* | ||
* @covers ::plsr_delete_plugin_option | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove this? The function is located in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned here #1845 (comment) Without adding
|
||
*/ | ||
public function test_delete_plugin_option(): void { | ||
unregister_setting( 'reading', 'plsr_speculation_rules' ); | ||
|
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.
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.
Initially I kept the
@covers
annotation just like suggested changes however that's resulting in reduced code coverage.If covers annotation is not there it automatically finds the function that is being tested.
However if we are specifying like this then coverage reduced. Also tested with
ClassName::FunctionName
annotation.cc : @westonruter
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.
Strange. I don't know why that would be.
Nevertheless, I see that the
test_plsr_sanitize_setting()
test is already coveringplsr_sanitize_setting
. Therefore, do we even need thistest_sanitize_setting
test? Should its test cases not be put into thedata_plsr_sanitize_setting
data provider?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.
Ideally it should be added in data_plsr_sanitize_setting data provider but Code coverage is unable to track these 3 lines that are being tested if passed via data provider.
![image](https://private-user-images.githubusercontent.com/69689387/411963267-05d82c8c-c30b-42c5-8783-0f331a03b93e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NjA0NDIsIm5iZiI6MTczOTY2MDE0MiwicGF0aCI6Ii82OTY4OTM4Ny80MTE5NjMyNjctMDVkODJjOGMtYzMwYi00MmM1LTg3ODMtMGYzMzFhMDNiOTNlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDIyNTU0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE5NjNjZDg4NzhhMjYwOWY0YjU3MzMzN2E3Yjc4ZWM2NGQzOTNjYWRiZDgxNDJkNzNjMTNmNzdmYTU1YzkyYmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8a9jI6Ea4_C5XWgDo4hO4mOwzBcHYeTKQGD-vjr-tM0)
However when adding these test in another function and calling
![image](https://private-user-images.githubusercontent.com/69689387/411963921-1fc72bd5-5880-4190-8377-0b7e4c41079a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NjA0NDIsIm5iZiI6MTczOTY2MDE0MiwicGF0aCI6Ii82OTY4OTM4Ny80MTE5NjM5MjEtMWZjNzJiZDUtNTg4MC00MTkwLTgzNzctMGI3ZTRjNDEwNzlhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDIyNTU0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIzNTBmYzc1ZGRhMmMzMDM2NDAzMDRlYTVmOWNiOWNlZTg3ODE1OGVkOWIxOWEwNzQwYTQ4ZmQ4OGNmNDlmMWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.-8xJdTZkdkRIzWRoNTkpcuZxs-ktkYFfuS9_BYRIBg0)
plsr_sanitize_setting()
then it seems to recognise the line being covered.I renamed the function as per @felixarntz suggestion.
cc : @westonruter