Skip to content

Commit

Permalink
fix (conf:check) Default options are displayed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Wtyd committed Apr 17, 2023
1 parent 94f6bcd commit 619de7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ConfigurationFile/OptionsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function getProcesses(): int

public function isDefaultProcesses(): bool
{
return $this->defaultExecution;
return $this->defaultProcesses;
}

public function getExecution(): string
Expand Down
31 changes: 25 additions & 6 deletions tests/System/Commands/CheckConfigurationFileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Tests\System\Commands;

use Tests\Utils\TestCase\SystemTestCase;
use Wtyd\GitHooks\ConfigurationFile\FileReader;

class CheckConfigurationFileCommandTest extends SystemTestCase
{
Expand All @@ -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.');
}

Expand Down

0 comments on commit 619de7e

Please sign in to comment.