How to shadow a core function used in two different tests files?
Wrap it in a !function_exists()

See core/tests/Drupal/Tests/Core/Render/Element/MachineNameTest.php for example:

&lt;?php

namespace Drupal\Core\Render\Element;

if (!function_exists('t')) {

  function t($string, array $args = []) {
    return strtr($string, $args);
  }

}


That said, t() as a specific example is deprecated and should not be used in classes, use the StringTranslationTrait/service instead and you can actually inject it.