Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1045 from oittaa/patch-2
Browse files Browse the repository at this point in the history
[Generator.php] mt_rand() changed in PHP 7.1
  • Loading branch information
fzaninotto authored Oct 7, 2016
2 parents 57d1666 + 19dcb90 commit cd7ae26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

sudo: false
Expand Down
6 changes: 5 additions & 1 deletion src/Faker/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ public function seed($seed = null)
if ($seed === null) {
mt_srand();
} else {
mt_srand((int) $seed);
if (PHP_VERSION_ID < 70100) {
mt_srand((int) $seed);
} else {
mt_srand((int) $seed, MT_RAND_PHP);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion test/Faker/Provider/UuidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Faker\Test\Provider;

use Faker\Generator;
use Faker\Provider\Uuid as BaseProvider;

class UuidTest extends \PHPUnit_Framework_TestCase
Expand All @@ -14,7 +15,8 @@ public function testUuidReturnsUuid()

public function testUuidExpectedSeed()
{
mt_srand(123);
$faker = new Generator();
$faker->seed(123);
$this->assertEquals("8e2e0c84-50dd-367c-9e66-f3ab455c78d6", BaseProvider::uuid());
$this->assertEquals("073eb60a-902c-30ab-93d0-a94db371f6c8", BaseProvider::uuid());
}
Expand Down

0 comments on commit cd7ae26

Please sign in to comment.