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\Logger;
15 use Monolog\TestCase;
16  
17 class MailHandlerTest extends TestCase
18 {
19 /**
20 * @covers Monolog\Handler\MailHandler::handleBatch
21 */
22 public function testHandleBatch()
23 {
24 $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
25 $formatter->expects($this->once())
26 ->method('formatBatch'); // Each record is formatted
27  
28 $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
29 $handler->expects($this->once())
30 ->method('send');
31 $handler->expects($this->never())
32 ->method('write'); // write is for individual records
33  
34 $handler->setFormatter($formatter);
35  
36 $handler->handleBatch($this->getMultipleRecords());
37 }
38  
39 /**
40 * @covers Monolog\Handler\MailHandler::handleBatch
41 */
42 public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
43 {
44 $records = array(
45 $this->getRecord(Logger::DEBUG, 'debug message 1'),
46 $this->getRecord(Logger::DEBUG, 'debug message 2'),
47 $this->getRecord(Logger::INFO, 'information'),
48 );
49  
50 $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
51 $handler->expects($this->never())
52 ->method('send');
53 $handler->setLevel(Logger::ERROR);
54  
55 $handler->handleBatch($records);
56 }
57  
58 /**
59 * @covers Monolog\Handler\MailHandler::write
60 */
61 public function testHandle()
62 {
63 $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
64  
65 $record = $this->getRecord();
66 $records = array($record);
67 $records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n";
68  
69 $handler->expects($this->once())
70 ->method('send')
71 ->with($records[0]['formatted'], $records);
72  
73 $handler->handle($record);
74 }
75 }