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


PHP Faker\Generator类代码示例

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


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

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

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

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

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

示例15: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $shops = $this->shopRepository->findAll();
     // assign 3 shipping plans with 3 shipping optinos each to 80% of shops
     foreach ($shops as $shop) {
         if ($this->faker->boolean(20)) {
             continue;
         }
         /** @var Shop $shop */
         $shop->shippingPlans()->saveMany(factory(ShippingPlan::class, 3)->make())->each(function ($shippingPlan) {
             /** @var ShippingPlan $shippingPlan */
             $shippingPlan->shippingOptions()->saveMany(factory(ShippingOption::class, 3)->make());
         });
     }
     // assign shipping plan to each product if owner has any
     // or 0 if owner doesn't
     $products = $this->productRepository->with('owner.shippingPlans')->findAll();
     foreach ($products as $product) {
         /** @var Seller $seller */
         $seller = $product->seller;
         if ($seller->shippingPlans->count()) {
             /** @var Product $product */
             $product->shippingPlans()->attach($seller->shippingPlans->random()->id);
         }
     }
 }
开发者ID:gez-studio,项目名称:gez-mall,代码行数:31,代码来源:ShippingPlanSeeder.php


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