1
0
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:
Francois Zaninotto 2012-04-14 19:50:13 +02:00
parent 9a60f901d6
commit 5cc1162da1
3 changed files with 53 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<?php
namespace Faker\Provider\ru_Ru;
namespace Faker\Provider\ru_RU;
class Address extends \Faker\Provider\Base
{

View 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');
}
}
}

View 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'));
}
}