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
<?php
namespace Faker\Test\Provider\fr_FR;
use Faker\Calculator\Luhn;
use Faker\Generator;
use Faker\Provider\fr_FR\Company;
class CompanyTest extends \PHPUnit_Framework_TestCase
{
private $faker;
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Company($faker));
$this->faker = $faker;
}
public function testSiretReturnsAValidSiret()
{
$siret = $this->faker->siret(false);
$this->assertRegExp("/^\d{14}$/", $siret);
$this->assertTrue(Luhn::isValid($siret));
}
public function testSiretReturnsAWellFormattedSiret()
{
$siret = $this->faker->siret();
$this->assertRegExp("/^\d{3}\s\d{3}\s\d{3}\s\d{5}$/", $siret);
$siret = str_replace(' ', '', $siret);
$this->assertTrue(Luhn::isValid($siret));
}
public function testSirenReturnsAValidSiren()
{
$siren = $this->faker->siren(false);
$this->assertRegExp("/^\d{9}$/", $siren);
$this->assertTrue(Luhn::isValid($siren));
}
public function testSirenReturnsAWellFormattedSiren()
{
$siren = $this->faker->siren();
$this->assertRegExp("/^\d{3}\s\d{3}\s\d{3}$/", $siren);
$siren = str_replace(' ', '', $siren);
$this->assertTrue(Luhn::isValid($siren));
}
public function testCatchPhraseReturnsValidCatchPhrase()
{
$this->assertTrue(TestableCompany::isCatchPhraseValid($this->faker->catchPhrase()));
}
public function testIsCatchPhraseValidReturnsFalseWhenAWordsAppearsTwice()
{
$isCatchPhraseValid = TestableCompany::isCatchPhraseValid('La sécurité de rouler en toute sécurité');
$this->assertFalse($isCatchPhraseValid);
}
public function testIsCatchPhraseValidReturnsTrueWhenNoWordAppearsTwice()
{
$isCatchPhraseValid = TestableCompany::isCatchPhraseValid('La sécurité de rouler en toute simplicité');
$this->assertTrue($isCatchPhraseValid);
}
}
class TestableCompany extends Company
{
public static function isCatchPhraseValid($catchPhrase)
{
return parent::isCatchPhraseValid($catchPhrase);
}
}