|
From: Chris C. <ch...@w3...> - 2008-08-22 04:30:22
|
Hi, It's not possible to override PHP's internal functions (or any global functions) except perhaps with the help of RunKit. In terms of providing a mock version of Class_C, I'd suggest using a little dependency lookup as a the path of least resistance if you need to retrofit this without too much modification. A registry would be the simplest way to achieve this. Cheers, Chris Kyohere Luke wrote: > Hi, > > here's the scenario: > > I'm trying to test Class_A::Method_B(..). Method_B internally calls > Class_C::Method_D() - which takes a long time, and is accessed from the > global/autoload mechanism of the application. I'd like to skip this call, > since it's irrelevant to my tests. > > Aside from re-designing my class/method to read in Class_C as one of it's > arguments, or else creating a dummy Class_C, and loading it before the real > one is loaded, is there a way to achieve this with Mocks? > > Secondly, is there a way to prevent the class I'm trying to test from > calling such mundane php functions like file_exists(), etc? Because in such > a case, I have to design my test to create/delete files from the file system > and so on. > > Thanks! > > Luke > > |