write() public method

Writes $message to a new Growl notification.
public write ( string $priority, string $message, array $options = [] ) : Closure
$priority string The `Logger`-based priority of the message. This value is mapped to a Growl-specific priority value if possible.
$message string Message to be shown.
$options array Any options that are passed to the `notify()` method. See the `$options` parameter of `notify()`.
return Closure Function returning boolean `true` on successful write, `false` otherwise.
Exemplo n.º 1
0
 public function testMessagePriority()
 {
     $connection = fopen('php://memory', 'w+');
     $growl = new Growl(compact('connection') + array('name' => 'Lithium', 'title' => 'Lithium log'));
     $writer = $growl->write('info', 'info: Test message.', array());
     $params = array('message' => 'info: Test message.', 'options' => array('priority' => 'emergency'));
     $result = $writer('lithium\\analysis\\Logger', $params, null);
     $bytes = array(1, 0, 0, 7, 2, 2, 76, 105, 116, 104, 105, 117, 109, 0, 6, 69, 114, 114, 111, 114, 115, 0, 8, 77, 101, 115, 115, 97, 103, 101, 115, 0, 1, 126, 154, 165, 127, 162, 58, 0, 172, 243, 11, 201, 119, 62, 33, 133, 55, 1, 1, 0, 4, 0, 8, 0, 11, 0, 19, 0, 7, 77, 101, 115, 115, 97, 103, 101, 115, 76, 105, 116, 104, 105, 117, 109, 32, 108, 111, 103, 105, 110, 102, 111, 58, 32, 84, 101, 115, 116, 32, 109, 101, 115, 115, 97, 103, 101, 46, 76, 105, 116, 104, 105, 117, 109, 180, 219, 185, 111, 150, 248, 170, 144, 208, 88, 63, 48, 171, 130, 209, 32);
     rewind($connection);
     $result = array_map('ord', str_split(stream_get_contents($connection)));
     $this->assertEqual($bytes, $result);
 }
Exemplo n.º 2
0
 public function testStickyMessages()
 {
     $growl = new Growl(array('name' => 'Lithium', 'title' => 'Lithium log', 'connection' => function () {
         return fopen('php://memory', 'w+');
     }));
     $writer = $growl->write('info', 'info: Test message.', array());
     $params = array('message' => 'info: Test message.', 'options' => array('sticky' => true));
     $result = $writer('lithium\\analysis\\Logger', $params, null);
     $bytes = array(1, 0, 0, 7, 1, 1, 76, 105, 116, 104, 105, 117, 109, 0, 6, 69, 114, 114, 111, 114, 115, 0, 8, 77, 101, 115, 115, 97, 103, 101, 115, 0, 1, 186, 210, 71, 199, 54, 204, 63, 37, 190, 184, 63, 79, 225, 46, 67, 23, 1, 1, 1, 0, 0, 8, 0, 11, 0, 19, 0, 7, 77, 101, 115, 115, 97, 103, 101, 115, 76, 105, 116, 104, 105, 117, 109, 32, 108, 111, 103, 105, 110, 102, 111, 58, 32, 84, 101, 115, 116, 32, 109, 101, 115, 115, 97, 103, 101, 46, 76, 105, 116, 104, 105, 117, 109, 123, 79, 163, 67, 106, 115, 6, 31, 170, 247, 50, 98, 144, 44, 105, 89);
     rewind($growl->connection);
     $result = array_map('ord', str_split(stream_get_contents($growl->connection)));
     $this->assertEqual($bytes, $result);
 }