public function testBirthNumber() { $faker = new Generator(); $faker->addProvider(new Person($faker)); $faker->addProvider(new Miscellaneous($faker)); for ($i = 0; $i < 1000; $i++) { $birthNumber = $faker->birthNumber(); $birthNumber = str_replace('/', '', $birthNumber); // check date $year = intval(substr($birthNumber, 0, 2), 10); $month = intval(substr($birthNumber, 2, 2), 10); $day = intval(substr($birthNumber, 4, 2), 10); // make 4 digit year from 2 digit representation $year += $year < 54 ? 2000 : 1900; // adjust special cases for month if ($month > 50) { $month -= 50; } if ($year >= 2004 && $month > 20) { $month -= 20; } $this->assertTrue(checkdate($month, $day, $year), "Birth number {$birthNumber}: date {$year}/{$month}/{$day} is invalid."); // check CRC if presented if (strlen($birthNumber) == 10) { $crc = intval(substr($birthNumber, -1), 10); $refCrc = intval(substr($birthNumber, 0, -1), 10) % 11; if ($refCrc == 10) { $refCrc = 0; } $this->assertEquals($crc, $refCrc, "Birth number {$birthNumber}: checksum {$crc} doesn't match expected {$refCrc}."); } } }
public function setUp() { $faker = new Generator(); $faker->addProvider(new Address($faker)); $faker->addProvider(new Person($faker)); $this->faker = $faker; }
public function setUp() { $faker = new Generator(); $faker->addProvider(new Company($faker)); $faker->addProvider(new Lorem($faker)); $this->faker = $faker; }
public function setUp() { $faker = new Generator(); $faker->addProvider(new Person($faker)); $faker->addProvider(new Internet($faker)); $faker->addProvider(new Company($faker)); $this->faker = $faker; }
public function setUp() { $faker = new Generator(); $faker->seed(1); $faker->addProvider(new DateTime($faker)); $faker->addProvider(new Person($faker)); $this->faker = $faker; }
public function setUp() { $this->originalTz = @date_default_timezone_get(); date_default_timezone_set('Europe/Bucharest'); $faker = new Generator(); $faker->addProvider(new DateTime($faker)); $faker->addProvider(new Person($faker)); $this->faker = $faker; }
public function setUp() { $faker = new Generator(); $faker->addProvider(new BaseProvider($faker)); $faker->addProvider(new DateTimeProvider($faker)); $faker->addProvider(new PersonProvider($faker)); $faker->addProvider(new PaymentProvider($faker)); $this->faker = $faker; }
/** * 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); } }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->glue = new Glue(sys_get_temp_dir(), 1); $this->faker = FakerFactory::create(); $this->faker->addProvider(new Provider\Internet($this->faker)); $this->faker->addProvider(new Provider\DateTime($this->faker)); $this->testData = array('name' => $this->faker->uuid, 'data' => implode(' ', $this->faker->sentences())); $this->glue->save($this->testData['name'], $this->testData['data']); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->storage = new \Glue\Storage(1, sys_get_temp_dir()); $this->faker = FakerFactory::create(); $this->faker->addProvider(new Provider\Internet($this->faker)); $this->faker->addProvider(new Provider\DateTime($this->faker)); $data = implode(' ', $this->faker->sentences()); $this->testData = array('key' => $this->faker->uuid, 'data' => $data); $this->storage->save($this->testData['key'], $this->testData['data']); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->filename = sys_get_temp_dir() . '/' . time(); $this->index = new Index($this->filename); $this->faker = FakerFactory::create(); $this->faker->addProvider(new Provider\Internet($this->faker)); $this->faker->addProvider(new Provider\DateTime($this->faker)); $data = implode(' ', $this->faker->sentences()); $this->testData = array('key' => $this->faker->uuid, 'data' => $data, 'length' => strlen($data)); $this->index->save($this->testData['key'], 0, $this->testData['length']); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->filename = sys_get_temp_dir() . '/' . time(); $this->blob = new Blob($this->filename); $this->faker = FakerFactory::create(); $this->faker->addProvider(new Provider\Internet($this->faker)); $this->faker->addProvider(new Provider\DateTime($this->faker)); $data = implode(' ', $this->faker->sentences()); $length = strlen($data); $result = $this->blob->save($data); $this->testData = array('offset' => $result[0], 'length' => $length, 'data' => $data); }
public function load(ObjectManager $manager) { $faker = new Faker\Generator(); $faker->addProvider(new Faker\Provider\en_US\Text($faker)); $faker->addProvider(new Faker\Provider\Lorem($faker)); for ($i = 1; $i <= 100; $i++) { $post = new Post(); $post->setTitle($faker->sentence(4)); $post->setBody($faker->realText(500)); $manager->persist($post); } $manager->flush(); }
public function testLastKanaNameReturnsNagisa() { $faker = new Generator(); $faker->addProvider(new Person($faker)); $faker->seed(1); $this->assertEquals('ナギサ', $faker->lastKanaName); }
public function loadLocalProviders($locale) { $providerPath = realpath(__DIR__ . '/../../../src/Faker/Provider'); if (file_exists($providerPath . '/' . $locale . '/Internet.php')) { $internet = "\\Faker\\Provider\\{$locale}\\Internet"; $this->faker->addProvider(new $internet($this->faker)); } if (file_exists($providerPath . '/' . $locale . '/Person.php')) { $person = "\\Faker\\Provider\\{$locale}\\Person"; $this->faker->addProvider(new $person($this->faker)); } if (file_exists($providerPath . '/' . $locale . '/Company.php')) { $company = "\\Faker\\Provider\\{$locale}\\Company"; $this->faker->addProvider(new $company($this->faker)); } }
public function testIdNumber() { $faker = new Generator(); $faker->addProvider(new Person($faker)); $faker->seed(2); $this->assertRegExp('/^[А-Я]{2}\\d{8}$/u', $faker->idNumber); }
/** * @expectedException \InvalidArgumentException */ public function testTextMinLength() { $generator = new Generator(); $generator->addProvider(new Text($generator)); $generator->seed(0); $generator->realText(9); }
public function setUp() { $faker = new Generator(); $faker->addProvider(new Barcode($faker)); $faker->seed(0); $this->faker = $faker; }
public function testSkillFormatter() { $faker = new Generator(); $faker->addProvider(new Skill($faker)); $skills = Skill::getProgLanguages(); $skill = $faker->progLanguage; $this->assertTrue(in_array($skill, $skills)); }
public function testRandomHtmlReturnsValidHTMLString() { $faker = new Generator(); $faker->addProvider(new HtmlLorem($faker)); $node = $faker->randomHtml(6, 10); $dom = new \DOMDocument(); $error = $dom->loadHTML($node); $this->assertTrue($error); }
public function testNameReturnsFirstNameAndLastName() { $faker = new Generator(); $faker->addProvider(new Person($faker)); $this->assertContains($faker->name(), array('John Doe', 'Jane Doe')); $this->assertContains($faker->name('foobar'), array('John Doe', 'Jane Doe')); $this->assertContains($faker->name('male'), array('John Doe')); $this->assertContains($faker->name('female'), array('Jane Doe')); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { // Generate 20 access codes $faker = new Generator(); $faker->addProvider(new Base($faker)); for ($i = 0; $i < 20; $i++) { $code = new StudentAccessCode(); $code->setCode($faker->randomNumber(8)); $manager->persist($code); } $manager->flush(); }
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; }
/** * Configure the faker generator. * * @return void */ private function configureFakerGenerator() { $faker = new FakerGenerator(); $faker->addProvider(new \Faker\Provider\en_US\Person($faker)); $faker->addProvider(new \Faker\Provider\en_US\Address($faker)); $faker->addProvider(new \Faker\Provider\en_US\PhoneNumber($faker)); $faker->addProvider(new \Faker\Provider\en_US\Company($faker)); $faker->addProvider(new \Faker\Provider\Lorem($faker)); $faker->addProvider(new \Faker\Provider\Internet($faker)); app()->instance(FakerGenerator::class, $faker); }
public function setUp() { $faker = new Generator(); $faker->addProvider(new PhoneNumber($faker)); $this->faker = $faker; }
public function testMagicCallCallsFormatWithArguments() { $generator = new Generator(); $provider = new FooProvider(); $generator->addProvider($provider); $this->assertEquals('bazfoo', $generator->fooFormatterWithArguments('foo')); }
/** * {@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->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->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->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(); }