[Phpmyadmin-devel] PHPUnit tests 'Mock Objects' | Initialization Problem

Dhananjay Nakrani dhananjaynakrani at gmail.com
Sat Jun 7 07:30:04 CEST 2014


Hi everyone,

I'm fixing automated test-'testCreateIncidentFromBugReport()' for
error-reporting-server and need a little help with 'Mock Objects'.

See L#263 [0]. Because of 'will($this->returnValue(true))' there,
'Incident:save()' method of the mock object returns 'true' inside
'Incident::createIncidentFromBugReport()' (called at [3]).
Now, I want to make 'save()' method of the mock object to do initialization
of '$this' (incident object on which it operates). It is necessary because
'Incident::createIncidentFromBugReport()' is designed to return array of
ids of newly created incidents [1]. Currently '$this' is not initialized
and that's why '$this->id' is 'bool(false)' [2] in the log.

How can that be done?? Is there any method like 'returnValue()' to achieve
that??


[0]:
https://github.com/dhananjay92/error-reporting-server/compare/b71453d3eaf4...8a8bc7a700b8#diff-e77d61995cbbaa85aa84de5f5c24adc2L262
[1]:
https://github.com/dhananjay92/error-reporting-server/compare/b71453d3eaf4...8a8bc7a700b8#diff-5cd1459197cc4c095b963a99c7b97d90R208
[2]:
https://travis-ci.org/dhananjay92/error-reporting-server/jobs/26998211#L259
[3]:
https://github.com/dhananjay92/error-reporting-server/compare/b71453d3eaf4...8a8bc7a700b8#diff-e77d61995cbbaa85aa84de5f5c24adc2R271


Thanks,
Dhananjay Nakrani.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20140607/65d973ca/attachment.html>


More information about the Developers mailing list