HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/Lacom/lacom.nl/vendor/fzaninotto/faker/test/Faker/Provider/fr_FR/PaymentTest.php
<?php

namespace Faker\Test\Provider\fr_FR;

use Faker\Calculator\Luhn;
use Faker\Generator;
use Faker\Provider\fr_FR\Payment;
use PHPUnit\Framework\TestCase;

class PaymentTest extends TestCase
{
    private $faker;

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

    public function testFormattedVat()
    {
        $vat = $this->faker->vat(true);
        $this->assertRegExp("/^FR\s\w{2}\s\d{3}\s\d{3}\s\d{3}$/", $vat);

        $vat = str_replace(' ', '', $vat);
        $siren = substr($vat, 4, 12);
        $this->assertTrue(Luhn::isValid($siren));

        $key = (int) substr($siren, 2, 2);
        if ($key === 0) {
            $this->assertEqual($key, (12 + 3 * ($siren % 97)) % 97);            
        }
    }

    public function testUnformattedVat()
    {
        $vat = $this->faker->vat(false);
        $this->assertRegExp("/^FR\w{2}\d{9}$/", $vat);

        $siren = substr($vat, 4, 12);
        $this->assertTrue(Luhn::isValid($siren));

        $key = (int) substr($siren, 2, 2);
        if ($key === 0) {
            $this->assertEqual($key, (12 + 3 * ($siren % 97)) % 97);            
        }
    }
}