• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Faker\Generator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Faker\Generator的典型用法代码示例。如果您正苦于以下问题:PHP Generator类的具体用法?PHP Generator怎么用?PHP Generator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Generator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: generateProducts

 public static function generateProducts(\Faker\Generator $generator)
 {
     $title_words = $generator->words(mt_rand(2, 5));
     $title = implode(' ', $title_words);
     $price = mt_rand(1, 10000);
     return array('title' => $title, 'price' => $price);
 }
开发者ID:boliev,项目名称:tstask,代码行数:7,代码来源:ProductsCollection.php


示例2: test

 public function test(TestCase $test, Generator $faker)
 {
     $value = $faker->randomElement(array_filter(array_keys($this->items)), function ($value) {
         return !!$value;
     });
     return $test->select($value, $this->name);
 }
开发者ID:smallhadroncollider,项目名称:laravel-form-presenter,代码行数:7,代码来源:Select.php


示例3: testIdNumber

 public function testIdNumber()
 {
     $faker = new Generator();
     $faker->addProvider(new Person($faker));
     $faker->seed(2);
     $this->assertRegExp('/^[А-Я]{2}\\d{8}$/u', $faker->idNumber);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:7,代码来源:PersonTest.php


示例4: 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


示例5: setUp

 public function setUp()
 {
     $faker = new Generator();
     $faker->addProvider(new Barcode($faker));
     $faker->seed(0);
     $this->faker = $faker;
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:7,代码来源:BarcodeTest.php


示例6: 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


示例7: testTextMinLength

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testTextMinLength()
 {
     $generator = new Generator();
     $generator->addProvider(new Text($generator));
     $generator->seed(0);
     $generator->realText(9);
 }
开发者ID:diandianxiyu,项目名称:Yii2Api,代码行数:10,代码来源:TextTest.php


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


示例9: 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


示例10: 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


示例11: 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


示例12: faker

 /**
  * @return Generator
  */
 private function faker()
 {
     if (null === $this->faker) {
         $this->faker = Factory::create('en_US');
         $this->faker->seed(9000);
     }
     return $this->faker;
 }
开发者ID:Tigerlee1987,项目名称:modules.zendframework.com,代码行数:11,代码来源:FakerTrait.php


示例13: testSkillFormatter

 public function testSkillFormatter()
 {
     $faker = new Generator();
     $faker->addProvider(new Skill($faker));
     $skills = Skill::getProgLanguages();
     $skill = $faker->progLanguage;
     $this->assertTrue(in_array($skill, $skills));
 }
开发者ID:ikwattro,项目名称:faker-extra,代码行数:8,代码来源:SkillTest.php


示例14: 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


示例15: testRandomHtmlReturnsValidHTMLString

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


示例16: testSave

 /**
  * @covers \Glue\Storage\Index::save
  */
 public function testSave()
 {
     $data = implode(' ', $this->faker->sentences());
     $result = $this->index->save($this->faker->uuid, $this->testData['length'], strlen($data));
     $this->assertNotEquals(false, $result);
     $this->assertInternalType('int', $result);
 }
开发者ID:iborodikhin,项目名称:php-glue,代码行数:10,代码来源:IndexTest.php


示例17: testState

 public function testState()
 {
     $state = $this->faker->state();
     $this->assertNotEmpty($state);
     $this->assertInternalType('string', $state);
     $this->assertRegExp('/[A-Z][a-z]+/', $state);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:7,代码来源:AddressTest.php


示例18: createExpense

 public function createExpense(AcceptanceTester $I)
 {
     $I->wantTo('Create an expense');
     $vendorName = $this->faker->name;
     $clientEmail = $this->faker->safeEmail;
     $amount = $this->faker->numberBetween(10, 20);
     // create vendor
     $I->amOnPage('/vendors/create');
     $I->fillField(['name' => 'name'], $vendorName);
     $I->click('Save');
     $I->see($vendorName);
     $vendorId = $I->grabFromDatabase('vendors', 'id', ['name' => $vendorName]);
     // create client
     $I->amOnPage('/clients/create');
     $I->fillField(['name' => 'contacts[0][email]'], $clientEmail);
     $I->click('Save');
     $I->see($clientEmail);
     // create expense
     $I->amOnPage('/expenses/create');
     $I->fillField(['name' => 'amount'], $amount);
     $I->selectDropdown($I, $vendorName, '.vendor-select .dropdown-toggle');
     $I->selectDropdown($I, $clientEmail, '.client-select .dropdown-toggle');
     $I->click('Save');
     $I->seeInDatabase('expenses', ['vendor_id' => $vendorId]);
     // invoice expense
     $I->executeJS('submitAction(\'invoice\')');
     $I->click('Save');
     $I->wait(1);
     $I->see($clientEmail);
     $I->see($amount);
 }
开发者ID:sseshachala,项目名称:invoiceninja,代码行数:31,代码来源:ExpenseCest.php


示例19: testAreaSuffix

 public function testAreaSuffix()
 {
     $areaSuffix = $this->faker->areaSuffix();
     $this->assertNotEmpty($areaSuffix);
     $this->assertInternalType('string', $areaSuffix);
     $this->assertRegExp('/[A-Z][a-z]+/', $areaSuffix);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:7,代码来源:AddressTest.php


示例20: getArgs

 /**
  * @return array
  */
 public function getArgs()
 {
     $path = $this->getTemporaryPath();
     $paragraphs = $this->faker->paragraphs(rand(5, 50), true);
     $this->filesystem->dumpFile($path, $paragraphs);
     return [$path];
 }
开发者ID:php-school,项目名称:learn-you-php,代码行数:10,代码来源:MyFirstIo.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP FastRoute\simpleDispatcher函数代码示例发布时间:2022-05-23
下一篇:
PHP Faker\Factory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap