Drupal testing framework (PHPUnit) provide 3 types of tests: UnitTest, KernelTest, FunctionalTest (JSFunctionalTest) UnitTest : Very fast but Unit Only, without drupal. KernelTest : Is a service test with drupal but without interfaces ans theming.
1. Update drupal core and contrib odules to the last version
Example with composer if you use core-recommended: composer update drupal/core-recommended:9.3.14 -W
StringTranslationTrait allow to get t() and formatPlural() methods
Example: use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
class MyClass {