(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

not an expert of PHPUnit but the "each" function is not available anymore in PHP 8

Warning: This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.

Taken from the PHP site

Probably the PHPUnit version you're using is not up-to-date yet for PHP 8. Check the version if you can and then see here PHPUnit version support