Skip to content
Advertisement

change parameter value of dependent method in phpunit

i wrote a sample test case for collection like class but weird thing about this is in my testAdd method that i add a item in CustomCollectionService and it changed my parameter too. how can this happend?

JavaScript

and this is my test:

JavaScript

Advertisement

Answer

Because it is an object. So when you pass the $col object to the CollectionService and call the add method within the CollectionService, it is still the $col object from your test method that is being used.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement