scratch – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 /*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11  
12 namespace Monolog\Handler;
13  
14 use Monolog\TestCase;
15 use Monolog\Handler\SyslogUdp\UdpSocket;
16  
17 /**
18 * @requires extension sockets
19 */
20 class UdpSocketTest extends TestCase
21 {
22 public function testWeDoNotTruncateShortMessages()
23 {
24 $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
25  
26 $socket->expects($this->at(0))
27 ->method('send')
28 ->with("HEADER: The quick brown fox jumps over the lazy dog");
29  
30 $socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
31 }
32  
33 public function testLongMessagesAreTruncated()
34 {
35 $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
36  
37 $truncatedString = str_repeat("derp", 16254).'d';
38  
39 $socket->expects($this->exactly(1))
40 ->method('send')
41 ->with("HEADER" . $truncatedString);
42  
43 $longString = str_repeat("derp", 20000);
44  
45 $socket->write($longString, "HEADER");
46 }
47  
48 public function testDoubleCloseDoesNotError()
49 {
50 $socket = new UdpSocket('127.0.0.1', 514);
51 $socket->close();
52 $socket->close();
53 }
54  
55 /**
56 * @expectedException LogicException
57 */
58 public function testWriteAfterCloseErrors()
59 {
60 $socket = new UdpSocket('127.0.0.1', 514);
61 $socket->close();
62 $socket->write('foo', "HEADER");
63 }
64 }