A
A
Askar Fuzaylov2015-06-20 11:07:29
PHP
Askar Fuzaylov, 2015-06-20 11:07:29

Is it considered good practice to create test objects if there is no way to create mocks?

Is it considered good practice to create test objects if there is no way to create mocks?
I have a method that takes an argument of type ConnectionInterface and this object must have a certain property.
I need to test a method that works with this interface. Due to the fact that there is no way to create a mock and define a property for it, I simply created a test object of the ConnectionInterface type.
The tests work, but is this the right approach?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-06-20
Protko @Fesor

you can override the __get method and thus waste accessing the property and return the required value. But in general, public properties for objects of type ConnectionInterface are already strange.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question