jeudi 5 mai 2016

Is the MVC pattern broken if we pass the connection from the controller to the model?

At this moment my models create the pdo connection by them-selfs in the constructor.

Now I want to build some unit tests for the models and it is easier to mock the pdo connection if it is passed as a parameter to the constructor.

So there is a compromise between making the model more autonomous and instantiate what it it needs by itself or delegate the connection creation to the controller and having an easily testable model.

What do you think?

Aucun commentaire:

Enregistrer un commentaire