My test fails when I use $this->at(0) instead of $this->once(). I am surely missing a point here, but I don't know what. Anyone knows what could that be?
/**
* Passes
*/
public function testOne()
{
$expected = array(
'id' => 1,
'name' => 'Product Name'
);
$mock = $this->getMock('WS');
$mock->expects($this->once())
->method('getProductInfo')
->with($this->equalTo(1))
->will($this->returnValue($expected));
$this->object->setWs($mock);
// same as $mock->getInfo(1)
$returned = $this->object->getWs()->getProductInfo(1);
$this->assertEquals($expected, $returned);
}
/**
* Fails
*/
public function testOne()
{
$expected = array(
'id' => 1,
'name' => 'Product Name'
);
$mock = $this->getMock('WS');
$mock->expects($this->at(0)) // all that changed
->method('getProductInfo')
->with($this->equalTo(1))
->will($this->returnValue($expected));
$this->object->setWs($mock);
// returned equals NULL
// same as $mock->getInfo(1)
$returned = $this->object->getWs()->getProductInfo(1);
$this->assertEquals($expected, $returned);
}