From d5c28634dd325198223cf35975e1c9a84a93093b Mon Sep 17 00:00:00 2001 From: James Carr Date: Fri, 2 Nov 2012 09:19:09 -0500 Subject: [PATCH] give them an option to specify the command to run phpunit with! --- README.md | 4 ++++ lib/guard/phpunit/runner.rb | 7 +++++-- spec/guard/phpunit/runner_spec.rb | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 98dd3ca..174fecf 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,10 @@ The following options can be passed to Guard::PHPUnit: :cli => '--colors' # The options passed to the phpunit command # when running the tests. # default: nil + +:command => "./bin/phpunit" # specify alternative phpunit location + # that is not on the path. + # Useful if running phpunit from composer ``` Development diff --git a/lib/guard/phpunit/runner.rb b/lib/guard/phpunit/runner.rb index fa3e617..f5f86d1 100644 --- a/lib/guard/phpunit/runner.rb +++ b/lib/guard/phpunit/runner.rb @@ -172,9 +172,12 @@ def symlink_paths_to_tests_folder(paths, folder) # def phpunit_command(path, options) formatter_path = File.join( File.dirname(__FILE__), 'formatters', 'PHPUnit-Progress') + + command = "phpunit" + command = options[:command] if options[:command] cmd_parts = [] - cmd_parts << "phpunit" + cmd_parts << command cmd_parts << "--include-path #{formatter_path}" cmd_parts << "--printer PHPUnit_Extensions_Progress_ResultPrinter" cmd_parts << options[:cli] if options[:cli] @@ -194,4 +197,4 @@ def execute_command(command) end end end -end \ No newline at end of file +end diff --git a/spec/guard/phpunit/runner_spec.rb b/spec/guard/phpunit/runner_spec.rb index ed5c6db..a5b6e08 100644 --- a/spec/guard/phpunit/runner_spec.rb +++ b/spec/guard/phpunit/runner_spec.rb @@ -50,6 +50,14 @@ subject.run( ['tests'] ) end + it 'runs phpunit tests with provided command' do + formatter_path = @project_path.join('lib', 'guard', 'phpunit', 'formatters', 'PHPUnit-Progress') + subject.should_receive(:execute_command).with( + %r{^/usr/local/bin/phpunit --include-path #{formatter_path} --printer PHPUnit_Extensions_Progress_ResultPrinter .+$} + ).and_return(true) + subject.run( ['tests'] , {:command => '/usr/local/bin/phpunit'} ) + end + it 'prints the tests output to the console' do output = load_phpunit_output('passing') subject.stub(:notify_start)