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

Fix Infection config builder: make sure it always creates an array for exluded dirs but not object #714

Merged
merged 1 commit into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Config/ValueProvider/ExcludeDirsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static function (string $dir) use ($sourceDirs) {
}
}

return array_unique($excludedDirs);
return array_values(array_unique($excludedDirs));
}

private function getValidator(Locator $locator)
Expand Down
24 changes: 24 additions & 0 deletions tests/Config/ValueProvider/ExcludeDirsProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,30 @@ public function test_passes_when_correct_dir_typed(): void
$this->assertContains('foo', $excludeDirs);
}

public function test_returns_an_array_with_incremented_keys_started_from_zero(): void
{
if (!$this->hasSttyAvailable()) {
$this->markTestSkipped('Stty is not available');
}

$dirA = $this->workspace . \DIRECTORY_SEPARATOR . 'a' . \DIRECTORY_SEPARATOR;
$dirB = $this->workspace . \DIRECTORY_SEPARATOR . 'b' . \DIRECTORY_SEPARATOR;
$dirC = $this->workspace . \DIRECTORY_SEPARATOR . 'c' . \DIRECTORY_SEPARATOR;

\mkdir($dirA);
\mkdir($dirB);
\mkdir($dirC);

$excludeDirs = $this->provider->get(
$this->createStreamableInputInterfaceMock($this->getInputStream("$dirA\n$dirA\n$dirC\n")),
$this->createOutputInterface(),
[$dirA, $dirB, $dirC],
['.']
);

$this->assertSame([0 => $dirA, 1 => $dirC], $excludeDirs);
}

public function excludeDirsProvider()
{
return array_map(
Expand Down