本文整理汇总了PHP中Faker\Generator::seed方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::seed方法的具体用法?PHP Generator::seed怎么用?PHP Generator::seed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Faker\Generator
的用法示例。
在下文中一共展示了Generator::seed方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: faker
/**
* @return Generator
*/
private function faker()
{
if (null === $this->faker) {
$this->faker = Factory::create('en_US');
$this->faker->seed(9000);
}
return $this->faker;
}
示例2: createApplication
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = (require __DIR__ . '/../bootstrap/app.php');
$app->make('Illuminate\\Contracts\\Console\\Kernel')->bootstrap();
$this->faker = \Faker\Factory::create();
$this->faker->seed(1);
return $app;
}
示例3: __construct
/**
* Specter constructor.
*
* Initialize with a seed for repeatable fixture data
*
* @param integer $seed Faker seed value
*
* @return Specter
*/
public function __construct($seed = 0)
{
$this->faker = Faker\Factory::create();
$this->faker->addProvider(new Avatar($this->faker));
$this->faker->addProvider(new RelatedElement($this->faker, $this->trigger));
if ($seed) {
$this->faker->seed($seed);
}
}
示例4: testIdNumber
public function testIdNumber()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$faker->seed(2);
$this->assertRegExp('/^[А-Я]{2}\\d{8}$/u', $faker->idNumber);
}
示例5: setUp
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Barcode($faker));
$faker->seed(0);
$this->faker = $faker;
}
示例6: testTextMinLength
/**
* @expectedException \InvalidArgumentException
*/
public function testTextMinLength()
{
$generator = new Generator();
$generator->addProvider(new Text($generator));
$generator->seed(0);
$generator->realText(9);
}
示例7: testUuidExpectedSeed
public function testUuidExpectedSeed()
{
$faker = new Generator();
$faker->seed(123);
$this->assertEquals("8e2e0c84-50dd-367c-9e66-f3ab455c78d6", BaseProvider::uuid());
$this->assertEquals("073eb60a-902c-30ab-93d0-a94db371f6c8", BaseProvider::uuid());
}
示例8: setUp
public function setUp()
{
$faker = new Generator();
$faker->seed(1);
$faker->addProvider(new Person($faker));
$this->faker = $faker;
}
示例9: testLastKanaNameReturnsNagisa
public function testLastKanaNameReturnsNagisa()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$faker->seed(1);
$this->assertEquals('ナギサ', $faker->lastKanaName);
}
示例10: _getFaker
/**
* Get the Faker generator with the (optionally) configured locale
*
* @return Generator
*/
protected function _getFaker()
{
$locale = $this->getLocale();
$seed = $this->getSeedingNumber();
$this->out(__('Create Faker instance with "%s" locale...', $locale), 1, Shell::VERBOSE);
$this->faker = Factory::create($locale);
if (!empty($seed)) {
$this->out(__("Use seed '%s' for Faker.", $seed), 1, Shell::VERBOSE);
$this->faker->seed($seed);
}
return $this->faker;
}
示例11: factory
static function factory()
{
$faker = new Generator();
$faker->addProvider(new \Faker\Provider\zh_CN\Person($faker));
$faker->addProvider(new \Faker\Provider\zh_CN\Address($faker));
$faker->addProvider(new \Faker\Provider\zh_CN\PhoneNumber($faker));
$faker->addProvider(new \Faker\Provider\zh_CN\Company($faker));
$faker->addProvider(new \Faker\Provider\Lorem($faker));
$faker->addProvider(new \Faker\Provider\DateTime($faker));
$faker->addProvider(new \Faker\Provider\Internet($faker));
$faker->addProvider(new \Faker\Provider\Image($faker));
$faker->seed(rand(0, 65535));
return $faker;
}
示例12: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$faker->addProvider(new Internet($faker));
$faker->addProvider(new PhoneNumber($faker));
$faker->addProvider(new Lorem($faker));
// Generate default admin
$admin = new User();
$admin->setPlainPassword('123456');
$admin->setEmail('admin@gs1au.org');
$admin->setEnabled(true);
$admin->setType(User::ROLE_ADMIN);
$admin->setFirstName($faker->firstName);
$admin->setLastName($faker->lastName);
$manager->persist($admin);
// Generate default student
$student = new User();
$student->setPlainPassword('123456');
$student->setEmail('student@gs1au.org');
$student->setEnabled(true);
$student->setType(User::ROLE_STUDENT);
$student->setStudentProfileVisibility(User::VISIBILITY_VISIBLE);
$student->setFirstName($faker->firstName);
$student->setLastName($faker->lastName);
$faker->seed(rand(1, 10));
$studentProfile = new StudentProfile();
$studentProfile->setContactEmail($student->getEmail());
$studentProfile->setHeadline($faker->sentence);
$student->setStudentProfile($studentProfile);
$manager->persist($student);
// Generate stat for student
for ($i = 0; $i < 30; $i++) {
$numProfileView = rand(0, 15);
$numShortlist = rand(0, round($numProfileView / 2));
for ($y = 0; $y < $numProfileView; $y++) {
$time = (new \DateTime('now'))->modify('-' . $i . ' days');
$time->setTime(rand(1, 11), rand(1, 30), 0);
$statProfileView = new StatProfileView();
$statProfileView->setCreated($time);
$statProfileView->setStudent($studentProfile);
$manager->persist($statProfileView);
}
for ($z = 0; $z < $numShortlist; $z++) {
$time = (new \DateTime('now'))->modify('-' . $i . ' days');
$time->setTime(rand(1, 11), rand(1, 30), 0);
$statShortlist = new StatShortlist();
$statShortlist->setCreated($time);
$statShortlist->setStudent($studentProfile);
$manager->persist($statShortlist);
}
}
// Generate default member
$member = new User();
$member->setPlainPassword('123456');
$member->setEmail('member@gs1au.org');
$member->setEnabled(true);
$member->setType(User::ROLE_GS1_MEMBER);
$member->setFirstName($faker->firstName);
$member->setLastName($faker->lastName);
$manager->persist($member);
// Generate 20 more accounts of students and members
for ($i = 0; $i < 20; $i++) {
$faker->seed(rand(($i + 1) * 10, ($i + 2) * 10));
$user = new User();
$user->setPlainPassword('123456');
$user->setEmail($faker->email);
$user->setEnabled(true);
$user->setFirstName($faker->firstName);
$user->setLastName($faker->lastName);
$shouldBeAMember = $faker->numberBetween(0, 2) == 0;
if ($shouldBeAMember) {
$user->setType(User::ROLE_GS1_MEMBER);
} else {
$user->setType(User::ROLE_STUDENT);
// disable few students
$shouldEnableStudent = $faker->numberBetween(0, 2) != 0;
$user->setStudentProfileVisibility($shouldEnableStudent ? User::VISIBILITY_VISIBLE : User::VISIBILITY_HIDDEN);
$studentProfile = new StudentProfile();
$studentProfile->setContactEmail($user->getEmail());
$studentProfile->setHeadline($faker->sentence);
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
try {
$studentProfile->setContactNumber($phoneUtil->parse($faker->mobileNumber, "AU"));
} catch (\libphonenumber\NumberParseException $e) {
}
$user->setStudentProfile($studentProfile);
}
$manager->persist($user);
}
$manager->flush();
}
示例13: testSeed
public function testSeed()
{
$generator = new Generator();
$generator->seed(0);
$mtRandWithSeedZero = mt_rand();
$generator->seed(0);
$this->assertEquals($mtRandWithSeedZero, mt_rand(), 'seed(0) should be deterministic.');
$generator->seed();
$mtRandWithoutSeed = mt_rand();
$this->assertNotEquals($mtRandWithSeedZero, $mtRandWithoutSeed, 'seed() should be different than seed(0)');
$generator->seed();
$this->assertNotEquals($mtRandWithoutSeed, mt_rand(), 'seed() should not be deterministic.');
}
示例14: testSeed
public function testSeed()
{
$generator = new Generator();
$generator->seed(0);
$mtRandWithSeedZero = mt_rand();
$generator->seed(0);
$this->assertEquals($mtRandWithSeedZero, mt_rand(), 'seed(0) should be deterministic.');
$generator->seed();
$mtRandWithoutSeed = mt_rand();
$this->assertNotEquals($mtRandWithSeedZero, $mtRandWithoutSeed, 'seed() should be different than seed(0)');
$generator->seed();
$this->assertNotEquals($mtRandWithoutSeed, mt_rand(), 'seed() should not be deterministic.');
$generator->seed('10');
$this->assertTrue(true, 'seeding with a non int value doesn\'t throw an exception');
}