PHPUnit test complex method that use drupal service within it
Resurrecting this.  The first method would be to include the EntityFieldManager as an argument to your function or constructor, so you can send a mock object in.

The second would be to look at some of the tests in core.  Specifically core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php where the container is mocked and dependencies set up.    

$container = new ContainerBuilder();
$container-&gt;set('entity_type.manager', $entity_type_manager-&gt;reveal());
...
\Drupal::setContainer($container);