From 2463d3f24a9d1d8cf65b25cd2ee246591c32c9ab Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Thu, 26 Jul 2018 15:44:08 +0200 Subject: [PATCH 01/10] Add a Swiss Social Security Number (AVS13) generator. --- readme.md | 8 +++ src/Faker/Provider/fr_CH/Person.php | 83 ++++++++++++++++++++++++ test/Faker/Provider/fr_CH/PersonTest.php | 25 +++++++ 3 files changed, 116 insertions(+) create mode 100644 test/Faker/Provider/fr_CH/PersonTest.php diff --git a/readme.md b/readme.md index c37549018f..a6fed64e79 100644 --- a/readme.md +++ b/readme.md @@ -1092,6 +1092,14 @@ echo $faker->nationalId; // 'V11223344' echo $faker->taxpayerIdentificationNumber; // 'J1234567891' ``` +### `Faker\Provider\fr_CH\Person` +```php +navs13; // "756.1234.5678.97" +``` + ### `Faker\Provider\fr_FR\Address` ```php diff --git a/src/Faker/Provider/fr_CH/Person.php b/src/Faker/Provider/fr_CH/Person.php index 526a9021b5..0c6fd46322 100644 --- a/src/Faker/Provider/fr_CH/Person.php +++ b/src/Faker/Provider/fr_CH/Person.php @@ -87,4 +87,87 @@ class Person extends \Faker\Provider\fr_FR\Person 'Waeber', 'Weber', 'Wenger', 'Widmer', 'Wyss', 'Zbinden', 'Zimmermann', ); + + /** + * Generates a valid random AVS13 (swiss social security) number + * + * This function will generate a valid random AVS13 number and return it + * as a formatted string. + * + * @see https://www.zas.admin.ch/zas/fr/home/partenaires-et-institutions-/navs13.html + * @return string + */ + public function navs13() + { + $b = array( + 756, + self::generateRandomDigits(4), + self::generateRandomDigits(4), + self::generateRandomDigits(1), + ); + + $checksum = self::computeAvs13Checksum(implode("", $b)); + + $avs = sprintf("%s.%s.%s.%s%s", $b[0], $b[1], $b[2], $b[3], $checksum); + + return $avs; + } + + + /** + * Generates a string of {@see $length} random digits + * + * This function will generate a {@see $length} digits string. The length of + * the string must be greater than 0. If the provided length is lower or + * equal to 0, an \OutOfBoundsException is thrown. + * + * By default, if no {@see $length} parameter is given, the function will + * return a one-digit string. + * + * @since 0.1.0 + * @param int $length Length of the string of digits to generate + * @return string A string of {@see $length} random digits + * @throws \OutOfBoundsException + */ + protected static function generateRandomDigits($length = 1) + { + if ($length <= 0) { + throw new \OutOfBoundsException("Length must be greater than 0"); + } + + $digits = ""; + + for ($i = 0; $i < $length; $i++) { + $digits .= mt_rand(0, 9); + } + + return $digits; + } + + /** + * Computes the checksum of the first 12 digits of an AVS13 number. + * + * The checksum is computed exactly like the sum of an EAN13 number. + * + * @see https://fr.wikipedia.org/wiki/EAN_13 + * @param string $digits + * @return int + */ + protected static function computeAvs13Checksum($digits) + { + $even = true; + $esum = 0; + $osum = 0; + + for ($i = strlen($digits)-1; $i >= 0; $i--) { + if ($even) { + $esum += $digits[$i]; + } else { + $osum += $digits[$i]; + } + $even=!$even; + } + + return (10 - ((3 * $esum + $osum) % 10)) % 10; + } } diff --git a/test/Faker/Provider/fr_CH/PersonTest.php b/test/Faker/Provider/fr_CH/PersonTest.php new file mode 100644 index 0000000000..ff8551081d --- /dev/null +++ b/test/Faker/Provider/fr_CH/PersonTest.php @@ -0,0 +1,25 @@ +addProvider(new Person($faker)); + $this->faker = $faker; + } + + public function testAvsNumber() + { + $avs = $this->faker->navs13; + $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/i', $avs); + } +} \ No newline at end of file From f0fe7cb4143b62d88a197ad7d8b954cfa6080eab Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Wed, 22 Aug 2018 01:32:36 +0200 Subject: [PATCH 02/10] Add a Swiss Social Security Number (AVS13) generator - (includes changes) --- src/Faker/Calculator/Ean.php | 55 ++++++++++++++++ src/Faker/Provider/Base.php | 27 ++++++++ src/Faker/Provider/de_CH/Person.php | 28 ++++++++ src/Faker/Provider/fr_CH/Person.php | 72 ++------------------ src/Faker/Provider/it_CH/Person.php | 13 ++++ test/Faker/Calculator/EanTest.php | 84 ++++++++++++++++++++++++ test/Faker/Provider/de_CH/PersonTest.php | 34 ++++++++++ test/Faker/Provider/fr_CH/PersonTest.php | 6 +- test/Faker/Provider/it_CH/PersonTest.php | 27 ++++++++ 9 files changed, 279 insertions(+), 67 deletions(-) create mode 100644 src/Faker/Calculator/Ean.php create mode 100644 test/Faker/Calculator/EanTest.php create mode 100644 test/Faker/Provider/de_CH/PersonTest.php create mode 100644 test/Faker/Provider/it_CH/PersonTest.php diff --git a/src/Faker/Calculator/Ean.php b/src/Faker/Calculator/Ean.php new file mode 100644 index 0000000000..a1e0c076ed --- /dev/null +++ b/src/Faker/Calculator/Ean.php @@ -0,0 +1,55 @@ += 0; $i -= 2) { + $even += $digits[$i]; + } + + $odd = 0; + for ($i = $length - 2; $i >= 0; $i -= 2) { + $odd += $digits[$i]; + } + + return (10 - ((3 * $even + $odd) % 10)) % 10; + } + + /** + * Checks whether the provided number is an EAN compliant number and that + * the checksum is correct. + * + * @param string $ean An EAN number + * @return boolean + */ + public static function isValid($ean) + { + if (!preg_match(self::PATTERN, $ean)) { + return false; + } + + return self::checksum(substr($ean, 0, -1)) === intval(substr($ean, -1)); + } +} diff --git a/src/Faker/Provider/Base.php b/src/Faker/Provider/Base.php index fa321ee0d5..43a5eceb27 100644 --- a/src/Faker/Provider/Base.php +++ b/src/Faker/Provider/Base.php @@ -62,6 +62,33 @@ public static function randomDigitNot($except) return $result; } + /** + * Generates a string of random digits + * + * @param int $length Length of the string to generate + * @return string A string of {@see $length} random digits + * + * @throws \OutOfBoundsException + * @throws \InvalidArgumentException + */ + public static function randomDigitsString($length = 1) + { + if (!is_numeric($length)) { + throw new \InvalidArgumentException('the length parameter must be numeric'); + } + + if ($length <= 0) { + throw new \OutOfBoundsException('the length must be greater than 0'); + } + + $digits = ""; + for ($i = 0; $i < $length; $i++) { + $digits .= mt_rand(0, 9); + } + + return $digits; + } + /** * Returns a random integer with 0 to $nbDigits digits. * diff --git a/src/Faker/Provider/de_CH/Person.php b/src/Faker/Provider/de_CH/Person.php index afbdb9975f..58affd5918 100644 --- a/src/Faker/Provider/de_CH/Person.php +++ b/src/Faker/Provider/de_CH/Person.php @@ -86,4 +86,32 @@ class Person extends \Faker\Provider\de_DE\Person 'Wagner', 'Walker', 'Walser', 'Weber', 'Wehrli', 'Weibel', 'Weiss', 'Wenger', 'Wicki', 'Widmer', 'Willi', 'Wirth', 'Wirz', 'Wittwer', 'Wolf', 'Wyss', 'Wüthrich', 'Zaugg', 'Zbinden', 'Zehnder', 'Ziegler', 'Zimmermann', 'Zwahlen', 'Zürcher', ); + + /** + * Generates a valid random AVS13 (swiss social security) number + * + * This function acts as a localized alias for the function defined in the + * fr_CH provider. In the german-speaking part of Switzerland, the AVS13 + * number is generally known as AHV13. + * + * @see \Faker\Provider\fr_CH\Person::avs13() + * @return string + */ + public function ahv13() + { + return \Faker\Provider\fr_CH\Person::avs13(); + } + + /** + * Generates a valid random AVS13 (swiss social security) number + * + * This function acts as an alias for the function defined in the fr_CH provider. + * + * @see \Faker\Provider\fr_CH\Person::avs13() + * @return string + */ + public function avs13() + { + return \Faker\Provider\fr_CH\Person::avs13(); + } } diff --git a/src/Faker/Provider/fr_CH/Person.php b/src/Faker/Provider/fr_CH/Person.php index 0c6fd46322..84f3da9e92 100644 --- a/src/Faker/Provider/fr_CH/Person.php +++ b/src/Faker/Provider/fr_CH/Person.php @@ -97,77 +97,19 @@ class Person extends \Faker\Provider\fr_FR\Person * @see https://www.zas.admin.ch/zas/fr/home/partenaires-et-institutions-/navs13.html * @return string */ - public function navs13() + public static function avs13() { - $b = array( + $p = array( 756, - self::generateRandomDigits(4), - self::generateRandomDigits(4), - self::generateRandomDigits(1), + \Faker\Provider\Base::randomDigitsString(4), + \Faker\Provider\Base::randomDigitsString(4), + \Faker\Provider\Base::randomDigitsString(1), ); - $checksum = self::computeAvs13Checksum(implode("", $b)); + $checksum = \Faker\Calculator\Ean::checksum(implode($p)); - $avs = sprintf("%s.%s.%s.%s%s", $b[0], $b[1], $b[2], $b[3], $checksum); + $avs = sprintf("%s.%s.%s.%s%s", $p[0], $p[1], $p[2], $p[3], $checksum); return $avs; } - - - /** - * Generates a string of {@see $length} random digits - * - * This function will generate a {@see $length} digits string. The length of - * the string must be greater than 0. If the provided length is lower or - * equal to 0, an \OutOfBoundsException is thrown. - * - * By default, if no {@see $length} parameter is given, the function will - * return a one-digit string. - * - * @since 0.1.0 - * @param int $length Length of the string of digits to generate - * @return string A string of {@see $length} random digits - * @throws \OutOfBoundsException - */ - protected static function generateRandomDigits($length = 1) - { - if ($length <= 0) { - throw new \OutOfBoundsException("Length must be greater than 0"); - } - - $digits = ""; - - for ($i = 0; $i < $length; $i++) { - $digits .= mt_rand(0, 9); - } - - return $digits; - } - - /** - * Computes the checksum of the first 12 digits of an AVS13 number. - * - * The checksum is computed exactly like the sum of an EAN13 number. - * - * @see https://fr.wikipedia.org/wiki/EAN_13 - * @param string $digits - * @return int - */ - protected static function computeAvs13Checksum($digits) - { - $even = true; - $esum = 0; - $osum = 0; - - for ($i = strlen($digits)-1; $i >= 0; $i--) { - if ($even) { - $esum += $digits[$i]; - } else { - $osum += $digits[$i]; - } - $even=!$even; - } - - return (10 - ((3 * $esum + $osum) % 10)) % 10; - } } diff --git a/src/Faker/Provider/it_CH/Person.php b/src/Faker/Provider/it_CH/Person.php index 5592fb530e..6587922edb 100644 --- a/src/Faker/Provider/it_CH/Person.php +++ b/src/Faker/Provider/it_CH/Person.php @@ -85,4 +85,17 @@ class Person extends \Faker\Provider\it_IT\Person 'Weber', 'Widmer', 'Zanetti', 'Zanini', 'Zimmermann', ); + + /** + * Generates a valid random AVS13 (swiss social security) number + * + * This function acts as an alias for the function defined in the fr_CH provider. + * + * @see \Faker\Provider\fr_CH\Person::avs13() + * @return string + */ + public function avs13() + { + return \Faker\Provider\fr_CH\Person::avs13(); + } } diff --git a/test/Faker/Calculator/EanTest.php b/test/Faker/Calculator/EanTest.php new file mode 100644 index 0000000000..a486ca9a61 --- /dev/null +++ b/test/Faker/Calculator/EanTest.php @@ -0,0 +1,84 @@ +assertEquals($checksum, Ean::checksum($partial)); + } + + /** + * @dataProvider ean8ValidationProvider + */ + public function testEan8Validation($ean8, $valid) + { + $this->assertTrue(Ean::isValid($ean8) === $valid); + } + + public function Ean13checksumProvider() + { + return array( + array('123456789123', '1'), + array('978020137962', '4'), + array('235469852146', '9'), + array('300109265083', '5'), + array('392109219083', '7'), + ); + } + + public function ean13ValidationProvider() + { + return array( + array('1234567891231', true), + array('2354698521469', true), + array('3001092650834', false), + array('3921092190838', false), + ); + } + + /** + * @dataProvider Ean13checksumProvider + */ + public function testChecksumEan13($partial, $checksum) + { + $this->assertEquals($checksum, Ean::checksum($partial)); + } + + /** + * @dataProvider ean13ValidationProvider + */ + public function testEan13Validation($ean13, $valid) + { + $this->assertTrue(Ean::isValid($ean13) === $valid); + } + +} \ No newline at end of file diff --git a/test/Faker/Provider/de_CH/PersonTest.php b/test/Faker/Provider/de_CH/PersonTest.php new file mode 100644 index 0000000000..06fa06eb2f --- /dev/null +++ b/test/Faker/Provider/de_CH/PersonTest.php @@ -0,0 +1,34 @@ +addProvider(new Person($faker)); + $this->faker = $faker; + } + + public function testAvs13Number() + { + $avs = $this->faker->avs13; + $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $avs); + $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); + } + + public function testAhv13Number() + { + $ahv = $this->faker->ahv13; + $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $ahv); + $this->assertTrue(Ean::isValid(str_replace('.', '', $ahv))); + } +} \ No newline at end of file diff --git a/test/Faker/Provider/fr_CH/PersonTest.php b/test/Faker/Provider/fr_CH/PersonTest.php index ff8551081d..96e8a1b9ea 100644 --- a/test/Faker/Provider/fr_CH/PersonTest.php +++ b/test/Faker/Provider/fr_CH/PersonTest.php @@ -2,6 +2,7 @@ namespace Faker\Test\Provider\fr_CH; +use Faker\Calculator\Ean; use Faker\Generator; use Faker\Provider\fr_CH\Person; use PHPUnit\Framework\TestCase; @@ -19,7 +20,8 @@ public function setUp() public function testAvsNumber() { - $avs = $this->faker->navs13; - $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/i', $avs); + $avs = $this->faker->avs13; + $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $avs); + $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); } } \ No newline at end of file diff --git a/test/Faker/Provider/it_CH/PersonTest.php b/test/Faker/Provider/it_CH/PersonTest.php new file mode 100644 index 0000000000..3dfaa0d778 --- /dev/null +++ b/test/Faker/Provider/it_CH/PersonTest.php @@ -0,0 +1,27 @@ +addProvider(new Person($faker)); + $this->faker = $faker; + } + + public function testAvs13Number() + { + $avs = $this->faker->avs13; + $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $avs); + $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); + } +} \ No newline at end of file From 564adf1f838e1580d1e3229cb29369d6b2e80c6f Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Wed, 22 Aug 2018 01:45:05 +0200 Subject: [PATCH 03/10] Set avs13 methods as static --- src/Faker/Provider/de_CH/Person.php | 4 ++-- src/Faker/Provider/it_CH/Person.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Faker/Provider/de_CH/Person.php b/src/Faker/Provider/de_CH/Person.php index 58affd5918..ce9493e30b 100644 --- a/src/Faker/Provider/de_CH/Person.php +++ b/src/Faker/Provider/de_CH/Person.php @@ -97,7 +97,7 @@ class Person extends \Faker\Provider\de_DE\Person * @see \Faker\Provider\fr_CH\Person::avs13() * @return string */ - public function ahv13() + public static function ahv13() { return \Faker\Provider\fr_CH\Person::avs13(); } @@ -110,7 +110,7 @@ public function ahv13() * @see \Faker\Provider\fr_CH\Person::avs13() * @return string */ - public function avs13() + public static function avs13() { return \Faker\Provider\fr_CH\Person::avs13(); } diff --git a/src/Faker/Provider/it_CH/Person.php b/src/Faker/Provider/it_CH/Person.php index 6587922edb..12ef337960 100644 --- a/src/Faker/Provider/it_CH/Person.php +++ b/src/Faker/Provider/it_CH/Person.php @@ -94,7 +94,7 @@ class Person extends \Faker\Provider\it_IT\Person * @see \Faker\Provider\fr_CH\Person::avs13() * @return string */ - public function avs13() + public static function avs13() { return \Faker\Provider\fr_CH\Person::avs13(); } From 70c001fc8e6b2c537bab7496cf7a64a63f837a56 Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Wed, 22 Aug 2018 02:00:46 +0200 Subject: [PATCH 04/10] Add relevant documentation to the README. --- readme.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index a6fed64e79..6a7ff8e1f9 100644 --- a/readme.md +++ b/readme.md @@ -859,6 +859,15 @@ echo $faker->cvr; // "32458723" echo $faker->p; // "5398237590" ``` +### `Faker\Provider\de_CH\Person` +```php +avs13; // "756.1234.5678.97" OR +echo $faker->ahv13; // "756.1234.5678.97" +``` + ### `Faker\Provider\de_DE\Payment` ```php @@ -1097,7 +1106,7 @@ echo $faker->taxpayerIdentificationNumber; // 'J1234567891' navs13; // "756.1234.5678.97" +echo $faker->avs13; // "756.1234.5678.97" ``` ### `Faker\Provider\fr_FR\Address` @@ -1200,6 +1209,14 @@ echo $faker->bankAccountNumber; // "HU09904437680048220079300783" echo $faker->nik(); // "8522246001570940" ``` +### `Faker\Provider\it_CH\Person` +```php +avs13; // "756.1234.5678.97" +``` + ### `Faker\Provider\it_IT\Company` ```php From 9d279a974da25d5023e910c7c2ea63a798322bb9 Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Wed, 22 Aug 2018 10:24:13 +0200 Subject: [PATCH 05/10] Update README to include documentation for randomDigitsString. --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 6a7ff8e1f9..e07ff19911 100644 --- a/readme.md +++ b/readme.md @@ -104,6 +104,7 @@ Each of the generator properties (like `name`, `address`, and `lorem`) are calle randomDigit // 7 randomDigitNotNull // 5 + randomDigitsString($length = 1) // '0325698745' randomNumber($nbDigits = NULL, $strict = false) // 79907610 randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL) // 48.8932 numberBetween($min = 1000, $max = 9000) // 8567 From c62561affa22c28752c19f1cfe64732292a5cb4d Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Sun, 26 Aug 2018 15:31:15 +0200 Subject: [PATCH 06/10] Add missing tests for the randomDigitsString method --- test/Faker/Provider/BaseTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Faker/Provider/BaseTest.php b/test/Faker/Provider/BaseTest.php index e619d5be0a..22c7bf3b20 100644 --- a/test/Faker/Provider/BaseTest.php +++ b/test/Faker/Provider/BaseTest.php @@ -35,6 +35,32 @@ public function testRandomDigitNotReturnsValidDigit() } } + public function testRandomDigitsStringReturnsString() + { + $this->assertInternalType('string', BaseProvider::randomDigitsString()); + } + + public function testRandomDigitsStringReturnsOnlyDigits() + { + $this->assertRegExp('/^\d+$/', BaseProvider::randomDigitsString(5)); + } + + /** + * @expectedException \OutOfBoundsException + */ + public function testRandomDigitsStringThrowsExceptionWhenCalledWithInvalidLength() + { + BaseProvider::randomDigitsString(0); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testRandomDigitsStringThrowsExceptionWhenCalledWithNonNumericalLength() + { + BaseProvider::randomDigitsString('a'); + } + /** * @expectedException \InvalidArgumentException */ From 2d85a04515774f51d65e1aebb0081e6ec2bc3b4e Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Thu, 27 Sep 2018 14:51:42 +0200 Subject: [PATCH 07/10] Remove randomDigitsString function as a similar numerify() function already exists. --- src/Faker/Provider/Base.php | 27 --------------------------- src/Faker/Provider/fr_CH/Person.php | 6 +++--- test/Faker/Provider/BaseTest.php | 26 -------------------------- 3 files changed, 3 insertions(+), 56 deletions(-) diff --git a/src/Faker/Provider/Base.php b/src/Faker/Provider/Base.php index 43a5eceb27..fa321ee0d5 100644 --- a/src/Faker/Provider/Base.php +++ b/src/Faker/Provider/Base.php @@ -62,33 +62,6 @@ public static function randomDigitNot($except) return $result; } - /** - * Generates a string of random digits - * - * @param int $length Length of the string to generate - * @return string A string of {@see $length} random digits - * - * @throws \OutOfBoundsException - * @throws \InvalidArgumentException - */ - public static function randomDigitsString($length = 1) - { - if (!is_numeric($length)) { - throw new \InvalidArgumentException('the length parameter must be numeric'); - } - - if ($length <= 0) { - throw new \OutOfBoundsException('the length must be greater than 0'); - } - - $digits = ""; - for ($i = 0; $i < $length; $i++) { - $digits .= mt_rand(0, 9); - } - - return $digits; - } - /** * Returns a random integer with 0 to $nbDigits digits. * diff --git a/src/Faker/Provider/fr_CH/Person.php b/src/Faker/Provider/fr_CH/Person.php index 84f3da9e92..b2e597ff92 100644 --- a/src/Faker/Provider/fr_CH/Person.php +++ b/src/Faker/Provider/fr_CH/Person.php @@ -101,9 +101,9 @@ public static function avs13() { $p = array( 756, - \Faker\Provider\Base::randomDigitsString(4), - \Faker\Provider\Base::randomDigitsString(4), - \Faker\Provider\Base::randomDigitsString(1), + self::numerify('####'), + self::numerify('####'), + self::numerify('#'), ); $checksum = \Faker\Calculator\Ean::checksum(implode($p)); diff --git a/test/Faker/Provider/BaseTest.php b/test/Faker/Provider/BaseTest.php index 22c7bf3b20..e619d5be0a 100644 --- a/test/Faker/Provider/BaseTest.php +++ b/test/Faker/Provider/BaseTest.php @@ -35,32 +35,6 @@ public function testRandomDigitNotReturnsValidDigit() } } - public function testRandomDigitsStringReturnsString() - { - $this->assertInternalType('string', BaseProvider::randomDigitsString()); - } - - public function testRandomDigitsStringReturnsOnlyDigits() - { - $this->assertRegExp('/^\d+$/', BaseProvider::randomDigitsString(5)); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testRandomDigitsStringThrowsExceptionWhenCalledWithInvalidLength() - { - BaseProvider::randomDigitsString(0); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRandomDigitsStringThrowsExceptionWhenCalledWithNonNumericalLength() - { - BaseProvider::randomDigitsString('a'); - } - /** * @expectedException \InvalidArgumentException */ From d3ad8801983aadbb57285959b06802504b27f47c Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Mon, 2 Sep 2019 16:57:02 +0200 Subject: [PATCH 08/10] Fix incorrect indentation --- test/Faker/Provider/de_CH/PersonTest.php | 8 ++++---- test/Faker/Provider/fr_CH/PersonTest.php | 8 ++++---- test/Faker/Provider/it_CH/PersonTest.php | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/Faker/Provider/de_CH/PersonTest.php b/test/Faker/Provider/de_CH/PersonTest.php index 06fa06eb2f..4adb0b4c3f 100644 --- a/test/Faker/Provider/de_CH/PersonTest.php +++ b/test/Faker/Provider/de_CH/PersonTest.php @@ -18,12 +18,12 @@ public function setUp() $this->faker = $faker; } - public function testAvs13Number() + public function testAvs13Number() { - $avs = $this->faker->avs13; + $avs = $this->faker->avs13; $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $avs); - $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); - } + $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); + } public function testAhv13Number() { diff --git a/test/Faker/Provider/fr_CH/PersonTest.php b/test/Faker/Provider/fr_CH/PersonTest.php index 96e8a1b9ea..1368b0a3c8 100644 --- a/test/Faker/Provider/fr_CH/PersonTest.php +++ b/test/Faker/Provider/fr_CH/PersonTest.php @@ -18,10 +18,10 @@ public function setUp() $this->faker = $faker; } - public function testAvsNumber() + public function testAvsNumber() { - $avs = $this->faker->avs13; + $avs = $this->faker->avs13; $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $avs); - $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); - } + $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); + } } \ No newline at end of file diff --git a/test/Faker/Provider/it_CH/PersonTest.php b/test/Faker/Provider/it_CH/PersonTest.php index 3dfaa0d778..cbc0b0fb37 100644 --- a/test/Faker/Provider/it_CH/PersonTest.php +++ b/test/Faker/Provider/it_CH/PersonTest.php @@ -18,10 +18,10 @@ public function setUp() $this->faker = $faker; } - public function testAvs13Number() + public function testAvs13Number() { - $avs = $this->faker->avs13; + $avs = $this->faker->avs13; $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $avs); - $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); - } + $this->assertTrue(Ean::isValid(str_replace('.', '', $avs))); + } } \ No newline at end of file From c47716b1913654af36907ebb2d55a8c098a98ab2 Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Mon, 2 Sep 2019 16:57:34 +0200 Subject: [PATCH 09/10] Remove unwanted method documentation --- readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.md b/readme.md index e07ff19911..6a7ff8e1f9 100644 --- a/readme.md +++ b/readme.md @@ -104,7 +104,6 @@ Each of the generator properties (like `name`, `address`, and `lorem`) are calle randomDigit // 7 randomDigitNotNull // 5 - randomDigitsString($length = 1) // '0325698745' randomNumber($nbDigits = NULL, $strict = false) // 79907610 randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL) // 48.8932 numberBetween($min = 1000, $max = 9000) // 8567 From eca76032de40ab11bf941ece31a312cb943ca5fe Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Mon, 2 Sep 2019 16:59:01 +0200 Subject: [PATCH 10/10] Rename test method to be consistent with the other PersonTest.php files in de_CH and it_CH. --- test/Faker/Provider/fr_CH/PersonTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Faker/Provider/fr_CH/PersonTest.php b/test/Faker/Provider/fr_CH/PersonTest.php index 1368b0a3c8..9bfec99f67 100644 --- a/test/Faker/Provider/fr_CH/PersonTest.php +++ b/test/Faker/Provider/fr_CH/PersonTest.php @@ -18,7 +18,7 @@ public function setUp() $this->faker = $faker; } - public function testAvsNumber() + public function testAvs13Number() { $avs = $this->faker->avs13; $this->assertRegExp('/^756\.([0-9]{4})\.([0-9]{4})\.([0-9]{2})$/', $avs);