本文整理汇总了PHP中Faker\Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: load
public function load(ObjectManager $manager)
{
$faker = Factory::create();
for ($i = 0; $i < 50; $i++) {
static $id = 1;
$post = new Post();
$post->setTitle($faker->sentence);
$post->setAuthorEmail('[email protected]');
$post->setImageName("images/post/foto{$id}.jpg");
$post->setContent($faker->realText($maxNbChars = 5000, $indexSize = 2));
$marks = array();
for ($q = 0; $q < rand(1, 10); $q++) {
$marks[] = rand(1, 5);
}
$post->setMarks($marks);
$post->addMark(5);
$manager->persist($post);
$this->addReference("{$id}", $post);
$id = $id + 1;
$rand = rand(3, 7);
for ($j = 0; $j < $rand; $j++) {
$comment = new Comment();
$comment->setAuthorEmail('[email protected]');
$comment->setCreatedBy('user_user');
$comment->setContent($faker->realText($maxNbChars = 500, $indexSize = 2));
$comment->setPost($post);
$post->getComments()->add($comment);
$manager->persist($comment);
$manager->flush();
}
}
$manager->flush();
}
开发者ID:syrotchukandrew,项目名称:blog,代码行数:33,代码来源:LoadPostData.php
示例8: __construct
/**
* Build a new Seed.
*/
public function __construct()
{
// Bind Faker instance if available
if (class_exists('Faker\\Factory')) {
$this->faker = Faker::create();
}
}
开发者ID:anahkiasen,项目名称:arrounded,代码行数:10,代码来源:AbstractSeeder.php
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// Validate form
$this->validate($request, ['user_quantity' => 'required|integer|between:1,100']);
// Assign variables
$form_array = $request->input('form_array', array());
$user_quantity = $request->input('user_quantity');
// Generate Fake User Data
$faker = Factory::create('en_US');
$payload = array();
$deposit_address = in_array('address', $form_array);
$deposit_phone = in_array('phone', $form_array);
$deposit_birthdate = in_array('birthdate', $form_array);
for ($i = 0; $i < $user_quantity; $i++) {
$individual = array();
$individual[] = $faker->name;
if ($deposit_address) {
$individual[] = $faker->address;
}
if ($deposit_phone) {
$individual[] = $faker->phoneNumber;
}
if ($deposit_birthdate) {
$individual[] = $faker->date($format = 'Y-m-d', $max = 'now');
}
// Append to payload array
$payload[] = $individual;
}
// Push data to view and return view
return view('results', ['payload' => $payload, 'source' => 'fake-user', 'title' => 'Fake User Generator']);
}
开发者ID:sietekk,项目名称:cscie15.project3,代码行数:37,代码来源:FakeUserController.php
示例10: testSkillFormatter
public function testSkillFormatter()
{
$faker = Factory::create();
$faker->addProvider(new PersonExtra($faker));
$fullName = $faker->fullName();
print_r($fullName);
}
开发者ID:ikwattro,项目名称:faker-extra,代码行数:7,代码来源:PersonExtraTest.php
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('tbl_users')->truncate();
$faker = \Faker\Factory::create();
for ($i = 0; $i < 10; $i++) {
switch (mt_rand(1, 4)) {
case 1:
$insertion = 'van';
break;
case 2:
$insertion = 'de';
break;
case 3:
$insertion = 'van der';
break;
default:
$insertion = '';
}
$city2 = "";
$street2 = "";
$house_nr2 = "";
$postalcode2 = "";
if (mt_rand(1, 2) == 1) {
$street2 = $faker->streetName;
$house_nr2 = $faker->numberBetween(0, 2000);
$postalcode2 = $faker->postcode;
$city2 = $faker->city;
}
\App\User::create(['username' => $faker->userName, 'password' => password_hash('password', PASSWORD_DEFAULT), 'email' => $faker->email, 'firstname' => $faker->firstName, 'lastname' => $faker->lastName, 'insertion' => $insertion, 'phone_nr' => $faker->phoneNumber, 'birthdate' => $faker->date($format = 'Y-m-d', $max = 'now') . " " . $faker->time($format = 'H:i:s', $max = 'now'), 'city' => $faker->city, 'street' => $faker->streetName, 'house_nr' => $faker->numberBetween(0, 2000), 'postalcode' => $faker->postcode, 'city2' => $city2, 'street2' => $street2, 'house_nr2' => $house_nr2, 'postalcode2' => $postalcode2]);
}
}
开发者ID:justmemaarten,项目名称:vlambeer,代码行数:36,代码来源:UsersTableSeeder.php
示例12: 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
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Leaveapplication::create([]);
}
}
开发者ID:kenkode,项目名称:xaraerp,代码行数:7,代码来源:LeaveapplicationsTableSeeder.php
示例18: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Version::create([]);
}
}
开发者ID:arwinjp,项目名称:ODTS,代码行数:7,代码来源:VersionsTableSeeder.php
示例19: 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
示例20: 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;未经允许,请勿转载。 |
请发表评论