mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-19 23:09:47 +01:00
Add a way to test localized providers
This commit is contained in:
parent
9a60f901d6
commit
5cc1162da1
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Provider\ru_Ru;
|
||||
namespace Faker\Provider\ru_RU;
|
||||
|
||||
class Address extends \Faker\Provider\Base
|
||||
{
|
||||
|
26
test/Faker/Provider/LocalizationTest.php
Normal file
26
test/Faker/Provider/LocalizationTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Test\Provider;
|
||||
|
||||
use Faker\Factory;
|
||||
|
||||
class LocalizationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testLocalizedNameProvidersDoNotThrowErrors()
|
||||
{
|
||||
foreach (glob(__DIR__ . '/../../../src/Faker/Provider/*/Person.php') as $localizedPerson) {
|
||||
preg_match('#/([a-zA-Z_]+)/Person\.php#', $localizedPerson, $matches);
|
||||
$faker = Factory::create($matches[1]);
|
||||
$this->assertNotNull($faker->name(), 'Localized Name Provider ' . $matches[1] . ' does not throw errors');
|
||||
}
|
||||
}
|
||||
|
||||
public function testLocalizedAddressProvidersDoNotThrowErrors()
|
||||
{
|
||||
foreach (glob(__DIR__ . '/../../../src/Faker/Provider/*/Address.php') as $localizedAddress) {
|
||||
preg_match('#/([a-zA-Z_]+)/Address\.php#', $localizedAddress, $matches);
|
||||
$faker = Factory::create($matches[1]);
|
||||
$this->assertNotNull($faker->address(), 'Localized Address Provider ' . $matches[1] . ' does not throw errors');
|
||||
}
|
||||
}
|
||||
}
|
26
test/Faker/Provider/PersonTest.php
Normal file
26
test/Faker/Provider/PersonTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Faker\Test\Provider;
|
||||
|
||||
use Faker\Provider\Person;
|
||||
use Faker\Generator;
|
||||
|
||||
class PersonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFirstNameReturnsJohnOrJane()
|
||||
{
|
||||
$this->assertContains(Person::firstName(), array('John', 'Jane'));
|
||||
}
|
||||
|
||||
public function testLastNameReturnsDoe()
|
||||
{
|
||||
$this->assertEquals(Person::lastName(), 'Doe');
|
||||
}
|
||||
|
||||
public function testNameReturnsFirstNameAndLastName()
|
||||
{
|
||||
$faker = new Generator();
|
||||
$faker->addProvider(new Person($faker));
|
||||
$this->assertContains($faker->name(), array('John Doe', 'Jane Doe'));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user