When running php unit test case i got below error
PHPUnit\Framework\Exception: Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in vendor/symfony/console/Helper/Helper.php:137.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
This error occurs because passing null to the preg_replace() function as the third argument is deprecated in PHP 8.0. To resolve this error, you need to pass an empty string instead of null.
To fix this error in Symfony console, you can upgrade the symfony/console package to the latest version. This issue has been fixed in Symfony console version 4.4.23, 5.2.11, and 5.3.0.
You can update the symfony/console package by running the following command:
composer require symfony/console:^5.2.11
After updating the package, you can run the PHPUnit test case again to verify that the error has been resolved.
The error message you received suggests that you are using a deprecated function in the Symfony Console component, specifically preg_replace(). This error can be resolved by upgrading your version of Symfony Console to a version that no longer uses this deprecated function.
To resolve this issue, you can follow these steps:
Update your composer.json file to require the latest version of Symfony Console. You can do this by adding or modifying the following line in the "require" section of your composer.json file:
Run the following command to update your dependencies:
Once the update is complete, try running your PHPUnit test case again.
Note: It's always a good practice to test your application on a development environment before upgrading any dependencies.