Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#21742 closed enhancement (fixed)

Allow unit tests to override is_*_admin()

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

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 14 years ago.
Rough take on using WP_Screen
21742.2.diff​ (3.8 KB ) - added by ryan 14 years ago.
21742.3.diff​ (4.6 KB ) - added by ryan 14 years ago.
21742-ut.diff​ (2.2 KB ) - added by ryan 14 years ago.
21742.4.diff​ (4.6 KB ) - added by ryan 14 years ago.
21742.5.diff​ (38.1 KB ) - added by nacin 14 years ago.

Download all attachments as: .zip

Change History (11)

@ryan
14 years ago

Rough take on using WP_Screen

@ryan
14 years ago

@ryan
14 years ago

@ryan
14 years ago

@ryan
14 years ago

#1 @ryan
14 years ago

  • Owner set to ryan
  • Resolution → fixed
  • Status new → 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
14 years ago

  • Milestone Awaiting Review → 3.5

@nacin
14 years ago

#3 @ocean90
14 years ago

  • Resolution fixed
  • Status closed → reopened

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

#4 @ryan
14 years ago

In [21693]:

s/blog/site/. see #21742

#5 @ocean90
14 years ago

  • Resolution → fixed
  • Status reopened → closed
Note: See TracTickets for help on using tickets.