Sha256: 0f9daa0633c27982ddcb822b7b00d1213a164d84c360bf849d4fd26b8860e5a5

Contents?: true

Size: 1.78 KB

Versions: 18

Compression:

Stored size: 1.78 KB

Contents

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Console\Tests\Question;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Question\ConfirmationQuestion;

class ConfirmationQuestionTest extends TestCase
{
    /**
     * @dataProvider normalizerUsecases
     */
    public function testDefaultRegexUsecases($default, $answers, $expected, $message)
    {
        $sut = new ConfirmationQuestion('A question', $default);

        foreach ($answers as $answer) {
            $normalizer = $sut->getNormalizer();
            $actual = $normalizer($answer);
            $this->assertEquals($expected, $actual, sprintf($message, $answer));
        }
    }

    public function normalizerUsecases()
    {
        return [
            [
                true,
                ['y', 'Y', 'yes', 'YES', 'yEs', ''],
                true,
                'When default is true, the normalizer must return true for "%s"',
            ],
            [
                true,
                ['n', 'N', 'no', 'NO', 'nO', 'foo', '1', '0'],
                false,
                'When default is true, the normalizer must return false for "%s"',
            ],
            [
                false,
                ['y', 'Y', 'yes', 'YES', 'yEs'],
                true,
                'When default is false, the normalizer must return true for "%s"',
            ],
            [
                false,
                ['n', 'N', 'no', 'NO', 'nO', 'foo', '1', '0', ''],
                false,
                'When default is false, the normalizer must return false for "%s"',
            ],
        ];
    }
}

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dependabot-composer-0.119.0.beta1 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.113.19 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.112.1 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.111.57 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.111.56 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.111.52 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.111.50 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.111.25 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.111.17 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.111.15 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.110.13 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.108.11 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.108.8 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.107.47 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.107.39 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.107.36 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.107.28 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php
dependabot-composer-0.107.14 helpers/vendor/symfony/console/Tests/Question/ConfirmationQuestionTest.php