Last active
December 9, 2015 15:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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