<commit_before><?php

namespace tests\NilPortugues\Validator;

use NilPortugues\Validator\Validator;

/**
 * Class ValidatorTest
 * @package tests\NilPortugues\Validator
 */
class ValidatorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Validator
     */
    private $validator;

    /**
     *
     */
    public function setUp()
    {
        $this->validator = new Validator();
    }

    /**
     *
     */
    public function tearDown()
    {
        $this->validator = null;
    }

    /**
     * @test
     */
    public function itShouldGetIntegerClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Numeric\Integer',
            get_class($this->validator->isInteger('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldGetFloatClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Numeric\Float',
            get_class($this->validator->isFloat('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldGetArrayClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Collection\Collection',
            get_class($this->validator->isArray('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldGetObjectClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Object\Object',
            get_class($this->validator->isObject('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldReturnPropertyName()
    {
        $this->assertEmpty($this->validator->getPropertyName());

        $this->validator->isArray('propertyName');
        $this->assertSame('propertyName', $this->validator->getPropertyName());
    }

    /**
     * @test
     */
    public function itShouldThrowExceptionIfLanguageFileNotFound()
    {
        $this->setExpectedException('\InvalidArgumentException');
        $validator = new Validator('locale.php');

        $stringValidator = $validator->isString('property');
        $stringValidator->isBetween(500,1000)->validate('a');
        $stringValidator->getErrors();
    }

    /**
     * @test
     */
    public function itShouldThrowRuntimeExceptionIfFunctionMapIsNotFound()
    {
        $validator = new Validator();
        $reflection = new \ReflectionObject($validator);

        $property = $reflection->getProperty("functionMapFile");
        $property->setAccessible(true);
        $property->setValue($validator, 'notFound.php');

        $this->setExpectedException('\RuntimeException');
        $method = $reflection->getMethod('buildFunctionMap');
        $method->setAccessible(true);
        $method->invoke($validator);
    }
}<commit_msg>removed unused line<commit_after><?php

namespace tests\NilPortugues\Validator;

use NilPortugues\Validator\Validator;

/**
 * Class ValidatorTest
 * @package tests\NilPortugues\Validator
 */
class ValidatorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Validator
     */
    private $validator;

    /**
     *
     */
    public function setUp()
    {
        $this->validator = new Validator();
    }

    /**
     *
     */
    public function tearDown()
    {
        $this->validator = null;
    }

    /**
     * @test
     */
    public function itShouldGetIntegerClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Numeric\Integer',
            get_class($this->validator->isInteger('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldGetFloatClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Numeric\Float',
            get_class($this->validator->isFloat('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldGetArrayClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Collection\Collection',
            get_class($this->validator->isArray('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldGetObjectClass()
    {
        $this->assertSame(
            'NilPortugues\Validator\Attribute\Object\Object',
            get_class($this->validator->isObject('propertyName'))
        );
    }

    /**
     * @test
     */
    public function itShouldReturnPropertyName()
    {
        $this->assertEmpty($this->validator->getPropertyName());

        $this->validator->isArray('propertyName');
        $this->assertSame('propertyName', $this->validator->getPropertyName());
    }

    /**
     * @test
     */
    public function itShouldThrowExceptionIfLanguageFileNotFound()
    {
        $this->setExpectedException('\InvalidArgumentException');
        $validator = new Validator('locale.php');

        $stringValidator = $validator->isString('property');
        $stringValidator->isBetween(500,1000)->validate('a');
    }

    /**
     * @test
     */
    public function itShouldThrowRuntimeExceptionIfFunctionMapIsNotFound()
    {
        $validator = new Validator();
        $reflection = new \ReflectionObject($validator);

        $property = $reflection->getProperty("functionMapFile");
        $property->setAccessible(true);
        $property->setValue($validator, 'notFound.php');

        $this->setExpectedException('\RuntimeException');
        $method = $reflection->getMethod('buildFunctionMap');
        $method->setAccessible(true);
        $method->invoke($validator);
    }
}
{'fraction_non_alphanumeric': 0.1413849213523775, 'fraction_numerical': 0.0025311878502983186, 'mean_word_length': 2.354760460885385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 70, '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': '926307', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1525, 'n_words': 193}