當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。