Change record status: 
Project: 
Introduced in branch: 
8.0.x
Introduced in version: 
8.0.0-beta10
Description: 

In Drupal 8 the possibility to write unit tests with PHPUnit was added. In versions before 8.0.0-beta10 the REQUEST_TIME constant was defined at the start of the test. This was intended to mimic the constant with the same name which is set in bootstrap.inc during an actual page request.

However this constant has been removed in Drupal 8.0.0-beta10 to pave the way for running functional tests through PHPUnit in the future. Page requests that are performed during functional tests would cause Drupal to set this constant again during its bootstrap phase, and this would cause a conflict.

Developers are now suggested to instead use (int) \Drupal::request()->server->get('REQUEST_TIME') in code intended to be executed during PHPUnit tests.

Before: (Drupal 8.0.0-beta9 and earlier)
Example taken from ViewUIObjectTest::testIsLocked()

$lock = (object) array(
  'owner' => 2,
  'data' => array(),
  'updated' => REQUEST_TIME,
);

After: (Drupal 8.0.0-beta10 and later)
Example taken from ViewUIObjectTest::testIsLocked()

$lock = (object) array(
  'owner' => 2,
  'data' => array(),
  'updated' => (int) \Drupal::request()->server->get('REQUEST_TIME'),
);
Impacts: 
Module developers