当前位置: 首页>>代码示例>>PHP>>正文


PHP Generator::addProvider方法代码示例

本文整理汇总了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}.");
         }
     }
 }
开发者ID:Wookashlab,项目名称:MainRepo,代码行数:33,代码来源:PersonTest.php

示例2: setUp

 public function setUp()
 {
     $faker = new Generator();
     $faker->addProvider(new Address($faker));
     $faker->addProvider(new Person($faker));
     $this->faker = $faker;
 }
开发者ID:Wookashlab,项目名称:MainRepo,代码行数:7,代码来源:AddressTest.php

示例3: setUp

 public function setUp()
 {
     $faker = new Generator();
     $faker->addProvider(new Company($faker));
     $faker->addProvider(new Lorem($faker));
     $this->faker = $faker;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:7,代码来源:CompanyTest.php

示例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;
 }
开发者ID:gpis88ce,项目名称:Gpis88ce,代码行数:8,代码来源:InternetTest.php

示例5: setUp

 public function setUp()
 {
     $faker = new Generator();
     $faker->seed(1);
     $faker->addProvider(new DateTime($faker));
     $faker->addProvider(new Person($faker));
     $this->faker = $faker;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:8,代码来源:PersonTest.php

示例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;
 }
开发者ID:fzaninotto,项目名称:faker,代码行数:9,代码来源:PersonTest.php

示例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;
 }
开发者ID:wozhen,项目名称:yii2-cms-writedown,代码行数:9,代码来源:PaymentTest.php

示例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);
     }
 }
开发者ID:helpscout,项目名称:specter,代码行数:18,代码来源:Specter.php

示例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']);
 }
开发者ID:iborodikhin,项目名称:php-glue,代码行数:13,代码来源:GlueTest.php

示例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']);
 }
开发者ID:iborodikhin,项目名称:php-glue,代码行数:14,代码来源:StorageTest.php

示例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']);
 }
开发者ID:iborodikhin,项目名称:php-glue,代码行数:15,代码来源:IndexTest.php

示例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);
 }
开发者ID:iborodikhin,项目名称:php-glue,代码行数:16,代码来源:BlobTest.php

示例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();
 }
开发者ID:jonafrank,项目名称:symfonyBlogSearch,代码行数:13,代码来源:LoadPostData.php

示例14: testLastKanaNameReturnsNagisa

 public function testLastKanaNameReturnsNagisa()
 {
     $faker = new Generator();
     $faker->addProvider(new Person($faker));
     $faker->seed(1);
     $this->assertEquals('ナギサ', $faker->lastKanaName);
 }
开发者ID:selenzo,项目名称:bsuir,代码行数:7,代码来源:PersonTest.php

示例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));
     }
 }
开发者ID:Kingsmanscode,项目名称:blog,代码行数:16,代码来源:InternetTest.php


注:本文中的Faker\Generator::addProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。