Reputation: 550
I'm running phpunit from within symfony2 and am seeing every log entry output to stdout.
I have removed all monolog handlers and other config entries from all config.yml files so assume it's a default setting of the symfony-phpunit bridge or something.
This is my 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>
Any ideas on removing this output?
ETA, the tests are using an instantiated monolog instance as shown below:
/**
* @return Logger
*/
protected function getLogger() {
$logger = new Logger('test');
$logger->pushHandler(new DebugHandler);
return $logger;
}
(removing the debugHandler has no effect).
It's behaviour is akin to there being a handler that outputs to stdout yet this isn't the case. Here are some of the output when i run 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 [] []
Upvotes: 3
Views: 1323
Reputation: 550
False alarm, it was a monolog instance of my own making and not symfony-managed one. Duh
Upvotes: 1
Reputation: 39430
You can suppress the stdout to the console in a test case with the setOutputCallback
method with a dummy callback. As Example:
public function testDlRegisteredUserWithoutPointAction()
{
// Suppress StreamedResponse output to console
$this->setOutputCallback(function() {});
....
}
Here more docs.
Hope this help
Upvotes: 1