<commit_before><?php

namespace CfdiUtilsTests\Validate\Cfdi33\Standard;

use CfdiUtils\Nodes\Node;
use CfdiUtils\Validate\Cfdi33\Standard\EmisorRegimenFiscal;
use CfdiUtils\Validate\Status;
use CfdiUtilsTests\Validate\ValidateTestCase;

class EmisorRegimenFiscalTest extends ValidateTestCase
{
    /** @var  EmisorRegimenFiscal */
    protected $validator;

    protected function setUp()
    {
        parent::setUp();
        $this->validator = new EmisorRegimenFiscal();
    }

    public function providerValidCases()
    {
        return[
            // personas morales
            ['AAA010101AAA', '601'],
            ['AAA010101AAA', '603'],
            ['AAA010101AAA', '609'],
            ['AAA010101AAA', '610'],
            ['AAA010101AAA', '620'],
            ['AAA010101AAA', '622'],
            ['AAA010101AAA', '623'],
            ['AAA010101AAA', '624'],
            ['AAA010101AAA', '628'],
            ['AAA010101AAA', '607'],
            // personas físicas
            ['AAAA010101AAA', '605'],
            ['AAAA010101AAA', '606'],
            ['AAAA010101AAA', '608'],
            ['AAAA010101AAA', '610'],
            ['AAAA010101AAA', '611'],
            ['AAAA010101AAA', '612'],
            ['AAAA010101AAA', '614'],
            ['AAAA010101AAA', '616'],
            ['AAAA010101AAA', '621'],
            ['AAAA010101AAA', '622'],
            ['AAAA010101AAA', '629'],
            ['AAAA010101AAA', '630'],
            ['AAAA010101AAA', '615'],
        ];
    }

    /**
     * @param string $emisorRfc
     * @param string $regimenFiscal
     * @dataProvider providerValidCases
     */
    public function testValidCases($emisorRfc, $regimenFiscal)
    {
        $this->comprobante->addChild(new Node('cfdi:Emisor', [
            'RegimenFiscal' => $regimenFiscal,
            'Rfc' => $emisorRfc,
        ]));

        $this->runValidate();
        $this->assertStatusEqualsCode(Status::ok(), 'REGFIS01');
    }

    public function providerInvalidCases()
    {
        return [
            ['AAA010101AAA', '605'], // persona moral con regimen incorrecto
            ['AAAA010101AAA', '601'], // persona física con regimen incorrecto
            ['', '615'], // RFC vacío, con regimen
            ['', ''], // RFC vacío, regimen vacío
            [null, ''], // sin RFC, regimen vacío
            [null, '630'], // sin RFC, con regimen
            [null, null],  // sin RFC, sin regimen
        ];
    }<commit_msg>Add invalid RFC and RFC with Ñ (create failures)<commit_after><?php

namespace CfdiUtilsTests\Validate\Cfdi33\Standard;

use CfdiUtils\Nodes\Node;
use CfdiUtils\Validate\Cfdi33\Standard\EmisorRegimenFiscal;
use CfdiUtils\Validate\Status;
use CfdiUtilsTests\Validate\ValidateTestCase;

class EmisorRegimenFiscalTest extends ValidateTestCase
{
    /** @var  EmisorRegimenFiscal */
    protected $validator;

    protected function setUp()
    {
        parent::setUp();
        $this->validator = new EmisorRegimenFiscal();
    }

    public function providerValidCases()
    {
        return[
            // personas morales
            ['AAA010101AAA', '601'],
            ['AAA010101AAA', '603'],
            ['AAA010101AAA', '609'],
            ['AAA010101AAA', '610'],
            ['AAA010101AAA', '620'],
            ['AAA010101AAA', '622'],
            ['AAA010101AAA', '623'],
            ['AAA010101AAA', '624'],
            ['AAA010101AAA', '628'],
            ['AAA010101AAA', '607'],
            ['ÑAA010101AAA', '601'], // with Ñ
            // personas físicas
            ['AAAA010101AAA', '605'],
            ['AAAA010101AAA', '606'],
            ['AAAA010101AAA', '608'],
            ['AAAA010101AAA', '610'],
            ['AAAA010101AAA', '611'],
            ['AAAA010101AAA', '612'],
            ['AAAA010101AAA', '614'],
            ['AAAA010101AAA', '616'],
            ['AAAA010101AAA', '621'],
            ['AAAA010101AAA', '622'],
            ['AAAA010101AAA', '629'],
            ['AAAA010101AAA', '630'],
            ['AAAA010101AAA', '615'],
            ['ÑAAA010101AAA', '605'], // with Ñ
            ['AAA010000AAA', '601'], // RFC inválido, regimen válido persona moral
            ['AAAA010000AAA', '605'], // RFC inválido, regimen válido persona física
        ];
    }

    /**
     * @param string $emisorRfc
     * @param string $regimenFiscal
     * @dataProvider providerValidCases
     */
    public function testValidCases($emisorRfc, $regimenFiscal)
    {
        $this->comprobante->addChild(new Node('cfdi:Emisor', [
            'RegimenFiscal' => $regimenFiscal,
            'Rfc' => $emisorRfc,
        ]));

        $this->runValidate();
        $this->assertStatusEqualsCode(Status::ok(), 'REGFIS01');
    }

    public function providerInvalidCases()
    {
        return [
            ['AAA010101AAA', '605'], // persona moral con regimen incorrecto
            ['AAAA010101AAA', '601'], // persona física con regimen incorrecto
            ['', '615'], // RFC vacío, con regimen
            ['', ''], // RFC vacío, regimen vacío
            [null, ''], // sin RFC, regimen vacío
            [null, '630'], // sin RFC, con regimen
            [null, null],  // sin RFC, sin regimen
        ];
    }
{'fraction_non_alphanumeric': 0.15645472061657031, 'fraction_numerical': 0.09826589595375723, 'mean_word_length': 2.0697811945594324, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '260668', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1554, 'n_words': 322}