Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32702 closed defect (bug) (fixed)

Unit tests should set `$_SERVER['SERVER_NAME']` for `wp_mail()`

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 4.3 Priority: normal
Severity: normal Version:
Component: Mail Keywords:
Focuses: Cc:

Description

When a test calls wp_mail() (directly or indirectly), and when that call to wp_mail() doesn't include an explicit From header, wp_mail() attempts to concatenate a From email out of $_SERVER['SERVER_NAME']. But when running PHPUnit, this variable is not set. Ideally, we'd only fake the SERVER_NAME when wp_mail() requires it, though I don't think there'd be any harm in faking it for every test (it's only used in WP when sending mail).

The tests specific to wp_mail() already do this.

See [32820].

Change History (1)

#1 @boonebgorges
9 years ago

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

In 32839:

Make sure $_SERVER['SERVER_NAME'] is set whenever wp_mail() is called in PHPUnit tests.

This eliminates PHP notices when wp_mail() needs to determine its own From header.

See [25381] for a previous fix, which focused only on the mail-specific tests.

Fixes #32702.

Note: See TracTickets for help on using tickets.