mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-04-21 16:01:56 +02:00
Merge pull request #1747 from aanfarhan/master
Add lastName gender specific on ru_RU locale
This commit is contained in:
commit
9979692c5a
@ -105,6 +105,8 @@ class Person extends \Faker\Provider\Person
|
||||
'Меркушев', 'Лыткин', 'Туров',
|
||||
);
|
||||
|
||||
protected static $lastNameSuffix = array('a', '');
|
||||
|
||||
/**
|
||||
* Return male middle name
|
||||
*
|
||||
@ -154,4 +156,24 @@ class Person extends \Faker\Provider\Person
|
||||
static::GENDER_FEMALE,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return last name for the specified gender.
|
||||
*
|
||||
* @param string|null $gender A gender of the last name should be generated
|
||||
* for. If the argument is skipped a random gender will be used.
|
||||
* @return string Last name
|
||||
*/
|
||||
public function lastName($gender = null)
|
||||
{
|
||||
$lastName = static::randomElement(static::$lastName);
|
||||
|
||||
if (static::GENDER_FEMALE === $gender) {
|
||||
return $lastName . 'a';
|
||||
} elseif (static::GENDER_MALE === $gender) {
|
||||
return $lastName;
|
||||
}
|
||||
|
||||
return $lastName . static::randomElement(static::$lastNameSuffix);
|
||||
}
|
||||
}
|
||||
|
37
test/Faker/Provider/ru_RU/PersonTest.php
Normal file
37
test/Faker/Provider/ru_RU/PersonTest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Test\Provider\ru_RU;
|
||||
|
||||
use Faker\Generator;
|
||||
use Faker\Provider\ru_RU\Person;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PersonTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Generator
|
||||
*/
|
||||
private $faker;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$faker = new Generator();
|
||||
$faker->addProvider(new Person($faker));
|
||||
$this->faker = $faker;
|
||||
}
|
||||
|
||||
public function testLastNameFemale()
|
||||
{
|
||||
$this->assertEquals("a", substr($this->faker->lastName('female'), -1));
|
||||
}
|
||||
|
||||
public function testLastNameMale()
|
||||
{
|
||||
$this->assertNotEquals("a", substr($this->faker->lastName('male'), -1));
|
||||
}
|
||||
|
||||
public function testLastNameRandom()
|
||||
{
|
||||
$this->assertNotNull($this->faker->lastName());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user