gpt4 book ai didi

phpunit - PHPUnit 中 `willReturn()` 和 `will($this->returnValue())` 之间的区别?

转载 作者:行者123 更新时间:2023-12-02 17:49:58 26 4
gpt4 key购买 nike

在 PHPUnit 中,之间有任何区别吗

$mockFoo->method('methodName')->will($this->returnValue($mockBar));

$mockFoo->method('methodName')->willReturn($mockBar);

最佳答案

不,willReturn() 只是一个快捷方式。在推出之前,只有另一种变体。现在这个简单的案例不需要它。

引用the manual :

This short syntax is the same as will($this->returnValue($value)). We can use variations on this longer syntax to achieve more complex stubbing behaviour.

关于phpunit - PHPUnit 中 `willReturn()` 和 `will($this->returnValue())` 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33868479/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com