/** * Generates a new, random user with a name, address, and birthday. * * @param array $options An array of options describing how to generate the * the user. * @return array The newly created user. */ private function generateUser($options) { $faker = $this->getFaker(); $user = []; $user[self::USER_NAME_KEY] = $faker->name; if ($options[self::ADD_ADDRESS_KEY]) { $user[self::USER_STREET_KEY] = $faker->streetAddress; $user[self::USER_CITY_KEY] = $faker->city; $user[self::USER_COUNTRY_KEY] = $faker->country; $user[self::USER_POSTCODE_KEY] = $faker->postcode; } if ($options[self::ADD_BIRTHDAY_KEY]) { $user[self::USER_BIRTHDAY_KEY] = $this->birthdayStringFromDate($faker->dateTimeBetween('-99 years', '-15 years')); } if ($options[self::ADD_PASSWORD_KEY]) { $user[self::USER_PASSWORD_KEY] = kjbpwg::generatePassword(); } if ($options[self::ADD_PROFILE_KEY]) { $user[self::USER_PROFILE_KEY] = $faker->sentence(); } return $user; }
public function testPasswordGeneratedWithNullUseHpyhensOptionUsesDefaultValue() { $options = [kjbpw::OPTION_USE_HYPHENS => null]; $password = kjbpw::generatePassword($options); $this->assertNotEquals(0, substr_count($password, '-'), "Password should contain hyphens\n"); }