svn: /pear/packages/Net_Growl/trunk/ Net/Growl.php tests/Growl/GrowlBaseTest.php

From: Date: Thu, 05 Apr 2012 08:55:17 +0000
Subject: svn: /pear/packages/Net_Growl/trunk/ Net/Growl.php tests/Growl/GrowlBaseTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-64617@lists.php.net to get a copy of this message
farell Thu, 05 Apr 2012 08:55:17 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=324841 Log: - 'port' option is now optional - 'protocol' option is enough to know port to use (anyway it cannot be changed : UDP always fixed to 9887 and GNTP to 23053) Changed paths: U pear/packages/Net_Growl/trunk/Net/Growl.php A pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php Modified: pear/packages/Net_Growl/trunk/Net/Growl.php =================================================================== --- pear/packages/Net_Growl/trunk/Net/Growl.php 2012-04-05 08:44:41 UTC (rev 324840) +++ pear/packages/Net_Growl/trunk/Net/Growl.php 2012-04-05 08:55:17 UTC (rev 324841) @@ -192,8 +192,10 @@ } else { $protocol = $options['protocol']; } + $options['port'] = self::GNTP_PORT; } else { $protocol = 'udp'; + $options['port'] = self::UDP_PORT; } $class = 'Net_Growl_' . ucfirst($protocol); @@ -304,6 +306,17 @@ } /** + * Gets options used with current Growl object + * + * @return array + * @since 2.6.0 + */ + public function getOptions() + { + return $this->options; + } + + /** * Limit the number of notifications * * This method limits the number of notifications to be displayed on @@ -866,4 +879,3 @@ } } - \ No newline at end of file Added: pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php =================================================================== --- pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php (rev 0) +++ pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php 2012-04-05 08:55:17 UTC (rev 324841) @@ -0,0 +1,89 @@ +<?php +/** + * Unit tests for Net_Growl package base class + * + * PHP version 5 + * + * @category Networking + * @package Net_Growl + * @author Laurent Laville <pear@laurent-laville.org> + * @license http://www.opensource.org/licenses/bsd-license.php BSD + * @version SVN: $Id:$ + * @link http://pear.php.net/package/Net_Growl + * @since File available since Release 2.6.0 + */ + +require_once 'Net/Growl/Autoload.php'; + +/** + * Unit test for Net_Growl_Gntp class + */ +class Net_Growl_GrowlBaseTest extends PHPUnit_Framework_TestCase +{ + /** + * Sets up the fixture. + * This method is called before a test is executed. + * + * @return void + */ + protected function setUp() + { + // @link http://sebastian-bergmann.de/archives/882-guid.html + // Testing Code That Uses Singletons + Net_Growl::reset(); + } + + /** + * test to retrieve options in used with current Growl object + */ + public function testGettingOptions() + { + $appName = 'Net_Growl UT'; + $notifications = array(); + $defaultOptions = array( + 'host' => '127.0.0.1', + 'port' => Net_Growl::UDP_PORT, + 'protocol' => 'udp', + 'timeout' => 30, + 'context' => array(), + 'passwordHashAlgorithm' => 'MD5', + 'encryptionAlgorithm' => 'NONE', + 'debug' => false + ); + + $growl = Net_Growl::singleton($appName, $notifications); + + $this->assertEquals( + $defaultOptions, + $growl->getOptions() + ); + } + + /** + * test of use without need to declare port option + */ + public function testUseWithOptionalPortOption() + { + $appName = 'Net_Growl UT'; + $notifications = array(); + $password = ''; + $options = array( + 'protocol' => 'gntp', + ); + $growl = Net_Growl::singleton($appName, $notifications, $password, $options); + + $this->assertEquals( + array( + 'host' => '127.0.0.1', + 'port' => Net_Growl::GNTP_PORT, + 'protocol' => 'gntp', + 'timeout' => 30, + 'context' => array(), + 'passwordHashAlgorithm' => 'MD5', + 'encryptionAlgorithm' => 'NONE', + 'debug' => false + ), + $growl->getOptions() + ); + } +}

« previous php.pear.cvs (#64617) next »