1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
<?php
namespace Faker\Test\Provider;
use Faker\Provider\Person;
use Faker\Test\TestCase;
/**
* @group legacy
*/
final class PersonTest extends TestCase
{
/**
* @dataProvider firstNameProvider
*/
public function testFirstName($gender, $expected)
{
self::assertContains($this->faker->firstName($gender), $expected);
}
public function firstNameProvider()
{
return [
[null, ['John', 'Jane']],
['foobar', ['John', 'Jane']],
['male', ['John']],
['female', ['Jane']],
];
}
public function testFirstNameMale()
{
self::assertContains(Person::firstNameMale(), ['John']);
}
public function testFirstNameFemale()
{
self::assertContains(Person::firstNameFemale(), ['Jane']);
}
/**
* @dataProvider titleProvider
*/
public function testTitle($gender, $expected)
{
self::assertContains($this->faker->title($gender), $expected);
}
public function titleProvider()
{
return [
[null, ['Mr.', 'Mrs.', 'Ms.', 'Miss', 'Dr.', 'Prof.']],
['foobar', ['Mr.', 'Mrs.', 'Ms.', 'Miss', 'Dr.', 'Prof.']],
['male', ['Mr.', 'Dr.', 'Prof.']],
['female', ['Mrs.', 'Ms.', 'Miss', 'Dr.', 'Prof.']],
];
}
public function testTitleMale()
{
self::assertContains(Person::titleMale(), ['Mr.', 'Dr.', 'Prof.']);
}
public function testTitleFemale()
{
self::assertContains(Person::titleFemale(), ['Mrs.', 'Ms.', 'Miss', 'Dr.', 'Prof.']);
}
public function testLastNameReturnsDoe()
{
self::assertEquals($this->faker->lastName(), 'Doe');
}
public function testNameReturnsFirstNameAndLastName()
{
self::assertContains($this->faker->name(), ['John Doe', 'Jane Doe']);
self::assertContains($this->faker->name('foobar'), ['John Doe', 'Jane Doe']);
self::assertContains($this->faker->name('male'), ['John Doe']);
self::assertContains($this->faker->name('female'), ['Jane Doe']);
}
protected function getProviders(): iterable
{
yield new Person($this->faker);
}
}
|