<commit_before><?php

/*
 * This file is part of the Valit package.
 *
 * @package Valit
 * @author <NAME> <<EMAIL>>
 * @copyright 2016
 * @license MIT
 */

namespace spec\Moccalotto\Valit;

use PhpSpec\ObjectBehavior;

class ManagerSpec extends ObjectBehavior
{
    public function it_is_initializable()
    {
        $this->beConstructedWith([]);
        $this->shouldHaveType('Moccalotto\Valit\Manager');
        $this->shouldHaveType('Moccalotto\Valit\Contracts\CheckManager');
    }

    public function it_loads_core_providers()
    {
        $this->beConstructedThrough('create');

        $this->hasCheck('isNumeric')->shouldBe(true);
        $this->hasCheck('decimalString')->shouldBe(true);
    }

    public function it_can_execute_checks()
    {
        $this->beConstructedThrough('create');

        $this->executeCheck('isNumeric', 42, [])
            ->shouldHaveType('Moccalotto\Valit\Result');

        $this->executeCheck('isNumeric', 42, [])->success()->shouldBe(true);
    }

    public function it_has_default_global_instance()
    {
        $this->beConstructedThrough('instance');

        $this->shouldHaveType('Moccalotto\Valit\Contracts\CheckManager');

        $this->instance()->shouldBe($this->getWrappedObject());
    }

    /**
     * Must be last because of use of setAsGlobal()
     */
    public function it_can_override_global()
    {
        $this->beConstructedThrough('create');

        $this->instance()->shouldNotBe($this->getWrappedObject());

        $this->setAsGlobal();

        $this->instance()->shouldBe($this->getWrappedObject());
    }

}<commit_msg>Test for robustness.<commit_after><?php

/*
 * This file is part of the Valit package.
 *
 * @package Valit
 * @author <NAME> <<EMAIL>>
 * @copyright 2016
 * @license MIT
 */

namespace spec\Moccalotto\Valit;

use PhpSpec\ObjectBehavior;

class ManagerSpec extends ObjectBehavior
{
    public function it_is_initializable()
    {
        $this->beConstructedWith([]);
        $this->shouldHaveType('Moccalotto\Valit\Manager');
        $this->shouldHaveType('Moccalotto\Valit\Contracts\CheckManager');
    }

    public function it_loads_core_providers()
    {
        $this->beConstructedThrough('create');

        $this->hasCheck('isNumeric')->shouldBe(true);
        $this->hasCheck('decimalString')->shouldBe(true);
    }

    public function it_can_execute_checks()
    {
        $this->beConstructedThrough('create');

        $this->executeCheck('isNumeric', 42, [])
            ->shouldHaveType('Moccalotto\Valit\Result');

        $this->executeCheck('isNumeric', 42, [])->success()->shouldBe(true);

        $this->shouldThrow('UnexpectedValueException')->duringExecuteCheck(
            'someCheckThatDoesntExist',
            42,
            []
        );
    }

    public function it_has_default_global_instance()
    {
        $this->beConstructedThrough('instance');

        $this->shouldHaveType('Moccalotto\Valit\Contracts\CheckManager');

        $this->instance()->shouldBe($this->getWrappedObject());
    }

    /**
     * Must be last because of use of setAsGlobal()
     */
    public function it_can_override_global()
    {
        $this->beConstructedThrough('create');

        $this->instance()->shouldNotBe($this->getWrappedObject());

        $this->setAsGlobal();

        $this->instance()->shouldBe($this->getWrappedObject());
    }

}
{'fraction_non_alphanumeric': 0.15281899109792285, 'fraction_numerical': 0.005341246290801187, 'mean_word_length': 3.1412776412776413, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 65, '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': '2217305', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1000, 'n_words': 143}