/** * Test getting info returned from the server * * @return void */ public function testGetInfo() { if (!constant('TESTS_ZEND_TIMESYNC_ONLINE_ENABLED')) { $this->markTestSkipped('Zend\\TimeSync online tests are not enabled in TestConfiguration'); } $server = new TimeSync\TimeSync('time.windows.com'); $date = $server->getDate(); $result = $server->getInfo(); $this->assertTrue(count($result) > 0); }
/** * Test getting info returned from the server * * @return void */ public function testGetInfo() { $server = new TimeSync\TimeSync('time.windows.com'); try { $date = $server->getDate(); $result = $server->getInfo(); $this->assertTrue(count($result) > 0); } catch (TimeSync\Exception $e) { // nothing } }
public function testTimesync() { try { $server = new TimeSync('ntp://pool.ntp.org', 'alias'); $date1 = $server->getDate(); // need to use the proxy class to simulate time() returning wrong value $date2 = new TestHelper(time()); $info = $server->getInfo(); if ($info['offset'] >= 1 || $info['offset'] <= -1) { $this->assertFalse($date1->getTimestamp() == $date2->getTimestamp()); } else { $this->assertEquals($date1->getTimestamp(), $date2->getTimestamp()); } } catch (\ZendTimeSync\Exception $e) { $this->markTestIncomplete('NTP timeserver not available.'); } }