Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mt_rand sequences differ between runs with mock cache being warmed and without #45

Open
niceblex33 opened this issue Jan 4, 2020 · 1 comment

Comments

@niceblex33
Copy link

Hi. In our phpunit test we use srand to set initial value for the random number generator. After we started to use softmocks we've encountered the problem which was inequality between expected and actual results in tests which cover a code which uses the mt_rand function.

The reason was that during creation of mock cache the PrettyPrinterAbstract is called and mt_rand ran. It would be better to think not to use mt_rand.

@YuriyNasretdinov
Copy link
Contributor

Sorry, I'm not sure what you're talking about, as there don't seem to be any mt_rand() calls in Soft Mocks code base itself:

$ grep -R mt_rand . | wc -l
0

I can confirm that there is an mt_rand() call inside the PHP-Parser though:

./vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php:        $this->docStringEndToken = '_DOC_STRING_END_' . mt_rand();

I do agree that this code looks a bit odd but I suggest that you create a github issue in PHP Parser repository as in this case it may be a source of very subtle bugs too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants