Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#21742 closed enhancement (fixed)

Allow unit tests to override is_*_admin()

Reported by: ryan's profile ryan Owned by: ryan's profile ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4.1
Component: Unit Tests Keywords:
Focuses: Cc:

Description

Unit tests sometimes need to fake being in the user, network, or blog admin or on the front page. This is currently impossible due to the use of constants. A possible solution is to consult the current screen if it is setup and fallback to the constants otherwise. Alternatively, add filters in the is_*_admin() functions.

Attachments (6)

21742.diff (3.2 KB) - added by ryan 12 years ago.
Rough take on using WP_Screen
21742.2.diff (3.8 KB) - added by ryan 12 years ago.
21742.3.diff (4.6 KB) - added by ryan 12 years ago.
21742-ut.diff (2.2 KB) - added by ryan 12 years ago.
21742.4.diff (4.6 KB) - added by ryan 12 years ago.
21742.5.diff (38.1 KB) - added by nacin 12 years ago.

Download all attachments as: .zip

Change History (11)

@ryan
12 years ago

Rough take on using WP_Screen

@ryan
12 years ago

@ryan
12 years ago

@ryan
12 years ago

@ryan
12 years ago

#1 @ryan
12 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [21687]:

Introduce WP_Screen::in_admin() for determining which admin the screen is in.
Change is_*_admin() to reference in_admin() with fallback to the WP_*_ADMIN constants during early bootstrap. This allows unit tests and ajax handlers to set the admin context.

fixes #21742

#2 @SergeyBiryukov
12 years ago

  • Milestone changed from Awaiting Review to 3.5

@nacin
12 years ago

#3 @ocean90
12 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Missing dashboard widgets: http://cl.ly/J9gm

#4 @ryan
12 years ago

In [21693]:

s/blog/site/. see #21742

#5 @ocean90
12 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.