mt_rand sequences differ between runs with mock cache being warmed and without
- Dominant language
- PHP
- Stars
- 308
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the PHPUnit scenario using srand, comparing mt_rand sequences with and without a warmed mock cache. Start by tracing mock-cache creation into PrettyPrinterAbstract and identify the mt_rand call mentioned in the report. Done means mock-cache warming no longer changes the sequence observed by the test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100