本文整理汇总了PHP中Faker\Generator::name方法的典型用法代码示例。如果您正苦于以下问题:PHP Generator::name方法的具体用法?PHP Generator::name怎么用?PHP Generator::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Faker\Generator
的用法示例。
在下文中一共展示了Generator::name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNameReturnsFirstNameAndLastName
public function testNameReturnsFirstNameAndLastName()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$this->assertContains($faker->name(), array('John Doe', 'Jane Doe'));
$this->assertContains($faker->name('foobar'), array('John Doe', 'Jane Doe'));
$this->assertContains($faker->name('male'), array('John Doe'));
$this->assertContains($faker->name('female'), array('Jane Doe'));
}
示例2: generateReference
/**
* Generates a student convention reference from the student full name and the date of signature of the convention.
*
* @param \DateTime $dateOfSignature
* @param string|null $fullname If is null, a random name is used instead
*
* @return string
*/
public function generateReference(\DateTime $dateOfSignature, $fullname = null)
{
if (null === $fullname || '' === $fullname) {
// It does not matter if the Faker instance is not based on the application locale as we don't really
// care of the real value of the name. Keeping this avoid having to inject a faker instance which is
// more difficul to properly test.
$fullname = $this->faker->name();
}
$fullnameParts = array_merge(explode(' ', $this->normalizeString($fullname)), ['a', 'b', 'c', 'd', 'e', 'f']);
$reference = '';
foreach ($fullnameParts as $part) {
$referenceLength = strlen($reference);
if (6 === $referenceLength) {
break;
}
$remaining = 6 - $referenceLength;
if (3 < $remaining) {
$remaining = 3;
}
$reference .= substr($part, 0, $remaining);
}
$reference .= $dateOfSignature->format('Ymd');
return strtoupper($reference);
}
示例3: getDummyData
public function getDummyData(Generator $faker, array $customValues = array())
{
return ['comunidad' => $faker->company, 'tipo_secretariado_id' => rand(1, 3), 'responsable' => $faker->name($gender = null | 'male' | 'female'), 'direccion' => $faker->randomElement(['Numancia, 22', 'Escaleritas, 128', 'Carvajal, 32']), 'cp' => $faker->randomElement(['35012', '35016', '35018', '35010', '32012']), 'pais_id' => 73, 'provincia_id' => 1, 'localidad_id' => $faker->biasedNumberBetween($min = 1, $max = 34, $function = 'sqrt'), 'email_solicitud' => $faker->email, 'email_envio' => $faker->email, 'web' => $faker->url, 'facebook' => $faker->url, 'telefono1' => $faker->randomElement(['615324789', '928276589', '627456896', '615856912']), 'telefono2' => $faker->randomElement(['', '', '928278956', '928564285']), 'tipo_comunicacion_preferida_id' => rand(1, 2), 'observaciones' => $faker->text($maxNbChars = 200)];
}