Opened 8 years ago
Last modified 4 years ago
#38433 new enhancement
Complete test coverage for current_user_can_for_blog()
Reported by: | johnbillion | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | Role/Capability | Keywords: | needs-unit-tests good-first-bug has-patch needs-dev-note |
Focuses: | Cc: |
Description
In Tests_User_Capabilities
, all roles and capabilities are tested using current_user_can()
. They should all be tested using current_user_can_for_blog()
, too.
Attachments (3)
Change History (8)
#2
in reply to:
↑ description
;
follow-up:
↓ 3
@
5 years ago
I'v duplicated the calls in one function: test_subscriber_cant_edit_posts
with the desired result, but then I have added a new function to test that an editor CAN edit their posts but no others in another site, but it looks like current_user_can_for_blog
takes the current site when the other site doesn't exist.
I'll attach the diff and the output.
#3
in reply to:
↑ 2
@
5 years ago
Replying to santilinwp:
I'v duplicated the calls in one function:
test_subscriber_cant_edit_posts
with the desired result, but then I have added a new function to test that an editor CAN edit their posts but no others in another site, but it looks likecurrent_user_can_for_blog
takes the current site when the other site doesn't exist.
I'll attach the diff and the output.
Digging a little bit more in the code I've learnt that current_user_can_for_blog
just disregards the $blog_id
parameter if not is_multisite
, so the test is allright.
#4
@
5 years ago
- Keywords has-patch needs-dev-note added; needs-patch removed
I understand that the way to go is duplicate most of the functions to make multisite and not multisite versions, like in the attached example.
@
5 years ago
An extended patch which demostrates the duplicating of tests (multisite and not multisite)
Marking
good-first-bug
for someone that would like to dive into writing unit tests.