PHPUnit testing a method that changes an entity field
You can't do that in a unit test, you have to work with real entities in a functional test since $entity-&gt;save(); needs the database to be loaded.
And as $result = $this-&gt;service-&gt;changeEntityField($entity); will return an entity there's no way $result can be equal to 10 or 20. It will be equal to an entity. But in a functional test you'll be able to load the entity and check if the field has the good value or not after your function has been called.