Injecting a validation class Instance to unit test - phpunit


I'm testing a class named City that accepts two parameters in this class i have a name getter that return a trimmed / filtered string.


If i want to use a custom validation class i'll have to inject it through the constructor. and i'll have to create a real object in a my test.


  • Should i create a validation object and pass it to City class in my test? since i can't use a mock for this one.

  • Am i breaking the unit test isolation here?


City Class

class City   {   protected $name;   protected $shortCode;
public function __construct($name