Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@
* @property string $uuid
*
* @method string uuid()
*
* @property string $sin()
*
* @method string sin()
*
*/
class Generator
{
Expand Down
21 changes: 21 additions & 0 deletions src/Provider/en_CA/Person.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Faker\Provider\en_CA;

class Person extends \Faker\Provider\Person {

/**
* @example '744-884-672'
*
* @return string
*
* Generated values are intentionally not Luhn-valid and should be used for testing purposes only.
*/
public function sin()
{

$first = static::randomElement([1,2,3,4,5,6,7,9]);
return $first . static::numerify('##-###-###');

}
}
29 changes: 29 additions & 0 deletions test/Provider/en_CA/PersonTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Faker\Provider\en_CA;

use Faker\Test\TestCase;

/**
* @group legacy
*/
final class PersonTest extends TestCase
{
/**
* Test the validity of SIN
*/
public function testSin(): void
{
$sin = $this->faker->sin();
self::assertNotEmpty($sin);
self::assertIsString($sin);
self::assertMatchesRegularExpression('/^[1-79]\d{2}-\d{3}-\d{3}$/', $sin);
}

protected function getProviders(): iterable
{
yield new Person($this->faker);
}
}