ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
MailHandlerTest.php
Go to the documentation of this file.
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;
16 
18 {
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 
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 
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 }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
const ERROR
Runtime errors.
Definition: Logger.php:57
$records
Definition: simple_test.php:22
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
Monolog::handleBatch
Create styles array
The data for the language used.
testHandleBatch()
Monolog::handleBatch
const INFO
Interesting events.
Definition: Logger.php:39