-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure stdout is valid XML for junit format (#129)
- Loading branch information
Showing
9 changed files
with
148 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace ShipMonk\ComposerDependencyAnalyser; | ||
|
||
use Closure; | ||
use PHPUnit\Framework\TestCase; | ||
use ShipMonk\ComposerDependencyAnalyser\Result\ResultFormatter; | ||
use function fopen; | ||
use function preg_replace; | ||
use function str_replace; | ||
use function stream_get_contents; | ||
|
||
abstract class FormatterTest extends TestCase | ||
{ | ||
|
||
abstract protected function createFormatter(Printer $printer): ResultFormatter; | ||
|
||
/** | ||
* @param Closure(ResultFormatter): void $closure | ||
*/ | ||
protected function getFormatterNormalizedOutput(Closure $closure): string | ||
{ | ||
$stream = fopen('php://memory', 'w'); | ||
self::assertNotFalse($stream); | ||
|
||
$printer = new Printer($stream); | ||
$formatter = $this->createFormatter($printer); | ||
|
||
$closure($formatter); | ||
return $this->normalizeEol((string) stream_get_contents($stream, -1, 0)); | ||
} | ||
|
||
protected function normalizeEol(string $string): string | ||
{ | ||
return str_replace("\r\n", "\n", $string); | ||
} | ||
|
||
protected function removeColors(string $output): string | ||
{ | ||
return (string) preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $output); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.