Вход Регистрация
Файл: gapps/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php
Строк: 109
<?php

/*
 * This file is part of the Monolog package.
 *
 * (c) Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace MonologHandler;

use 
MonologTestCase;
use 
MonologLogger;
use 
MonologProcessorWebProcessor;

class 
AbstractProcessingHandlerTest extends TestCase
{
    
/**
     * @covers MonologHandlerAbstractProcessingHandler::handle
     */
    
public function testHandleLowerLevelMessage()
    {
        
$handler $this->getMockForAbstractClass('MonologHandlerAbstractProcessingHandler', array(Logger::WARNINGtrue));
        
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
    }

    
/**
     * @covers MonologHandlerAbstractProcessingHandler::handle
     */
    
public function testHandleBubbling()
    {
        
$handler $this->getMockForAbstractClass('MonologHandlerAbstractProcessingHandler', array(Logger::DEBUGtrue));
        
$this->assertFalse($handler->handle($this->getRecord()));
    }

    
/**
     * @covers MonologHandlerAbstractProcessingHandler::handle
     */
    
public function testHandleNotBubbling()
    {
        
$handler $this->getMockForAbstractClass('MonologHandlerAbstractProcessingHandler', array(Logger::DEBUGfalse));
        
$this->assertTrue($handler->handle($this->getRecord()));
    }

    
/**
     * @covers MonologHandlerAbstractProcessingHandler::handle
     */
    
public function testHandleIsFalseWhenNotHandled()
    {
        
$handler $this->getMockForAbstractClass('MonologHandlerAbstractProcessingHandler', array(Logger::WARNINGfalse));
        
$this->assertTrue($handler->handle($this->getRecord()));
        
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
    }

    
/**
     * @covers MonologHandlerAbstractProcessingHandler::processRecord
     */
    
public function testProcessRecord()
    {
        
$handler $this->getMockForAbstractClass('MonologHandlerAbstractProcessingHandler');
        
$handler->pushProcessor(new WebProcessor(array(
            
'REQUEST_URI' => '',
            
'REQUEST_METHOD' => '',
            
'REMOTE_ADDR' => '',
            
'SERVER_NAME' => '',
            
'UNIQUE_ID' => '',
        )));
        
$handledRecord null;
        
$handler->expects($this->once())
            ->
method('write')
            ->
will($this->returnCallback(function ($record) use (&$handledRecord) {
                
$handledRecord $record;
            }))
        ;
        
$handler->handle($this->getRecord());
        
$this->assertEquals(6count($handledRecord['extra']));
    }
}
Онлайн: 1
Реклама