本文整理匯總了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)];
}