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


PHP Faker\Factory类代码示例

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


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

示例1: run

 public function run()
 {
     $faker = Factory::create();
     foreach (range(1, 10) as $index) {
         Category::create(['name' => $faker->firstName, 'description' => $faker->text(130), 'active' => $faker->boolean(85)]);
     }
 }
开发者ID:Tisho84,项目名称:laravel-work,代码行数:7,代码来源:CategoriesTableSeeder.php

示例2: postGenerate

 /**
  * Responds to requests to POST /lorem
  */
 public function postGenerate(Request $request)
 {
     // Validate the request data
     // num_users - how many users should be created
     // tb_word_count - how many words in password
     $this->validate($request, ['num_users' => 'required|integer|min:1|max:99', 'tb_word_count' => 'integer|min:1|max:9']);
     $num_users = $request->input('num_users');
     $lang = $request->input('lang');
     $address1 = $request->input('address1');
     $profile = $request->input('profile');
     $tb_word_count = $request->input('tb_word_count');
     $cb_number = $request->input('cb_number');
     $cb_symbol = $request->input('cb_symbol');
     $pwd_case = $request->input('pwd_case');
     //The section below declares the arrays needed to hold random user data
     //and then populates those arrays.
     //instantiate new PwdGenerator object
     $a = new \App\PwdGenerator($tb_word_count, $pwd_case, $cb_number, $cb_symbol);
     $pwd_array = [];
     $faker = \Faker\Factory::create($lang);
     $name_array = [];
     $address_array = [];
     $profile_array = [];
     for ($i = 0; $i < $num_users; $i++) {
         // populate array with random names
         $name_array[$i] = $faker->name;
         //populate array with random address info
         $address_array[$i] = $faker->address;
         //populate array with random profile text
         $profile_array[$i] = $faker->text;
         //populate array with random passwords
         $pwd_array[$i] = $a->generatePwd();
     }
     return view('random.generate')->with('num_users', $num_users)->with('lang', $lang)->with('address1', $address1)->with('profile', $profile)->with('tb_word_count', $tb_word_count)->with('cb_number', $cb_number)->with('cb_symbol', $cb_symbol)->with('pwd_case', $pwd_case)->with('name_array', $name_array)->with('address_array', $address_array)->with('profile_array', $profile_array)->with('pwd_array', $pwd_array);
 }
开发者ID:anthon94,项目名称:p3,代码行数:38,代码来源:RandomController.php

示例3: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     //
     $this->app->singleton(FakerGenerator::class, function () {
         return Factory::create('zh_CN');
     });
 }
开发者ID:rossli,项目名称:hai30,代码行数:12,代码来源:AppServiceProvider.php

示例4: testPostItem

 public function testPostItem()
 {
     $client = static::createClient();
     $faker = Factory::create();
     $client->request('POST', '/api/items', array('name' => $faker->name, 'description' => $faker->text));
     $this->assertEquals(201, $client->getResponse()->getStatusCode());
 }
开发者ID:nanofelis,项目名称:sf2-api-rest-demo,代码行数:7,代码来源:ItemsControllerTest.php

示例5: setUp

 public function setUp()
 {
     date_default_timezone_set('Europe/Berlin');
     $faker = Factory::create();
     $this->veryLongString = preg_replace("/[^A-Za-z0-9]/", '', $faker->sentence(90));
     $this->faker = $faker;
 }
开发者ID:vmrose,项目名称:clientlibrary,代码行数:7,代码来源:CompanyMemberTest.php

