I need to test, that the code creates a new instance of a class with certain parameters:
$bar = new ProgressBar($output, $size);
I tried to create an alias mock and set an expectation for the __construct
method, but it didn't work:
$progressBar = \Mockery::mock('alias:' . ProgressBar::class);
$progressBar->shouldReceive('__construct')
->with(\Mockery::type(OutputInterface::class), 3)
->once();
This expectation is never met:
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.
Do you know any other way how to test this with Mockery?
return new ProgressBar(...func_get_args())
. So I was wondering if this practice could be tested with Mockery. I will have a look at AspectMock. – VaclavSir