From 619de7e272d5e2c7a1f0fb532a4b6e86edf46fee Mon Sep 17 00:00:00 2001 From: Wtyd Date: Mon, 17 Apr 2023 17:00:57 +0000 Subject: [PATCH] fix (conf:check) Default options are displayed correctly --- .../OptionsConfiguration.php | 2 +- .../CheckConfigurationFileCommandTest.php | 31 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/ConfigurationFile/OptionsConfiguration.php b/src/ConfigurationFile/OptionsConfiguration.php index 216596e..589a316 100644 --- a/src/ConfigurationFile/OptionsConfiguration.php +++ b/src/ConfigurationFile/OptionsConfiguration.php @@ -160,7 +160,7 @@ public function getProcesses(): int public function isDefaultProcesses(): bool { - return $this->defaultExecution; + return $this->defaultProcesses; } public function getExecution(): string diff --git a/tests/System/Commands/CheckConfigurationFileCommandTest.php b/tests/System/Commands/CheckConfigurationFileCommandTest.php index b6a113e..256db36 100644 --- a/tests/System/Commands/CheckConfigurationFileCommandTest.php +++ b/tests/System/Commands/CheckConfigurationFileCommandTest.php @@ -3,7 +3,6 @@ namespace Tests\System\Commands; use Tests\Utils\TestCase\SystemTestCase; -use Wtyd\GitHooks\ConfigurationFile\FileReader; class CheckConfigurationFileCommandTest extends SystemTestCase { @@ -27,20 +26,40 @@ function it_passes_all_file_configuration_checks() ->expectsOutput('The file githooks.yml has the correct format.'); } - /** @test */ - function it_shows_default_options_when_not_set() + public function optionsDataProvider() { - $this->configurationFileBuilder->doNotSetOptions(); + return [ + 'Optins is empty' => [ + 'Options' => [], + 'Table Values' => [['execution', 'full (default)'], ['processes', '1 (default)']] + ], + 'Only execution is setted' => [ + 'Options' => ['execution' => 'fast'], + 'Table Values' => [['execution', 'fast'], ['processes', '1 (default)']] + ], + 'Only processes is setted' => [ + 'Options' => ['processes' => 3], + 'Table Values' => [['execution', 'full (default)'], ['processes', '3']] + ], + ]; + } + + /** + * @test + * @dataProvider optionsDataProvider + */ + function it_shows_default_options_when_not_are_setted($options, $tableValues) + { + $this->configurationFileBuilder->setOptions($options); $this->configurationFileBuilder->buildInFileSystem(); $this->artisan('conf:check') ->assertExitCode(0) - ->expectsTable(['Options', 'Values'], [['execution', 'full (default)'], ['processes', '1 (default)']]) + ->expectsTable(['Options', 'Values'], $tableValues) // ->expectsTable(['Tools', 'Commands'], [ // ['phpcs', 'tools/php71/phpcs ./ --standard=./qa/psr12-ruleset.xml --ignore=vendor,tools --error-severity=1 --warning-severity=6 --report=summary --parallel=2'], // ['phpstan', 'vendor/bin/phpstan analyse -c ./qa/phpstan.neon --no-progress --ansi src'], - // ->containsStringInOutput("The tag 'Options' is empty") ->expectsOutput('The file githooks.yml has the correct format.'); }