PHPUnit: Doing assertions on non-public variables

后端 未结 4 870
挽巷
挽巷 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 05:04

    You can also use Assert::assertAttributeEquals('value', 'propertyName', $object).

    See https://github.com/sebastianbergmann/phpunit/blob/3.7/PHPUnit/Framework/Assert.php#L490

提交回复
热议问题