How to replace usage of static Entity::load method calls for better testability?
My workaround is (without changing legacy code):

   $entityManager = $this-&gt;getMockBuilder('\Drupal\Core\Entity\EntityManager')
      -&gt;disableOriginalConstructor()
      -&gt;getMock();

    $entityManager-&gt;expects($this-&gt;any())
      -&gt;method('getEntityTypeFromClass')
      -&gt;will($this-&gt;returnCallback(function ($class_name) {
        return $class_name == 'Drupal\taxonomy\Entity\Term' ? 'taxonomy_term' : '';
      }));

    $term = $this-&gt;getMockBuilder('Drupal\taxonomy\Entity\Term')
      -&gt;disableOriginalConstructor()
      -&gt;getMock();

    $termStorage = $this-&gt;getMockBuilder('\Drupal\taxonomy\TermStorage')
      -&gt;disableOriginalConstructor()
      -&gt;getMock();

    $termStorage-&gt;expects($this-&gt;any())
      -&gt;method('load')
      -&gt;willReturn($term);

    $this-&gt;termStorage = $termStorage;

    $entityManager-&gt;expects($this-&gt;any())
      -&gt;method('getStorage')
      -&gt;will($this-&gt;returnCallback(function ($type) {
        return $type == 'taxonomy_term' ? $this-&gt;termStorage : NULL;
      }));

    $this-&gt;container = new ContainerBuilder();
    $this-&gt;container-&gt;set('entity.manager', $entityManager);
    \Drupal::setContainer($this-&gt;container);