相关疑难解决方法(0)

PHPUnit断言没有调用任何方法

我有一个使用ServiceB的ClassA.在某种情况下,ClassA最终不应该调用任何ServiceB方法.我现在想测试这个并且确实没有确实调用任何方法.

这可以按如下方式完成:

$classA->expects( $this->never() )->method( 'first_method' );
$classA->expects( $this->never() )->method( 'second_method' );
...
Run Code Online (Sandbox Code Playgroud)

有没有办法简单地说"不应该在这个对象上调用方法"而不是必须为每个方法指定一个限制?

php testing phpunit unit-testing mocking

30
推荐指数
1
解决办法
8935
查看次数

默认情况下,PHPUnit模拟对象永远不会期望

有没有办法告诉phpunit模拟对象,如果没有正式定义的期望,永远不要指望方法调用?

phpunit mocking expectations

6
推荐指数
1
解决办法
5490
查看次数

标签 统计

mocking ×2

phpunit ×2

expectations ×1

php ×1

testing ×1

unit-testing ×1