-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add FakeRunner which will be emulate running command #21
Conversation
I suggest add FakeRunner which will be emulate running the command. It must be used in unit and integration tests. Also i suggest add EchoFakeRunner which will be not execute command but prints the command. It will be used when application runs with --dry-run argument
fix EchoFakeRunner namespace. add tests
@Bukharovsi thanks a lot for this; I think it will be a really useful addition to the library so I'm keen to get it merged. At first glance, there's a couple of things I'd like to tidy up before it's merged. When I get some time later I'll go through and add some comments! Thanks |
@adambrett thanks for response! Could you please explain what do you want to improve? i will fix it. |
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.
@Bukharovsi I've added a couple of comments, it's mostly ok.
The only other thing I would like to see is the removal of the docblocks and phpstorm generated file blocks. I don't use them anywhere else in the library and think the code should be self-explanitory enough.
The last thing is that the functionality needs documenting in the relevant places in the README and then we're good to go.
Thanks
public function testRun() | ||
{ | ||
$runner = new EchoFakeRunner(); | ||
$runner->run(new Command('ls')); |
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.
could you wrap this in ob_start
and ob_get_clean
to test that the output matches the expected value?
src/Runners/EchoFakeRunner.php
Outdated
use AdamBrett\ShellWrapper\Command\CommandInterface; | ||
use AdamBrett\ShellWrapper\Runners\FakeRunner; | ||
|
||
class EchoFakeRunner extends FakeRunner |
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.
I think this should just be called DryRunner
. I don't think that it matters that it extends/is Fake
Thank you for feedback. I will fix it soon! |
Dockblocks has been removed Auto-generated dockblocks has been removed test for command printing in DryRunnerTest has been added add \r\n for DryRunner
I have fixed problems. Please pay attention with README. I could make some mistakes. |
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.
Looking good, just a couple of minor fixes I missed the first time around and we can get this merged!
src/Runners/DryRunner.php
Outdated
{ | ||
public function run(CommandInterface $command) | ||
{ | ||
echo $command."\r\n"; |
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.
I didn't spot this first time around, could you replace this with the line ending constant PHP_EOL
and put spaces around the dot?
$runner = new DryRunner(); | ||
ob_start(); | ||
$runner->run(new Command('ls')); | ||
static::assertEquals("ls\r\n", ob_get_clean(), 'This runner must print command'); |
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.
should probably be PHP_EOL
here too
@@ -0,0 +1,41 @@ | |||
<?php | |||
/** |
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.
Missed this docblock
README.md
Outdated
Dry* | Exit code | | x | x | ||
Fake* | Exit code | | x | x | ||
|
||
Use `FakeRunner` into unit tests for emulate command running. |
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.
How about:
"You can use FakeRunner
in your unit tests to emulate running a command."
README.md
Outdated
Fake* | Exit code | | x | x | ||
|
||
Use `FakeRunner` into unit tests for emulate command running. | ||
Use `DryRunner` when your application gets --dry-run argument and there is need to only print the command |
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.
And:
"You can use DryRunner
for debugging purposes, or when your application uses a --dry-run
type argument and you want to echo the command rather than run it."
Thanks for response! I have fixed this! |
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.
Awesome, thanks. I think you missed a couple of comments though. I just commented again to show what I mean. Once those two bits are sorted I'll get this merged!
Thanks
$runner = new DryRunner(); | ||
ob_start(); | ||
$runner->run(new Command('ls')); | ||
static::assertEquals("ls".PHP_EOL, ob_get_clean(), 'This runner must print command'); |
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.
this should be single quotes and there should be a space around the .
static::assertEquals('ls' . PHP_EOL, ob_get_clean(), 'This runner must print command');
src/Runners/DryRunner.php
Outdated
{ | ||
public function run(CommandInterface $command) | ||
{ | ||
echo $command.PHP_EOL; |
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.
There should be a space around the .
here
echo $command . PHP_EOL;
done! thanks! |
Excellent! thanks! |
I suggest add FakeRunner which will be emulate running the command.
It must be used in unit and integration tests.
Also i suggest add EchoFakeRunner which will be not execute command but prints the command. It will be used when application runs with --dry-run argument