<commit_before><?php
use GetOptionKit\Option;

class OptionTest extends PHPUnit_Framework_TestCase
{


    public function optionSpecDataProvider() {
        return [
            ['i'],
            ['f'],
            ['a=number'],

            // long options
            ['n|name'],
            ['e|email'],
        ];
    }


    /**
     * @dataProvider optionSpecDataProvider
     */
    public function testOptionSpec($spec)
    {
        $opt = new Option($spec);
        ok($opt);
    }

    /**
     * @expectedException Exception
     */
    public function testInvalidOptionSpec()
    {
        new Option('....');
    }


    public function testDefaultValue()
    {
        $opt = new Option('z');
        $opt->defaultValue(10);
        $this->assertEquals(10, $opt->getValue());
        $this->assertEquals('-z[=10]',$opt->renderReadableSpec(true));
    }

    public function testBackwardCompatibleBoolean()
    {
        $opt = new Option('scope');
        $opt->isa('bool');
        $this->assertEquals('boolean', $opt->isa);
        $this->assertEquals('--scope=<boolean>',$opt->renderReadableSpec(true));
    }



    public function validatorProvider()
    {
        return [
            [function($a) { return in_array($a, ['public', 'private']); }],
            [function($a) { return [in_array($a, ['public', 'private']), "message"]; }]
        ];
    }

    /**
     * @dataProvider validatorProvider<commit_msg>Add test case for valueName<commit_after><?php
use GetOptionKit\Option;

class OptionTest extends PHPUnit_Framework_TestCase
{


    public function optionSpecDataProvider() {
        return [
            ['i'],
            ['f'],
            ['a=number'],

            // long options
            ['n|name'],
            ['e|email'],
        ];
    }


    /**
     * @dataProvider optionSpecDataProvider
     */
    public function testOptionSpec($spec)
    {
        $opt = new Option($spec);
        ok($opt);
    }

    /**
     * @expectedException Exception
     */
    public function testInvalidOptionSpec()
    {
        new Option('....');
    }

    public function testValueName()
    {
        $opt = new Option('z');
        $opt->defaultValue(10);
        $opt->valueName('priority');
        $this->assertEquals('[=priority]', $opt->renderValueHint());
        $this->assertEquals('-z[=priority]', $opt->renderReadableSpec());
    }


    public function testDefaultValue()
    {
        $opt = new Option('z');
        $opt->defaultValue(10);
        $this->assertEquals(10, $opt->getValue());
        $this->assertEquals('-z[=10]',$opt->renderReadableSpec(true));
    }

    public function testBackwardCompatibleBoolean()
    {
        $opt = new Option('scope');
        $opt->isa('bool');
        $this->assertEquals('boolean', $opt->isa);
        $this->assertEquals('--scope=<boolean>',$opt->renderReadableSpec(true));
    }



    public function validatorProvider()
    {
        return [
            [function($a) { return in_array($a, ['public', 'private']); }],
            [function($a) { return [in_array($a, ['public', 'private']), "message"]; }]
        ];
    }

    /**
     * @dataProvider validatorProvider
{'fraction_non_alphanumeric': 0.1698647373387858, 'fraction_numerical': 0.004403900597672224, 'mean_word_length': 2.1610337972167, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, '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': '3059137', 'n_tokens_mistral': 923, 'n_tokens_neox': 892, 'n_words': 157}