Net_Growl
[ class tree: Net_Growl ] [ index: Net_Growl ] [ all elements ]

Class: Net_Growl_GntpMock

Source Location: /Net_Growl-2.7.0/Net/Growl/GntpMock.php

Class Overview

Net_Growl
   |
   --Net_Growl_GntpMock

Mock adapter intended for testing


Author(s):

Version:

  • Release: 2.7.0

Variables

Methods


Inherited Variables

Inherited Methods

Class: Net_Growl

Net_Growl::__construct()
Constructor
Net_Growl::debug()
Logs GNTP IN/OUT messages
Net_Growl::errorHandler()
Converts standard error into exception
Net_Growl::getApplication()
Returns the registered application object
Net_Growl::getDefaultGrowlIcon()
Returns Growl default icon logo binary data
Net_Growl::getOptions()
Gets options used with current Growl object
Net_Growl::notify()
Sends a notification to Growl
Net_Growl::publish()
Alias of notify() method.
Net_Growl::register()
Sends a application register to Growl
Net_Growl::reset()
Resettable Singleton Solution
Net_Growl::sendRequest()
Send request to remote server
Net_Growl::setNotificationLimit()
Limit the number of notifications
Net_Growl::singleton()
Singleton
Net_Growl::strByteLen()
Get string byte length
Net_Growl::utf8Encode()
Encodes a detect_order string to UTF-8
Net_Growl::__destruct()
Destructor

Class Details

[line 72]
Mock adapter intended for testing

Can be used to test applications depending on Net_Growl package without actually performing any GNTP requests. This adapter will return responses previously added via addResponse()

  1.   $mock Net_Growl::singleton($appName$notifications$password$options);
  2.   $mock->addResponse(
  3.           "GNTP/1.0 -OK NONE\r\n" .
  4.           "..."
  5.   );
  6.  
  7.  // This will return the response set above
  8.  $response $mock->register();



[ Top ]


Class Variables

$responses = array()

[line 79]

A queue of responses to be returned by sendRequest()
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 94]

Net_Growl_GntpMock __construct( mixed &$application, [array $notifications = array()], [string $password = ''], [array $options = array()])

Class constructor
  • Access: protected

Overrides Net_Growl::__construct() (Constructor)

Parameters:

mixed   &$application     Can be either a Net_Growl_Application object or the application name string
array   $notifications     List of notification types
string   $password     (optional) Password for Growl
array   $options     (optional) List of options : 'host', 'port', 'protocol', 'timeout' for Growl socket server. 'passwordHashAlgorithm', 'encryptionAlgorithm' to secure communications. 'debug' to know what data are sent and received.

[ Top ]

addResponse   [line 181]

void addResponse( mixed $response)

Adds response to the queue
  • Throws: Net_Growl_Exception
  • Access: public

Parameters:

mixed   $response     Either a string, a pointer to an open file, an instance of Net_Growl_Exception or Exception

[ Top ]

createResponseFromFile   [line 219]

Net_Growl_Response createResponseFromFile( resource $fp)

Creates a new Net_Growl_Response object from a file
  • Access: protected

Parameters:

resource   $fp     File pointer returned by fopen()

[ Top ]

createResponseFromString   [line 202]

Net_Growl_Response createResponseFromString( string $str)

Creates a new Net_Growl_Response object from a string
  • Access: protected

Parameters:

string   $str     Expected Growl Response

[ Top ]

sendNotify   [line 128]

Net_Growl_Response sendNotify( string $name, string $title, string $description, string $options)

Sends the NOTIFY message type
  • Throws: Net_Growl_Exception if remote server communication failure
  • Access: public

Parameters:

string   $name     Notification name
string   $title     Notification title
string   $description     Notification description
string   $options     Notification options

[ Top ]

sendRegister   [line 106]

Net_Growl_Response sendRegister( )

Sends the REGISTER message type
  • Throws: Net_Growl_Exception if remote server communication failure
  • Access: public

[ Top ]

sendRequest   [line 152]

Net_Growl_Response sendRequest( string $method, mixed $data, [bool $callback = false])

Returns the next response from the queue built by addResponse()

If the queue is empty it will return default empty response with status 400, if an Exception object was added to the queue it will be thrown.

  • Throws: Exception
  • Access: protected

Overrides Net_Growl::sendRequest() (Send request to remote server)

Parameters:

string   $method     NOT USED
mixed   $data     NOT USED
bool   $callback     NOT USED

[ Top ]


Documentation generated on Tue, 29 Jan 2013 18:30:05 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.