Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lib/guard/phpunit/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -194,4 +197,4 @@ def execute_command(command)
end
end
end
end
end
8 changes: 8 additions & 0 deletions spec/guard/phpunit/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down