When you have Mamp Pro and want to run phpunit or composer, the environment defaults to /usr/local/bin/php. Mamp Pro adds an alias to your .bash_profile instead of overruling the environment path. Because of that, you may experience something like this:
This version of PHPUnit is supported on PHP 7.2 and PHP 7.3.
You are using PHP 7.1.23 (/usr/bin/php).
As an alternative, you can install the latest PHP version using brew. Make sure that you run the link command, otherwise the default PHP package is not overruled and phpunit or composer may still fail.
brew install php@7.2
brew link php@7.2 --force