Skip to content

Instantly share code, notes, and snippets.

@mfrost503
Last active December 9, 2015 15:07
Show Gist options
  • Save mfrost503/2e77ac9bd8cfd651b050 to your computer and use it in GitHub Desktop.
Save mfrost503/2e77ac9bd8cfd651b050 to your computer and use it in GitHub Desktop.
Vim Script to run PHPUnit tests from the editor and display the results in the message bar
let g:test_directory = "tests"
function DirectoryExists(...)
if empty(a:1)
return 0
endif
let a:directory = system("if [ ! -d " . a:1 . " ]; then echo 0; else echo 1; fi")
return a:directory
endfunction
function PHPUnit()
let a:exists = DirectoryExists(g:test_directory)
if a:exists == 0
echom "You are not in the proper directory to run your tests"
return 0
endif
let a:tests = system("phpunit | grep \\(.*tests,.*\\)")
if a:tests == ""
echom "No tests to run are you in the right directory"
else
echom "PHPUnit Results: " . a:tests
return 1
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment