I'm getting pretty werid behavior when using phpunit's mockobjects to test for function calls with certain arguments:
Code: Select all
public function testSetStatusAndMaskedFetch() {
//create mock for database abstraction objects
$objOfferData = $this->getMock('OfferData', array('updateFieldById', 'getMetadataAsArrayByMask'), array(&$this->config, &$this->dbHandle));
//set expectation
/** set expectation for updateFieldById **/
$objOfferData ->expects($this->once())
->method('getMetadataAsArrayByMask')
->with($this->equalTo('0-1-1', '99994', 9, true, true, 8, 8, 8, 88, 4566));
/** run function which should call $objOfferData->getMetadataAsArrayByMask **/
}
Code: Select all
getMetadataAsArrayByMask($dateFrom, $dateTo, $companyNameIn, $status, $orderBy)
Now here's the things I do not get:
1. why does the test run through, even if the number of arguments do not match (also the values of the arguments do not match, they should by ('0000-0-0', '9999-99-99', '('company1'), array(of boolean), 'id ASC'))
2. why does it fail if I change the second parameter to 'a99994' ?
The reason for failing is: InvalidArgumentException: Argument #2 of PHPUnit_Framework_Constraint_IsEqual:__construct() is no numeric