Other PHP CLI tool can communicate with API using JSON. Why not PHPUnit?
composer require --dev tomasvotruba/phpunit-json-result-printer
Register extension in your phpunit.xml
file:
<extensions>
<bootstrap class="TomasVotruba\PHPUnitJsonResultPrinter\PHPUnitJsonResultPrinterExtension" />
</extensions>