Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1356 from nicodmf/feature/secondaryAdressfrFR
Browse files Browse the repository at this point in the history
Add secondary address to fr_FR provider
  • Loading branch information
fzaninotto authored Dec 7, 2017
2 parents c1c7d51 + 1b1e4aa commit 07201f7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,9 @@ $faker->department; // array('18' => 'Cher');

// Generates a random region
echo $faker->region; // "Saint-Pierre-et-Miquelon"

// Generates a random appartement,stair
echo $faker->secondaryAddress; // "Bat. 961"
```

### `Faker\Provider\fr_FR\Company`
Expand Down
10 changes: 10 additions & 0 deletions src/Faker/Provider/fr_FR/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ class Address extends \Faker\Provider\Address
array('971' => 'Guadeloupe'), array('972' => 'Martinique'), array('973' => 'Guyane'), array('974' => 'La Réunion'), array('976' => 'Mayotte')
);

protected static $secondaryAddressFormats = array('Apt. ###', 'Suite ###', 'Étage ###', "Bât. ###", "Chambre ###");

/**
* @example 'Appt. 350'
*/
public static function secondaryAddress()
{
return static::numerify(static::randomElement(static::$secondaryAddressFormats));
}

/**
* @example 'rue'
*/
Expand Down
33 changes: 33 additions & 0 deletions test/Faker/Provider/fr_FR/AddressTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Faker\Test\Provider\fr_FR;

use Faker\Generator;
use Faker\Provider\fr_FR\Address;
use PHPUnit\Framework\TestCase;

class AddressTest extends TestCase
{

/**
* @var Faker\Generator
*/
private $faker;

public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Address($faker));
$this->faker = $faker;
}

/**
* @test
*/
public function testSecondaryAddress()
{
$secondaryAdress = $this->faker->secondaryAddress();
$this->assertNotEmpty($secondaryAdress);
$this->assertInternalType('string', $secondaryAdress);
}
}

0 comments on commit 07201f7

Please sign in to comment.