array_flip() error when using phpunit
In the code shown for buildForm() there are two calls to loadMultiple():

The explicit call in the $digests = $digest_storage-&gt;loadMultiple(); line
The implicit call in the $subscription_entity = $subscription_storage-&gt;load(current($subscription_id)); line

The second line is an implicit call to loadMultiple() because the default implementation of load() (EntityStorageBase::load()) uses the following code.
assert(!is_null($id), sprintf('Cannot load the &quot;%s&quot; entity with NULL ID.', $this-&gt;entityTypeId));
$entities = $this-&gt;loadMultiple([$id]);
return isset($entities[$id]) ? $entities[$id] : NULL;

EntityStorageBase::loadMultiple() uses the following code.
$entities = [];
$preloaded_entities = [];

// Create a new variable which is either a prepared version of the $ids
// array for later comparison with the entity cache, or FALSE if no $ids
// were passed. The $ids array is reduced as items are loaded from cache,
// and we need to know if it is empty for this reason to avoid querying the
// database when all requested entities are loaded from cache.
$flipped_ids = $ids ? array_flip($ids) : FALSE; // This is line 261, in Drupal 9.0.x.

array_flip() raises the Can only flip STRING and INTEGER values! warning when the array passed as argument doesn't contain a string or an integer value, which also happens when the array contains one or more NULL values, or even FALSE values.
This means, for example, that the following line isn't setting $subscription_id to an integer or a string, possibly because there aren't any digest entity whose ID is $digest-&gt;id() associated with the subscription entity, or associated with the currently logged-in user.
$subscription_id = $query-&gt;condition('digest', $digest-&gt;id())
  -&gt;condition('uid', $this-&gt;currentUser-&gt;id())
  -&gt;execute();

This is the probable cause, giving that the code of that test isn't creating any subscription entity. If creating a digest entity is supposed to create a subscription entity, then it's not creating a subscription entity that is associated with a digest entity with that ID or with the currently logged-in user.
(I assume $digest-&gt;id() is returning an integer, since that is the usual case. I would verify that too, but since it's the test that is failing, it seems more probable the cause of the warning is the one I described.)