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

From: Date: Thu, 05 Apr 2012 09:36:05 +0000
Subject: svn: /pear/packages/Net_Growl/trunk/ Net/Growl.php tests/Growl/GrowlBaseTest.php tests/_files/response_gntp_notify_ok
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-64620@lists.php.net to get a copy of this message
farell Thu, 05 Apr 2012 09:36:05 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=324845 Log: add publish() method, alias of notify(). Do an easy migration if user want to use next major version Changed paths: U pear/packages/Net_Growl/trunk/Net/Growl.php U pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php A pear/packages/Net_Growl/trunk/tests/_files/response_gntp_notify_ok Modified: pear/packages/Net_Growl/trunk/Net/Growl.php =================================================================== --- pear/packages/Net_Growl/trunk/Net/Growl.php 2012-04-05 09:16:32 UTC (rev 324844) +++ pear/packages/Net_Growl/trunk/Net/Growl.php 2012-04-05 09:36:05 UTC (rev 324845) @@ -393,6 +393,25 @@ } /** + * Alias of notify() method. + * + * Prepare code to an easy migration for next major version of Net_Growl + * http://growl.laurent-laville.org/v3/site/ + * + * @param string $name Notification name + * @param string $title Notification title + * @param string $description (optional) Notification description + * @param string $options (optional) few Notification options + * + * @return Net_Growl_Response | FALSE + * @throws Net_Growl_Exception if NOTIFY failed + */ + public function publish($name, $title, $description = '', $options = array()) + { + return $this->notify($name, $title, $description, $options); + } + + /** * Send request to remote server * * @param string $method Either REGISTER, NOTIFY Modified: pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php =================================================================== --- pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php 2012-04-05 09:16:32 UTC (rev 324844) +++ pear/packages/Net_Growl/trunk/tests/Growl/GrowlBaseTest.php 2012-04-05 09:36:05 UTC (rev 324845) @@ -13,7 +13,8 @@ * @since File available since Release 2.6.0 */ -require_once 'Net/Growl/Autoload.php'; +//require_once 'Net/Growl/Autoload.php'; +require_once '/home/pear/Net_Growl/trunk/Net/Growl/Autoload.php'; /** * Unit test for Net_Growl_Gntp class @@ -86,4 +87,48 @@ $growl->getOptions() ); } + + /** + * test notify message with publish() method, alias of notify() + */ + public function testNotificationWithPublishMethod() + { + $appName = 'Net_Growl UT'; + $notifications = array( + 'GROWL_NOTIFY_STATUS' => array(), + ); + $password = ''; + $options = array( + 'protocol' => 'gntpMock', + ); + $growl = Net_Growl::singleton($appName, $notifications, $password, $options); + $growl->addResponse( + fopen(dirname(dirname(__FILE__)) + . '/_files/response_gntp_register_ok', 'rb') + ); + $growl->addResponse( + fopen(dirname(dirname(__FILE__)) + . '/_files/response_gntp_notify_ok', 'rb') + ); + + try { + $name = 'GROWL_NOTIFY_STATUS'; + $title = 'Congratulation'; + $description = 'You have successfully installe PEAR/Net_Growl.'; + $options = array(); + $response = $growl->publish($name, $title, $description, $options); + } + catch (Exception $e) { + $this->fail('Not Expected Net_Growl_Exception was thrown: '.$e->getMessage()); + return; + } + + $this->assertEquals( + array('OK', 'NOTIFY'), + array( + $response->getStatus(), + $response->getResponseAction() + ) + ); + } } Added: pear/packages/Net_Growl/trunk/tests/_files/response_gntp_notify_ok =================================================================== --- pear/packages/Net_Growl/trunk/tests/_files/response_gntp_notify_ok (rev 0) +++ pear/packages/Net_Growl/trunk/tests/_files/response_gntp_notify_ok 2012-04-05 09:36:05 UTC (rev 324845) @@ -0,0 +1,9 @@ +GNTP/1.0 -OK NONE +Response-Action: NOTIFY +Origin-Machine-Name: OURAGAN +Origin-Software-Name: Growl/Win +Origin-Software-Version: 2.0.0.28 +Origin-Platform-Name: Microsoft Windows NT 5.1.2600 Service Pack 3 +Origin-Platform-Version: 5.1.2600.196608 +X-Message-Daemon: Growl/Win +X-Timestamp: 09/05/2010 16:07:26

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