scratch – Blame information for rev 115

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\Logger;
16  
17 class MongoDBHandlerTest extends TestCase
18 {
19 /**
20 * @expectedException InvalidArgumentException
21 */
22 public function testConstructorShouldThrowExceptionForInvalidMongo()
23 {
24 new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
25 }
26  
27 public function testHandle()
28 {
29 $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false);
30 $collection = $this->getMock('stdClass', array('save'));
31  
32 $mongo->expects($this->once())
33 ->method('selectCollection')
34 ->with('DB', 'Collection')
35 ->will($this->returnValue($collection));
36  
37 $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
38  
39 $expected = array(
40 'message' => 'test',
41 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34),
42 'level' => Logger::WARNING,
43 'level_name' => 'WARNING',
44 'channel' => 'test',
45 'datetime' => $record['datetime']->format('Y-m-d H:i:s'),
46 'extra' => array(),
47 );
48  
49 $collection->expects($this->once())
50 ->method('save')
51 ->with($expected);
52  
53 $handler = new MongoDBHandler($mongo, 'DB', 'Collection');
54 $handler->handle($record);
55 }
56 }
57  
58 if (!class_exists('Mongo')) {
59 class Mongo
60 {
61 public function selectCollection()
62 {
63 }
64 }
65 }