Пример #1
0
 /**
  * 第二引数を省略した場合に, システム時刻の時差が設定されることを確認します.
  * @covers Peach\DT\ShiftFormat::__construct
  */
 public function test__construct()
 {
     $f = W3cDatetimeFormat::getInstance();
     $test = new ShiftFormat($f, 300);
     $expected = new ShiftFormat($f, 300, -540);
     $this->assertEquals($expected, $test);
 }
Пример #2
0
 /**
  * getInstance() のテストです. 以下を確認します.
  * 
  * - parse 時にタイムゾーン文字列をすべて無視する
  * - format 時にタイムゾーン文字列を付与しない
  * 
  * @covers Peach\DT\W3cDatetimeFormat::getInstance
  */
 public function testGetInstance()
 {
     $obj = W3cDatetimeFormat::getInstance();
     $this->assertEquals(new Datetime(2012, 5, 21, 7, 30), $obj->parseDatetime("2012-05-21T07:30+05:00"));
     $this->assertEquals(new Timestamp(2012, 5, 21, 7, 30, 45), $obj->parseTimestamp("2012-05-21T07:30:45-06:30"));
     $this->assertSame("2012-05-21T07:30", $obj->formatDatetime(new Datetime(2012, 5, 21, 7, 30)));
     $this->assertSame("2012-05-21T07:30:45", $obj->formatTimestamp(new Timestamp(2012, 5, 21, 7, 30, 45)));
 }
Пример #3
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $original = W3cDatetimeFormat::getInstance();
     $f = new FormatWrapper($original);
     $this->object = $f;
 }
Пример #4
0
 /**
  * ラップ対象のオブジェクトと同じ結果を返すことを確認します.
  * @covers Peach\DT\TimeWrapper::format
  */
 public function testFormat()
 {
     $d = new TimeWrapper(new Timestamp(2012, 5, 21, 7, 30, 15));
     $this->assertSame("2012-05-21 07:30:15", $d->format());
     $this->assertSame("2012-05-21T07:30:15", $d->format(W3cDatetimeFormat::getInstance()));
 }