add test to replicate #4285
use mock instead of concrete object
Merge pull request #5390 from stefanotorresi/test/abstract-factories

Add regression test for #5237
Merge branch 'feature/5390' into develop

Close #5390