<commit_before><?php

/**
 * Class FeatureConfigureByConfigStringTest
 */
class FeatureConfigureByConfigStringTest extends \PHPUnit_Framework_TestCase {


    /**
     * @dataProvider configureByConfigStringProvider
     * @covers DarkGigaByte\Rollout\Feature\FeatureAbstract::configureByConfigString()
     */
    public function testConfigureByConfigStringTest(
        $configString,
        $percentage,
        array $users,
        array $roles,
        array $groups,
        $returnValue
    ) {
        $feature = $this->getMockBuilder('\DarkGigaByte\Rollout\Feature\CoreFeature')
            ->disableOriginalConstructor()
            ->setMethods(array('setPercentage', 'setUsers', 'setRoles', 'setGroups'))
            ->getMock();

        if (true === $returnValue) {
            $feature->expects($this->once())
               ->method('setPercentage')
               ->with($this->equalTo($percentage))
               ->will($this->returnValue($feature));

            $feature->expects($this->once())
               ->method('setUsers')
               ->with($this->equalTo($users))
               ->will($this->returnValue($feature));

            $feature->expects($this->once())
               ->method('setRoles')
               ->with($this->equalTo($roles))
               ->will($this->returnValue($feature));

            $feature->expects($this->once())
               ->method('setGroups')
               ->with($this->equalTo($groups))
               ->will($this->returnValue($feature));
        }

        $this->assertEquals($returnValue, $feature->configureByConfigString($configString));
    }

    /**
     * @return array
     */
    public function configureByConfigStringProvider()
    {
        return array(
            array(
                '100|1,2,3,4|ROLE_ADMIN,ROLE_PREMIUM|caretaker,supporter,staff',
                100,
                array(1,2,3,4),
                array('ROLE_ADMIN','ROLE_PREMIUM'),
                array('caretaker', 'supporter', 'staff'),
                true
            ),
            array(
                '49|1,2,3,4|ROLE_ADMIN,ROLE_PREMIUM|caretaker,supporter,staff',
                49,
                array(1,2,3,4),
                array('ROLE_ADMIN','ROLE_PREMIUM'),
                array('caretaker', 'supporter', 'staff'),
                true<commit_msg>fixed tests to match the refactoring of FeatureAbstract::configureByConfigString<commit_after><?php

/**
 * Class FeatureConfigureByConfigStringTest
 */
class FeatureConfigureByConfigStringTest extends \PHPUnit_Framework_TestCase {


    /**
     * @dataProvider configureByConfigStringProvider
     * @covers DarkGigaByte\Rollout\Feature\FeatureAbstract::configureByConfigString()
     */
    public function testConfigureByConfigStringTest(
        $configString,
        $percentage,
        array $users,
        array $roles,
        array $groups,
        $returnValue
    ) {
        $feature = $this->getMockBuilder('\DarkGigaByte\Rollout\Feature\CoreFeature')
            ->disableOriginalConstructor()
            ->setMethods(array('setPercentage', 'setUsers', 'setRoles', 'setGroups'))
            ->getMock();

        if (true === $returnValue) {
            $feature->expects($this->atLeastOnce())
                ->method('setPercentage')
                ->with($this->logicalOr($this->equalTo(0), $this->equalTo($percentage)))
                ->will($this->returnValue($feature));

            $feature->expects($this->atLeastOnce())
               ->method('setUsers')
               ->with($this->logicalOr($this->equalTo(array()), $this->equalTo($users)))
               ->will($this->returnValue($feature));

            $feature->expects($this->atLeastOnce())
               ->method('setRoles')
               ->with($this->logicalOr($this->equalTo(array()), $this->equalTo($roles)))
               ->will($this->returnValue($feature));

            $feature->expects($this->atLeastOnce())
               ->method('setGroups')
               ->with($this->logicalOr($this->equalTo(array()), $this->equalTo($groups)))
               ->will($this->returnValue($feature));
        }

        $this->assertEquals($returnValue, $feature->configureByConfigString($configString));
    }

    /**
     * @return array
     */
    public function configureByConfigStringProvider()
    {
        return array(
            array(
                '100|1,2,3,4|ROLE_ADMIN,ROLE_PREMIUM|caretaker,supporter,staff',
                100,
                array(1,2,3,4),
                array('ROLE_ADMIN','ROLE_PREMIUM'),
                array('caretaker', 'supporter', 'staff'),
                true
            ),
            array(
                '49|1,2,3,4|ROLE_ADMIN,ROLE_PREMIUM|caretaker,supporter,staff',
                49,
                array(1,2,3,4),
                array('ROLE_ADMIN','ROLE_PREMIUM'),
                array('caretaker', 'supporter', 'staff'),
                true
{'fraction_non_alphanumeric': 0.14973694860380413, 'fraction_numerical': 0.010724403075677864, 'mean_word_length': 2.091307066916823, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 79, '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': '3404933', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1345, 'n_words': 164}