本文整理汇总了PHP中Faker\Generator::addProvider方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::addProvider方法的具体用法?PHP Generator::addProvider怎么用?PHP Generator::addProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Faker\Generator
的用法示例。
在下文中一共展示了Generator::addProvider方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBirthNumber
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}.");
}
}
}
示例2: setUp
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Address($faker));
$faker->addProvider(new Person($faker));
$this->faker = $faker;
}
示例3: setUp
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Company($faker));
$faker->addProvider(new Lorem($faker));
$this->faker = $faker;
}
示例4: setUp
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$faker->addProvider(new Internet($faker));
$faker->addProvider(new Company($faker));
$this->faker = $faker;
}
示例5: setUp
public function setUp()
{
$faker = new Generator();
$faker->seed(1);
$faker->addProvider(new DateTime($faker));
$faker->addProvider(new Person($faker));
$this->faker = $faker;
}
示例6: setUp
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;
}
示例7: setUp
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;
}
示例8: __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);
}
}
示例9: setUp
/**
* {@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']);
}
示例10: setUp
/**
* {@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']);
}
示例11: setUp
/**
* {@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']);
}
示例12: setUp
/**
* {@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);
}
示例13: load
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();
}
示例14: testLastKanaNameReturnsNagisa
public function testLastKanaNameReturnsNagisa()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$faker->seed(1);
$this->assertEquals('ナギサ', $faker->lastKanaName);
}
示例15: loadLocalProviders
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));
}
}