本文整理汇总了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)]);
}
}
示例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);
}
示例3: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
$this->app->singleton(FakerGenerator::class, function () {
return Factory::create('zh_CN');
});
}
示例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());
}
示例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;
}
示例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();
}
}
示例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;
}
示例8: testGetTimeout
public function testGetTimeout()
{
$client = new Client();
$expectedTimeout = $this->faker->randomDigit();
$client->setTimeout($expectedTimeout);
$this->assertEquals($expectedTimeout, $client->getTimeout());
}
示例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()]);
}
示例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')]);
}
}
示例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)));
}
}
示例12: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Leaveapplication::create([]);
}
}
示例13: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Version::create([]);
}
}
示例14: initFaker
private function initFaker()
{
$this->faker = Faker::create();
foreach ($this->scope->getCodes() as $code) {
$this->scopeFaker[$code] = Faker::create($this->scope->getLocale($code));
}
}
示例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()]);
}
}