krakjoe / uopz

User Operations for Zend
Other
358 stars 47 forks source link

Are time and date related functions ignored? #142

Closed asprega closed 3 years ago

asprega commented 3 years ago

Hi. First of all, thanks for the extension. It's great!

I'm trying to use it to build a clock mock for unit tests but it seems to ignore any uopz_set_return I do on time-related functions.

For example, the following are all ignored (original functions are still called):

uopz_set_return('strtotime', 'Foobar');
echo strtotime('today');

Outputs: <current timestamp>
uopz_set_return('time', 123);
echo time();

Outputs: <current timestamp>
uopz_set_return('date', 'Foobar');
echo date('Y-m-d');

Outputs: <current date in Y-m-d>

Whereas the following works, so that I know the extension is installed and enabled correctly:

uopz_set_return('strlen', 42');
echo strlen('Foobar');

Outputs: 42

I could not find anything in the documentation that said that it wouldn't work for certain functions, nor I couldn't find anything "obvious" in the source code that blacklists them (but I'm obviously not a php internals guy so I might be missing something).

Is there any obvious reason why this is not working? Thanks!

asprega commented 3 years ago

I'm super sorry but this wasn't working because I also had php-timecop extension enabled which obviously interfered with this. Please disregard!