我需要测试,代码使用某些参数创建一个新的类实例:
$bar = new ProgressBar($output, $size);
Run Code Online (Sandbox Code Playgroud)
我试图创建一个别名模拟并设置该__construct方法的期望,但它不起作用:
$progressBar = \Mockery::mock('alias:' . ProgressBar::class);
$progressBar->shouldReceive('__construct')
->with(\Mockery::type(OutputInterface::class), 3)
->once();
Run Code Online (Sandbox Code Playgroud)
这种期望从未得到满足: Mockery\Exception\InvalidCountException: Method __construct(object(Mockery\Matcher\Type), 3) from Symfony\Component\Console\Helper\ProgressBar should be called exactly 1 times but called 0 times.
你知道如何用Mockery测试这个吗?