2016-03-31 10 views
2

私はsymfony2の中からphpunitを実行しており、すべてのログエントリの出力をstdoutに見ています。phpunit monologコンソールの出力が冗長すぎる

すべてのconfig.ymlファイルからすべてのモノローグハンドラとその他の設定エントリを削除しましたので、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> 

任意のアイデアこの出力を削除するには?

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

(除去debugHandlerは効果がありません):以下に示すように

ETAは、テストがインスタンス化モノローグインスタンスを使用しています。

stdoutに出力するハンドラがありますが、これはそうではありません。私は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その他のドキュメント1

・ホープ、このヘルプ

+0

残念ながら、これは効果がありません。元の質問の編集をご覧ください – elmpp

0

誤警報、それは私自身の意思のモノローグインスタンスだっなくsymfonyの管理の。 Duh

関連する問題