<?php

final class PhabricatorLocalTimeTestCase extends PhabricatorTestCase {

  public function testLocalTimeFormatting() {
    $user = new PhabricatorUser();
    $user->overrideTimezoneIdentifier('America/Los_Angeles');

    $utc = new PhabricatorUser();
    $utc->overrideTimezoneIdentifier('UTC');

    $this->assertEqual(
      'Jan 1 2000, 12:00 AM',
      phabricator_datetime(946684800, $utc),
      pht('Datetime formatting'));
    $this->assertEqual(
      'Jan 1 2000',
      phabricator_date(946684800, $utc),
      pht('Date formatting'));
    $this->assertEqual(
      '12:00 AM',
      phabricator_time(946684800, $utc),
      pht('Time formatting'));

    $this->assertEqual(
      'Dec 31 1999, 4:00 PM',
      phabricator_datetime(946684800, $user),
      pht('Localization'));

    $this->assertEqual(
      '',
      phabricator_datetime(0, $user),
      pht('Missing epoch should fail gracefully'));
  }

}

<?php

final class PhabricatorLocalTimeTestCase extends PhabricatorTestCase {

  protected function getPhabricatorTestCaseConfiguration() {
    return array(
      self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
    );
  }

  public function testLocalTimeFormatting() {
    $user = $this->generateNewTestUser();
    $user->overrideTimezoneIdentifier('America/Los_Angeles');

    $utc = $this->generateNewTestUser();
    $utc->overrideTimezoneIdentifier('UTC');

    $this->assertEqual(
      'Jan 1 2000, 12:00 AM',
      phabricator_datetime(946684800, $utc),
      pht('Datetime formatting'));
    $this->assertEqual(
      'Jan 1 2000',
      phabricator_date(946684800, $utc),
      pht('Date formatting'));
    $this->assertEqual(
      '12:00 AM',
      phabricator_time(946684800, $utc),
      pht('Time formatting'));

    $this->assertEqual(
      'Dec 31 1999, 4:00 PM',
      phabricator_datetime(946684800, $user),
      pht('Localization'));

    $this->assertEqual(
      '',
      phabricator_datetime(0, $user),
      pht('Missing epoch should fail gracefully'));
  }

}

Fix local time test case for logged-out viewers using global settings
Fix local time test case for logged-out viewers using global settings

Summary:
In D16936, I changed logged-out viewers so they use global settings.

This can lead to a `SELECT` from an isolated unit test. Instead, give the test fixtures and use standard `generateNewUser()` stuff.

Test Plan: Ran `arc unit --everything`.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D16952
