0
我使用Symfony 3.1.9和PhpUnit 5.6.5。Symfony 3.1 + PhpUnit:未報告控制器異常
只要控制器發生異常,它就由symfony處理,堆棧跟蹤將顯示在視圖中。
我該如何解決這個問題,並使phpunit輸出異常?
我PHPUnit的配置:
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="app/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="app/" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<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>
編輯:這似乎與樹枝如何呈現在測試的例外和DEV以同樣的方式。正如https://symfony.com/doc/current/configuration/environments.html表示:無論環境
,一個Symfony的應用程序可以設置爲true或false 調試模式下運行。這會影響 應用程序中的許多事情,例如在錯誤頁面上顯示堆棧跟蹤,或者在每個請求上動態重建緩存文件 。雖然不是 要求,但對於dev和test 環境,調試模式通常設置爲true,對於prod環境,調試模式爲false。
現在我們如何在測試中設置kernel.debug參數?
你要測試什麼? – COil
@COIL我希望phpunit在我的控制器中引發異常時輸出跟蹤。我真的好奇,爲什麼twig在測試環境中處理異常,並在一個我永遠不會看到的頁面中呈現堆棧跟蹤? – slaur4