<commit_before><?php

/*
 * This file is part of Respect/Validation.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the "LICENSE.md"
 * file that was distributed with this source code.
 */

namespace Respect\Validation\Rules;

/**
 * @group  rule
 * @covers Respect\Validation\Rules\Contains
 * @covers Respect\Validation\Exceptions\ContainsException
 */
class ContainsTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider providerForContains
     */
    public function testStringsContainingExpectedValueShouldPass($start, $input)
    {
        $v = new Contains($start);
        $this->assertTrue($v->__invoke($input));
        $this->assertTrue($v->check($input));
        $this->assertTrue($v->assert($input));
    }

    /**
     * @dataProvider providerForNotContains
     * @expectedException Respect\Validation\Exceptions\ContainsException
     */
    public function testStringsNotContainsExpectedValueShouldNotPass($start, $input, $identical = false)
    {
        $v = new Contains($start, $identical);
        $this->assertFalse($v->__invoke($input));
        $this->assertFalse($v->assert($input));
    }

    public function providerForContains()
    {
        return array(
            array('foo', array('bar', 'foo')),
            array('foo', 'barbazFOO'),
            array('foo', 'barbazfoo'),
            array('foo', 'foobazfoo'),
            array('1', array(2, 3, 1)),
            array('1', array(2, 3, '1'), true),
        );
    }

    public function providerForNotContains()
    {
        return array(
            array('foo', ''),
            array('bat', array('bar', 'foo')),
            array('foo', 'barfaabaz'),
            array('foo', 'barbazFOO', true),
            array('foo', 'faabarbaz'),
        );
    }
}<commit_msg>Refactoring unit tests of "Contains" rule<commit_after><?php

/*
 * This file is part of Respect/Validation.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the "LICENSE.md"
 * file that was distributed with this source code.
 */

namespace Respect\Validation\Rules;

/**
 * @group  rule
 * @covers Respect\Validation\Rules\Contains
 * @covers Respect\Validation\Exceptions\ContainsException
 */
class ContainsTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider providerForContainsIdentical
     */
    public function testStringsContainingExpectedIdenticalValueShouldPass($start, $input)
    {
        $v = new Contains($start, true);
        $this->assertTrue($v->validate($input));
    }

    /**
     * @dataProvider providerForContains
     */
    public function testStringsContainingExpectedValueShouldPass($start, $input)
    {
        $v = new Contains($start, false);
        $this->assertTrue($v->validate($input));
    }

    /**
     * @dataProvider providerForNotContainsIdentical
     */
    public function testStringsNotContainsExpectedIdenticalValueShouldNotPass($start, $input)
    {
        $v = new Contains($start, true);
        $this->assertFalse($v->validate($input));
    }

    /**
     * @dataProvider providerForNotContains
     */
    public function testStringsNotContainsExpectedValueShouldNotPass($start, $input)
    {
        $v = new Contains($start, false);
        $this->assertFalse($v->validate($input));
    }

    public function providerForContains()
    {
        return array(
            array('foo', array('bar', 'foo')),
            array('foo', 'barbazFOO'),
            array('foo', 'barbazfoo'),
            array('foo', 'foobazfoO'),
            array('1', array(2, 3, 1)),
            array('1', array(2, 3, '1')),
        );
    }

    public function providerForContainsIdentical()
    {
        return array(
            array('foo', array('fool', 'foo')),
            array('foo', 'barbazfoo'),
            array('foo', 'foobazfoo'),
            array('1', array(2, 3, (string) 1)),
            array('1', array(2, 3, '1')),
        );
    }

    public function providerForNotContains()
    {
        return array(
            array('foo', ''),
            array('bat', array('bar', 'foo')),
            array('foo', 'barfaabaz'),
            array('foo', 'faabarbaz'),
        );
    }

    public function providerForNotContainsIdentical()
    {
        return array(
            array('foo', ''),
            array('bat', array('BAT', 'foo')),
            array('bat', array('BaT', 'Batata')),
            array('foo', 'barfaabaz'),
            array('foo', 'barbazFOO'),
            array('foo', 'faabarbaz'),
        );
    }
}
{'fraction_non_alphanumeric': 0.1539301310043668, 'fraction_numerical': 0.005240174672489083, 'mean_word_length': 2.523846153846154, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '7466653', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1308, 'n_words': 272}