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')); }
/** * 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); }
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)]; }