2016-03-31 41 views
2

我正在運行symfony2內的phpunit,並看到每個日誌項輸出到標準輸出。phpunit monolog控制檯輸出太詳細

我已經從所有config.yml文件中刪除了所有monolog處理程序和其他配置條目,所以假設它是symfony-phpunit橋的默認設置或其他。

這是我phpunit.xml.dist:

<?xml version="1.0" encoding="UTF-8"?> 

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html --> 
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" 
     backupGlobals="false" 
     colors="true" 
     bootstrap="app/autoload.php" 
> 
    <php> 
     <ini name="error_reporting" value="-1" /> 
    </php> 

    <testsuites> 
     <testsuite name="Project Test Suite"> 
      <directory>tests</directory> 
     </testsuite> 
    </testsuites> 

    <php> 
     <server name="KERNEL_DIR" value="app/" /> 
    </php> 

    <listeners> 
     <listener class="\Mockery\Adapter\Phpunit\TestListener" 
        file="Mockery/Adapter/Phpunit/TestListener.php"> 
     </listener> 
    </listeners> 

    <filter> 
     <whitelist> 
      <directory>src</directory> 
      <exclude> 
       <directory>src/*Bundle/Resources</directory> 
       <directory>src/*/*Bundle/Resources</directory> 
       <directory>src/*/Bundle/*Bundle/Resources</directory> 
      </exclude> 
     </whitelist> 
    </filter> 
</phpunit> 

上刪除該輸出任何想法?

ETA,所述測試是使用如下所示的實例化的獨白實例:

/** 
    * @return Logger 
    */ 
    protected function getLogger() { 
    $logger = new Logger('test'); 
    $logger->pushHandler(new DebugHandler); 
    return $logger; 
    } 

(除去debugHandler沒有任何影響)。

它的行爲類似於存在輸出到標準輸出的處理程序,但事實並非如此。下面是一些輸出的當我運行的PHPUnit:

Matthews-iMac:api matt$ phpunit ./tests/ONC/Test/Partridge/Import/Importer/ImportStaticTest.php 
PHPUnit 5.2.1 by Sebastian Bergmann and contributors. 

E..[2016-03-31 12:37:27] test.DEBUG: [PARSE] Could not parse data String could not be parsed as XML <oxip version="7.1" created="2016-02-20 12:05:53" lastMsgId="" requestTime="0.0584"> <response request="getCategories" code="001" message="success" debug="" provider="GENERIC"> <disclaimer></disclaimer> <category id="16" displayOrder="-788" name="Football" category="FOOTBALL"/ <category id="34" displayOrder="-777" name="Tennis" category="TENNIS"/> <category id="23" displayOrder="230" name="Motor Bikes" category="MOTOR_BIKES"/> <category id="36" displayOrder="360" name="Volleyball" category="VOLLEYBALL"/> </responseBROKEN> </oxip> [] [] 
.[2016-03-31 12:37:27] test.ERROR: [MAPPING] Could not map parsed response to stdClass | feed: CORAL_OPENBET, domain: ONC\Partridge\Entity\Category1, current key with cast: category, current key without cast: category, current result: array ( 'id' => '16', 'displayOrder' => '-788', 'name' => 'Football', 'categoryBELL' => 'FOOTBALL',), mappings: array ( 'name' => 'name', 'category' => 'canonicalised_name', '(int)displayOrder' => 'display_order',), Request: http://xmlfeeds.coral.co.uk/oxi/pub?template=getCategories [] [] 
+0

你在stdout上看到什麼樣的日誌? – Matteo

回答

1

您可以壓縮標準輸出到控制檯在一個測試用例與setOutputCallback方法與虛擬回調。例如:

public function testDlRegisteredUserWithoutPointAction() 
{ 
    // Suppress StreamedResponse output to console 
    $this->setOutputCallback(function() {}); 
    .... 
} 

Here更多文檔。

希望這有助於

+0

不幸的是,這沒有效果。請參閱原始問題的編輯 – elmpp

0

虛驚一場,這是我親手做的獨白實例,而不是Symfony的管理之一。 Duh