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

[Generator.php] mt_rand() changed in PHP 7.1 #1045

Merged
merged 3 commits into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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