-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Revamp the CommandTester #219
base: main
Are you sure you want to change the base?
Conversation
use Closure; | ||
use Symfony\Component\Console\Formatter\OutputFormatterInterface; | ||
|
||
final class DefaultFormatterFactory implements OutputFormatterFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review separately how to configure the formatter; review how it is possible in the tests (currently) or document the limitation
$this->outputs = $outputs; | ||
} | ||
|
||
private function doWrite(string $message, bool $newline): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to remove (dead code)
* @psalm-suppress PropertyNotSetInConstructor | ||
*/ | ||
final class CommandTester extends SymfonyCommandTester | ||
class CommandTester |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to review if final
is desired or not
private BaseSymfonyCommand $command, | ||
// See Symfony's Output::__construct() | ||
// We use the same default values. | ||
private array $inputs = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test to ensure the defaults are the same as the Symfony's ones
* | ||
* @param bool $normalize Whether to normalize end of lines to \n or not. | ||
*/ | ||
public function getDisplay(bool $normalize = false): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
part of the proposal, rather than going with display
and error display
like done in ZendStruck's ConsoleTest, I choose:
- display: stdout + stderr
- output: stdout
- error output: stderr
(stdout and stderr are the "defaults", as technically you could configure different outputs).
return $this; | ||
} | ||
|
||
public function dump(): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to properly integrate it I just copy/pasted ZendStruck ConsoleTest's API
also add the licensing
|
||
private static function createOutput(OutputInterface $config): StreamOutput | ||
{ | ||
$stream = fopen('php://memory', 'wb'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to double check if b
is desired or not and double check on Symfony's side too
* | ||
* @param bool $normalize Whether to normalize end of lines to \n or not. | ||
*/ | ||
public function getDisplay(bool $normalize = false): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want more normalization options like it was previously offered (with $extraNormalizers
) and/or leverage the DisplayNormalizer
* | ||
* @param bool $normalize Whether to normalize end of lines to \n or not. | ||
*/ | ||
public function getOutput(bool $normalize = false): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function getOutput(bool $normalize = false): string | |
public function getStandardOutput(bool $normalize = false): string |
?
use function rewind; | ||
use function stream_get_contents; | ||
|
||
final class TestOutput implements ConsoleOutputInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably should be @internal
Related to #217 and #192.