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

Add FakeRunner which will be emulate running command #21

Merged
merged 8 commits into from
Feb 4, 2017

Conversation

Bukharovsi
Copy link
Contributor

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

Bukharov added 3 commits January 30, 2017 12:21
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 Bukharovsi changed the title issue #20 https://github.com/adambrett/php-shell-wrapper/issues/20 Add FakeRunner whic will be emulate running command Jan 30, 2017
@Bukharovsi Bukharovsi changed the title Add FakeRunner whic will be emulate running command Add FakeRunner which will be emulate running command Jan 30, 2017
@adambrett
Copy link
Owner

@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

@Bukharovsi
Copy link
Contributor Author

@adambrett thanks for response! Could you please explain what do you want to improve? i will fix it.

Copy link
Owner

@adambrett adambrett left a 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'));
Copy link
Owner

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?

use AdamBrett\ShellWrapper\Command\CommandInterface;
use AdamBrett\ShellWrapper\Runners\FakeRunner;

class EchoFakeRunner extends FakeRunner
Copy link
Owner

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

@Bukharovsi
Copy link
Contributor Author

Thank you for feedback. I will fix it soon!

Bukharov added 2 commits February 1, 2017 00:06
Dockblocks has been removed
Auto-generated dockblocks has been removed
test for command printing in DryRunnerTest has been added
add \r\n for DryRunner
@Bukharovsi
Copy link
Contributor Author

I have fixed problems. Please pay attention with README. I could make some mistakes.

Copy link
Owner

@adambrett adambrett left a 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!

{
public function run(CommandInterface $command)
{
echo $command."\r\n";
Copy link
Owner

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');
Copy link
Owner

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
/**
Copy link
Owner

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.
Copy link
Owner

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
Copy link
Owner

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."

@Bukharovsi
Copy link
Contributor Author

Thanks for response! I have fixed this!

Copy link
Owner

@adambrett adambrett left a 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');
Copy link
Owner

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');

{
public function run(CommandInterface $command)
{
echo $command.PHP_EOL;
Copy link
Owner

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;

@Bukharovsi
Copy link
Contributor Author

done!

thanks!

@adambrett adambrett merged commit 16aced8 into adambrett:master Feb 4, 2017
@Bukharovsi
Copy link
Contributor Author

Excellent! thanks!

@Bukharovsi Bukharovsi deleted the fake_wrapper branch February 4, 2017 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants