Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config: add tests for the --generator= argument #765

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions tests/Core/Config/GeneratorArgTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Tests for the \PHP_CodeSniffer\Config --generator argument.
*
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
rodrigoprimo marked this conversation as resolved.
Show resolved Hide resolved
*/

namespace PHP_CodeSniffer\Tests\Core\Config;

use PHP_CodeSniffer\Tests\ConfigDouble;
use PHPUnit\Framework\TestCase;

/**
* Tests for the \PHP_CodeSniffer\Config --generator argument.
*
* @covers \PHP_CodeSniffer\Config::processLongArgument
*/
final class GeneratorArgTest extends TestCase
{


/**
* Ensure that the generator property is set when the parameter is passed.
rodrigoprimo marked this conversation as resolved.
Show resolved Hide resolved
*
* @param string $generatorName Generator name.
*
* @return void
* @dataProvider dataGeneratorNames
*/
public function testGenerators($generatorName)
{
$config = new ConfigDouble(["--generator=$generatorName"]);

$this->assertSame($generatorName, $config->generator);

}//end testGenerators()


/**
* Data provider for testGenerators().
*
* @return array<int, array<string>>
* @see self::testGenerators()
*/
public static function dataGeneratorNames()
{
return [
['Text'],
['HTML'],
['Markdown'],
];

}//end dataGeneratorNames()


/**
* Ensure that only the first argument is processed and others are ignored.
*
* @return void
*/
public function testOnlySetOnce()
{
$config = new ConfigDouble(
[
"--generator=Text",
"--generator=HTML",
"--generator=InvalidGenerator",
rodrigoprimo marked this conversation as resolved.
Show resolved Hide resolved
]
);

$this->assertSame('Text', $config->generator);

}//end testOnlySetOnce()


}//end class
Loading