public function testOptions() { $server = new Zend_TimeSync($this->timeservers); $options = array('timeout' => 1); $server->setOptions($options); $this->assertEquals(Zend_TimeSync::$options['timeout'], $server->getOption('timeout')); try { $server->setOptions(array('$' => 10)); $this->fail('Exception expected because of invalid option key'); } catch (Zend_TimeSync_Exception $e) { // success } try { $server->setOptions('foobar'); $this->fail('Exception expected because we did not supply an array'); } catch (Zend_TimeSync_Exception $e) { // success } $this->assertEquals(count($server->getOptions()), 1); try { $server->getOption('noneexistingkey'); $this->fail('Exception expected because we supplied an unknown key'); } catch (Zend_TimeSync_Exception $e) { // success } }
/** * Test setting an array of options * * @return void */ public function testSetOptions() { $options = array('timeout' => 5, 'foo' => 'bar'); $server = new Zend_TimeSync(); $server->setOptions($options); $this->assertEquals($options['timeout'], $server->getOptions('timeout')); $this->assertEquals($options['foo'], $server->getOptions('foo')); }
/** * Test setting an invalid option * * @return void */ public function testSetInvalidOptions() { $server = new Zend_TimeSync(); try { $server->setOptions('*'); $this->fail('Exception expected because we did not supply an array, array expected'); } catch (Zend_TimeSync_Exception $e) { // success } }