<commit_before><?php

namespace Lstr\Sprintf\Middleware\Cli;

use PHPUnit_Framework_TestCase;

class LongOptsTest extends PHPUnit_Framework_TestCase
{
    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @dataProvider provideNotLongOpts
     * @param string $name
     * @param array $options
     */
    public function testValueRemainsUnchangedIfTypeIsNotLongOpts($name, array $options)
    {
        $long_opts = new LongOpts();
        $values_callback = $this->getValuesCallback();

        $this->assertSame(
            $values_callback($name),
            $long_opts($name, $values_callback, $options)
        );
    }

    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::<private>
     */
    public function testArrayOfOptionsAreConvertedToString()
    {
        $long_opts = new LongOpts();
        $values_callback = $this->getValuesCallback();

        $this->assertSame(
            "--username='light' --host='localhost' --force --name='\"awe'\''some\"'",
            $long_opts("\"awe'some\"", $values_callback, ['type' => 'long-opts'])
        );
    }

    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::<private>
     */
    public function testTypeCanBeImpliedFromName()
    {
        $long_opts = new LongOpts();
        $values_callback = $this->getValuesCallback();

        $this->assertSame(
            "--username='light' --host='localhost' --force --name='long-opts'",
            $long_opts("long-opts", $values_callback, [])
        );
    }

    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::<private>
     */
    public function testStringIsUsedAsValue()
    {
        $long_opts = new LongOpts();
        $values_callback = $this->getValuesCallback();<commit_msg>Remove unused variable in long option test<commit_after><?php

namespace Lstr\Sprintf\Middleware\Cli;

use PHPUnit_Framework_TestCase;

class LongOptsTest extends PHPUnit_Framework_TestCase
{
    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @dataProvider provideNotLongOpts
     * @param string $name
     * @param array $options
     */
    public function testValueRemainsUnchangedIfTypeIsNotLongOpts($name, array $options)
    {
        $long_opts = new LongOpts();
        $values_callback = $this->getValuesCallback();

        $this->assertSame(
            $values_callback($name),
            $long_opts($name, $values_callback, $options)
        );
    }

    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::<private>
     */
    public function testArrayOfOptionsAreConvertedToString()
    {
        $long_opts = new LongOpts();
        $values_callback = $this->getValuesCallback();

        $this->assertSame(
            "--username='light' --host='localhost' --force --name='\"awe'\''some\"'",
            $long_opts("\"awe'some\"", $values_callback, ['type' => 'long-opts'])
        );
    }

    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::<private>
     */
    public function testTypeCanBeImpliedFromName()
    {
        $long_opts = new LongOpts();
        $values_callback = $this->getValuesCallback();

        $this->assertSame(
            "--username='light' --host='localhost' --force --name='long-opts'",
            $long_opts("long-opts", $values_callback, [])
        );
    }

    /**
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::process
     * @covers Lstr\Sprintf\Middleware\Cli\LongOpts::<private>
     */
    public function testStringIsUsedAsValue()
    {
        $long_opts = new LongOpts();
{'fraction_non_alphanumeric': 0.14590932777488275, 'fraction_numerical': 0.0, 'mean_word_length': 2.7308066083576286, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 24, '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': '5383869', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1178, 'n_words': 175}