Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#32636 closed defect (bug) (fixed)

$_SERVER['REQUEST_METHOD'] isn't set in the test environment

Reported by: johnbillion Owned by: wonderboymusic
Priority: normal Milestone: 4.3
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

A plugin of mine calls wp_validate_auth_cookie() in its unit tests, but this triggers a PHP notice because this function uses $_SERVER['REQUEST_METHOD'] which isn't set in the WordPress unit test environment.

Attachments (1)

32636.patch (965 bytes ) - added by johnbillion 11 years ago.

Download all attachments as: .zip

Change History (6)

@johnbillion
11 years ago

#1 @johnbillion
11 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Awaiting Review4.3

32636.patch sets $_SERVER['REQUEST_METHOD'] to GET in the test environment to prevent wp_validate_auth_cookie() triggering a PHP notice.

All tests remain passing with this change.

#2 @boonebgorges
11 years ago

Patch seems good to me, but make sure you check the AJAX tests before committing it, as many of them assume POST and I'm not sure if your change will override that.

#3 @johnbillion
11 years ago

The AJAX tests do indeed pass. They look at DOING_AJAX and the $_POST superglobal, but not the request method.

I've just noticed that Tests_Auth:setUp() explicitly sets $_SERVER['REQUEST_METHOD'] to null, presumably to avoid said PHP notice.

#4 @wonderboymusic
11 years ago

I added that setting to null to avoid said notice. This looks good. This is what I should have done originally.

#5 @wonderboymusic
11 years ago

  • Owner set to wonderboymusic
  • Resolutionfixed
  • Status newclosed

In 32785:

Set $_SERVER['REQUEST_METHOD'] for unit tests.

Props johnbillion.
Fixes #32636.

Note: See TracTickets for help on using tickets.