Skip to content

Commit

Permalink
bringing the TimeSync component into this component since Zend_Date i…
Browse files Browse the repository at this point in the history
…s the only one that uses it, and they depend on eachother
  • Loading branch information
jaydiablo committed Apr 25, 2018
1 parent 702113c commit 1b53792
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 43 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Zend Framework 1 - Date
Zend Framework 1 - Date & TimeSync
============================
[![Build Status](https://travis-ci.org/diablomedia/zf1-date.svg?branch=master)](https://travis-ci.org/diablomedia/zf1-date)
[![codecov](https://codecov.io/gh/diablomedia/zf1-date/branch/master/graph/badge.svg)](https://codecov.io/gh/diablomedia/zf1-date)
[![Latest Stable Version](https://poser.pugx.org/diablomedia/zendframework1-date/v/stable)](https://packagist.org/packages/diablomedia/zendframework1-date)
[![Total Downloads](https://poser.pugx.org/diablomedia/zendframework1-date/downloads)](https://packagist.org/packages/diablomedia/zendframework1-date)
[![License](https://poser.pugx.org/diablomedia/zendframework1-date/license)](https://packagist.org/packages/diablomedia/zendframework1-date)

This is just the Zend_Date component extracted from our fork of the Zend Framework 1 repo (https://github.com/diablomedia/zf1).
This is just the Zend_Date & Zend_TimeSync components extracted from our fork of the Zend Framework 1 repo (https://github.com/diablomedia/zf1).
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diablomedia/zendframework1-date",
"description": "Zend Framework 1 Date component",
"description": "Zend Framework 1 Date & TimeSync components",
"type": "library",
"keywords": [
"framework",
Expand All @@ -14,8 +14,8 @@
"php": ">=7.0.0",
"diablomedia/zendframework1-exception": "^1.0.0",
"diablomedia/zendframework1-cache": "^1.0.0",
"diablomedia/zendframework1-locale": "^1.0.0",
"diablomedia/zendframework1-timesync": "*"
"diablomedia/zendframework1-loader": "^1.0.0",
"diablomedia/zendframework1-locale": "^1.0.0"
},
"autoload": {
"psr-0": {
Expand All @@ -31,6 +31,9 @@
"phpunit/phpunit": "^6.0",
"phpstan/phpstan": "^0.9.2"
},
"include-path": [
"./src"
],
"archive": {
"exclude": ["/tests"]
},
Expand Down
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ parameters:
- '#Variable \$day might not be defined\.#'
- '#Variable \$leapyear might not be defined\.#'
- '#Variable \$year might not be defined\.#'
- '#Variable \$offset might not be defined\.#'
- '#Variable \$offset might not be defined\.#'
- '#Variable \$masterException might not be defined\.#'
6 changes: 3 additions & 3 deletions src/Zend/TimeSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Zend_TimeSync implements IteratorAggregate
/**
* Holds a reference to the timeserver that is currently being used
*
* @var object|false
* @var Zend_TimeSync_Protocol|false
*/
protected $_current;

Expand Down Expand Up @@ -130,7 +130,7 @@ public function addServer($target, $alias = null)
$this->_addServer($server, $key);
}
} else {
$this->_addServer($target, $alias);
$this->_addServer($target, (string) $alias);
}
}

Expand Down Expand Up @@ -188,7 +188,7 @@ public static function getOptions($key = null)
* If no alias is given it will return the current timeserver
*
* @param string|integer $alias - The alias from the timeserver to return
* @return object
* @return Zend_TimeSync_Protocol
* @throws Zend_TimeSync_Exception
*/
public function getServer($alias = null)
Expand Down
5 changes: 5 additions & 0 deletions src/Zend/TimeSync/Protocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ abstract class Zend_TimeSync_Protocol
*/
protected $_info = array();

/**
* @var int
*/
protected $_port;

/**
* Abstract method that prepares the data to send to the timeserver
*
Expand Down
44 changes: 10 additions & 34 deletions tests/Zend/TimeSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
* @version $Id$
*/

/**
* Zend_timeSync
*/
require_once 'Zend/TimeSync.php';

/**
* @category Zend
Expand Down Expand Up @@ -123,12 +119,8 @@ public function testInitSntpScheme()
*/
public function testInitUnknownScheme()
{
try {
$server = new Zend_TimeSync('http://time.windows.com', 'windows_time');
$this->fail('Exception expected because we supplied an invalid protocol');
} catch (Zend_TimeSync_Exception $e) {
// success
}
$this->expectException(Zend_TimeSync_Exception::class);
$server = new Zend_TimeSync('http://time.windows.com', 'windows_time');
}

/**
Expand Down Expand Up @@ -174,12 +166,8 @@ public function testGetInvalidOptionKey()
{
$server = new Zend_TimeSync();

try {
$result = $server->getOptions('foobar');
$this->fail('Exception expected because we supplied an invalid option key');
} catch (Zend_TimeSync_Exception $e) {
// success
}
$this->expectException(Zend_TimeSync_Exception::class);
$result = $server->getOptions('foobar');
}

/**
Expand All @@ -191,12 +179,8 @@ public function testSetUnknownCurrent()
{
$server = new Zend_TimeSync();

try {
$server->setServer('unknown_alias');
$this->fail('Exception expected because there is no timeserver which we can mark as current');
} catch (Zend_TimeSync_Exception $e) {
// success
}
$this->expectException(Zend_TimeSync_Exception::class);
$server->setServer('unknown_alias');
}

/**
Expand All @@ -208,12 +192,8 @@ public function testGetUnknownCurrent()
{
$server = new Zend_TimeSync();

try {
$result = $server->getServer();
$this->fail('Exception expected because there is no current timeserver set');
} catch (Zend_TimeSync_Exception $e) {
// success
}
$this->expectException(Zend_TimeSync_Exception::class);
$result = $server->getServer();
}

/**
Expand All @@ -225,12 +205,8 @@ public function testGetUnknownServer()
{
$server = new Zend_TimeSync();

try {
$result = $server->getServer('none_existing_server_alias');
$this->fail('Exception expected, because the requested timeserver does not exist');
} catch (Zend_TimeSync_Exception $e) {
// success
}
$this->expectException(Zend_TimeSync_Exception::class);
$result = $server->getServer('none_existing_server_alias');
}

/**
Expand Down

0 comments on commit 1b53792

Please sign in to comment.