WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 6 months ago

#47439 closed defect (bug) (fixed)

wp-phpunit: go_to() does not unset current_screen

Reported by: mauteri Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.3
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:
PR Number:

Description

current_screen should be added to this array for unsetting: https://github.com/wp-phpunit/wp-phpunit/blob/master/includes/abstract-testcase.php#L710

As of now, if you set_current_screen (which is automatically done in WP_Ajax_UnitTestCase to set_current_screen( 'ajax' )) is_admin() will be true when you tell your test, for example, $this->go_to( '/' ); A test like this will fail:

$this->go_to( '/' ); // go to homepage
$this->assertFalse( is_admin() ); // fails because is_admin() is true

Attachments (1)

47439.patch (823 bytes) - added by mauteri 6 months ago.

Download all attachments as: .zip

Change History (4)

@mauteri
6 months ago

#1 @mauteri
6 months ago

  • Keywords has-patch added

#2 @SergeyBiryukov
6 months ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @SergeyBiryukov
6 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 45486:

Build/Test Tools: Add $current_screen to the list of globals to unset in WP_UnitTestCase_Base::go_to().

Props mauteri.
Fixes #47439.

Note: See TracTickets for help on using tickets.