zend test - PHPUnit Mock Object replacing Real Class -
i have couple of tests in test suite being run in zend_test
one test creates mock of foo_bar_baz
via phpunit's mockbuilder class dependency. in test foo_bar_baz
(the change in case on purpose , necessary due autoloading), not getting class rather instance of mock, doesn't work.
doing var_dump
on object results in class foo_bar_baz#27115(0) { }
appears creating instance of mock.
fixing case of in mock gets things work expected. have never seen behavior in mocking objects before. reason mocked class being loaded php when next test tries instantiate real object instantiates mock instead. why happening?
class names in php not case-sensitive, filenames on *nix server are.
i suspect change in case causing change in behaviour because of autoload mechanism; php autoload 1 of foo_bar_baz.php , foo_bar_baz.php.
in case, if have defined class foo_bar_baz (as mock) php use same definition foo_bar_baz, thereby ignoring real class definition.
Comments
Post a Comment