示例6: setUp

 protected function setUp()
 {
     if (!static::$staticConnection) {
         static::$staticConnection = new Connection($this->server, $this->dbName);
     }
     $this->connection = static::$staticConnection;
     if (!static::$staticFaker) {
         static::$staticFaker = Factory::create();
     }
     if (!static::$staticMongator) {
         static::$staticMongator = new Mongator(new $this->metadataFactoryClass());
         static::$staticMongator->setConnection('default', $this->connection);
         static::$staticMongator->setDefaultConnectionName('default');
     }
     if (!static::$staticConfigClasses) {
         static::$staticConfigClasses = (require __DIR__ . '/../../configClasses.php');
     }
     $this->faker = static::$staticFaker;
     $this->mongator = static::$staticMongator;
     $this->unitOfWork = $this->mongator->getUnitOfWork();
     $this->metadataFactory = $this->mongator->getMetadataFactory();
     $this->cache = $this->mongator->getFieldsCache();
     foreach ($this->mongator->getAllRepositories() as $repository) {
         $repository->getIdentityMap()->clear();
     }
     $this->mongo = $this->connection->getMongo();
     $this->db = $this->connection->getMongoDB();
     foreach ($this->db->listCollections() as $collection) {
         //  $collection->drop();
     }
 }
开发者ID:mongator,项目名称:factory,代码行数:31,代码来源:TestCase.php

示例7: reset

 protected function reset()
 {
     $this->id = $this->factory->numberBetween(1, 10000);
     $this->body = $this->serializer->serialize($this->eventBuilder->build());
     $this->type = TransferWasMade::class;
     $this->occurredOn = $this->factory->dateTimeThisMonth;
 }
开发者ID:zoek1,项目名称:php-testing-tools,代码行数:7,代码来源:StoredEventBuilder.php

示例8: testGetTimeout

 public function testGetTimeout()
 {
     $client = new Client();
     $expectedTimeout = $this->faker->randomDigit();
     $client->setTimeout($expectedTimeout);
     $this->assertEquals($expectedTimeout, $client->getTimeout());
 }
开发者ID:petitchevalroux,项目名称:php-jsonapi,代码行数:7,代码来源:ClientTest.php

示例9: testGetEntity

 public function testGetEntity()
 {
     $controller = new JsonApiController();
     $meta = $this->getMockBuilder("Doctrine\\ORM\\Mapping\\ClassMetadata")->setConstructorArgs(["NwApi\\Entities\\User"])->getMock();
     $di = Di::getInstance();
     $di->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $di->em->expects($this->any())->method('find')->willReturn(new NwApi\Entities\User());
     $meta->identifier = ['id'];
     $controller->getEntity($meta, [$this->faker->randomDigit()]);
 }
开发者ID:petitchevalroux,项目名称:newswatcher-api,代码行数:10,代码来源:JsonApiControllerTest.php

示例10: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Product::create(['product_name' => $faker->word, 'details' => $faker->paragraph, 'picture' => 'uploads/products/1default.jpg', 'min_price' => $faker->randomDigit, 'max_price' => $faker->randomDigitNotNull, 'crop_id' => 1, 'location' => $faker->country, 'expiry_date' => $faker->date('Y--m-d')]);
     }
 }
开发者ID:talha08,项目名称:Farmer-Bazar,代码行数:7,代码来源:ProductsTableSeeder.php

示例11: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 500) as $index) {
         Photo::create(array('title' => $faker->sentence($nbwords = 5), 'image' => $faker->imageUrl($width = 640, $height = 480), 'gallery_id' => $faker->numberBetween(1, 50)));
     }
 }
开发者ID:arbuuuud,项目名称:gnt-aops,代码行数:7,代码来源:PhotosTableSeeder.php

示例12: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Leaveapplication::create([]);
     }
 }
开发者ID:kenkode,项目名称:xaraerp,代码行数:7,代码来源:LeaveapplicationsTableSeeder.php

示例13: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Version::create([]);
     }
 }
开发者ID:arwinjp,项目名称:ODTS,代码行数:7,代码来源:VersionsTableSeeder.php

示例14: initFaker

 private function initFaker()
 {
     $this->faker = Faker::create();
     foreach ($this->scope->getCodes() as $code) {
         $this->scopeFaker[$code] = Faker::create($this->scope->getLocale($code));
     }
 }
开发者ID:EcomDev,项目名称:mysql-performance-benchmark,代码行数:7,代码来源:Generator.php

示例15: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         Lesson::create(['title' => $faker->sentence(5), 'body' => $faker->paragraph(4), 'some_bool' => $faker->boolean()]);
     }
 }
开发者ID:richardmalkuth,项目名称:laravel-incremental-api,代码行数:7,代码来源:LessonsTableSeeder.php


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