PHPSpec - checking that a method has been called with a class instance argument

286 Views Asked by At

I have the following test in RSpec:

it { is_expected.to respond_to(:dock).with(1).argument }

I need to replicate this test but using PHPSpec. My code is below:

function it_should_dock_a_bike()
{
    $bike = new \Bike();
    $this->dock($bike)->shouldReturnAnInstanceOf('Bike');
}

This code works, and it does fail when I exclude the $bike argument, but is there a better way to explicitly write the test similar to the example in RSpec?

1

There are 1 best solutions below

0
DonCallisto On BEST ANSWER
$this->dock(Argument::any())->shouldReturnAnInstanceOf(Bike::class);

is what you're looking for