Skip to content

Commit

Permalink
Merge pull request #469 from xabbuh/pr-468
Browse files Browse the repository at this point in the history
clean up the temp file even when the test fails
  • Loading branch information
Simon Mönch authored Jan 29, 2021
2 parents 5631b2a + 2857be4 commit 699760c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions tests/OutputFormatter/BaselineOutputFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,24 @@ public function basicDataProvider(): iterable
public function testBasic(array $rules, string $expectedOutput): void
{
$generatedBaselineFile = tempnam(sys_get_temp_dir(), 'deptrac_');
$output = new BufferedOutput();

$formatter = new BaselineOutputFormatter();
$formatter->finish(
new Context($rules, []),
$this->createSymfonyOutput($output),
new OutputFormatterInput(['baseline-dump' => $generatedBaselineFile])
);

static::assertEquals(
$expectedOutput,
file_get_contents($generatedBaselineFile)
);
unlink($generatedBaselineFile);
try {
$output = new BufferedOutput();

$formatter = new BaselineOutputFormatter();
$formatter->finish(
new Context($rules, []),
$this->createSymfonyOutput($output),
new OutputFormatterInput(['baseline-dump' => $generatedBaselineFile])
);

static::assertEquals(
$expectedOutput,
file_get_contents($generatedBaselineFile)
);
} finally {
unlink($generatedBaselineFile);
}
}

public function testGetOptions(): void
Expand Down

0 comments on commit 699760c

Please sign in to comment.