コード例 #1
0
ファイル: TimeSyncTest.php プロジェクト: jsnshrmn/Suma
 /**
  * Test getting info returned from the server
  *
  * @return void
  */
 public function testGetInfo()
 {
     $server = new Zend_TimeSync('time.windows.com');
     try {
         $date = $server->getDate();
         $result = $server->getInfo();
         $this->assertTrue(count($result) > 0);
     } catch (Zend_TimeSync_Exception $e) {
         // nothing
     }
 }
コード例 #2
0
ファイル: DateTest.php プロジェクト: jsnshrmn/Suma
 public function testTimesync()
 {
     try {
         $server = new Zend_TimeSync('ntp://pool.ntp.org', 'alias');
         $date1 = $server->getDate();
         // need to use the proxy class to simulate time() returning wrong value
         $date2 = new Zend_Date_TestHelper(time());
         $info = $server->getInfo();
         if ($info['offset'] >= 0.5 || $info['offset'] <= -0.52) {
             $this->assertFalse($date1->getTimestamp() == $date2->getTimestamp());
         } else {
             $this->assertEquals($date1->getTimestamp(), $date2->getTimestamp());
         }
     } catch (Zend_TimeSync_Exception $e) {
         $this->markTestIncomplete('NTP timeserver not available.');
     }
 }
コード例 #3
0
ファイル: DateTest.php プロジェクト: jorgenils/zend-framework
 public function testTimesync()
 {
     // @todo: when the Zend_TimeSync adapter moves out of the incubator,
     // the following hack to allow it to be loaded should be removed.
     // see also ZF-954
     $incubator = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'incubator' . DIRECTORY_SEPARATOR . 'library';
     $include_path = get_include_path();
     set_include_path($include_path . PATH_SEPARATOR . $incubator);
     try {
         Zend_Loader::loadClass('Zend_TimeSync');
         Zend_Loader::loadClass('Zend_TimeSync_Ntp');
     } catch (Zend_Exception $e) {
         $this->markTestIncomplete($e->getMessage());
     }
     set_include_path($include_path);
     // @todo: end of hack
     try {
         $server = new Zend_TimeSync('ntp://pool.ntp.org', 'alias');
         $date1 = $server->getDate();
         // need to use the proxy class to simulate time() returning wrong value
         $date2 = new Zend_Date_TestHelper(time());
         $info = $server->getInfo();
         if ($info['offset'] != 0) {
             $this->assertFalse($date1->getTimestamp() == $date2->getTimestamp());
         } else {
             $this->assertSame($date1->getTimestamp(), $date2->getTimestamp());
         }
     } catch (Zend_TimeSync_Exception $e) {
         $this->markTestIncomplete('NTP timeserver not available.');
     }
 }