PHPUnit: Doing assertions on non-public variables

后端 未结 4 857
挽巷
挽巷 2020-12-06 04:30

Suppose I have a class with a private property and associated public getter and setter. I want to test with PHPUnit that the property gets the correct value after the sette

4条回答
  •  一向
    一向 (楼主)
    2020-12-06 04:58

    I agree with the others that in general you want to avoid accessing privates in your tests, but for the cases where you need to, you can use reflection to read and write the property.

提交回复
热议问题