How to Unit Test Entity Reference Field Value
This is a good example of a test that would probably be better suited as a kernel test rather than a unit test since it's dealing with the Field API which can get tricky to mock, and is probably better to test with the real thing.

To test this as a kernel test you need to ensure the following:


Either create your field field_symbols directly in the test's setUp method or place the field config and storage YAML files in a module's config/install directory, and enable that module for the test.


You'll need to also enable the node module, and any other module's that your code depends on



Then, in your test you can execute the custom code and ensure the expected values are set:

public function testFieldSymbols() {
  $node = $this-&gt;createNode();

   // Do this, or retrieve the service if your class is a service.
   $fixture = new ClassIAmTesting();

   $fixture-&gt;populateSymbols($node);

   $this-&gt;assertEquals('expected field value', $node-&gt;field_symbols-&gt;target_id);