You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.5KB

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