The terminal only tells me There was 1 Warning:. But how can I see the full warning message and where it's being triggered from?

--- this is my phpunit.xml file
<?xml version="1.0"?>
<phpunit
colors="true"
verbose="true"
stopOnFailure="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
Adding @AndorDávid comment as the the answer so it's easier to digest:
Use this config file:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
displayDetailsOnTestsThatTriggerWarnings="true"
colors="true">
<!-- rest of the config file -->
</phpunit>
Hope it is worthy to mention another approach how to show "warnings" that came from PHP during PHPUnit testing.
One way is to show all PHP Errors by enabling PHP error reporing using error_reporting(E_ALL) setUp() method in your tests:
public function setUp(): void
{
# Turn on error reporting
error_reporting(E_ALL);
// ...
}
Hereafter compare verbosity of either solutions:
First example of output with error_reporting(E_ALL):
PHPUnit 11.0.3 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.0
Configuration: C:\...\tests\phpunit.xml
.
Warning: Undefined property: stdClass::$idc in C:\...\lib\MyClass.php on line 324
W 2 / 2 (100%)
Time: 00:01.221, Memory: 26.00 MB
Second way was already mentioned in other answers is using displayDetailsOnTestsThatTriggerWarnings="true" attribute in phpunit.xml config file.
Second example of output with displayDetailsOnTestsThatTriggerWarnings="true" :
PHPUnit 11.0.3 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.0
Configuration: C:\...\tests\phpunit.xml
.W 2 / 2 (100%)
Time: 00:01.204, Memory: 26.00 MB
1 test triggered 1 PHP warning:
1) C:\Users\...\lib\MyClass.php:324
Undefined property: stdClass::$foo
Triggered by:
* MyClassTest::test_MyClass_searchById
C:\Users\...\tests\MyClassTest.php:414
OK, but there were issues!
Tests: 2, Assertions: 4, Warnings: 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With