-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvim-phpunit.vim
More file actions
78 lines (68 loc) · 2.16 KB
/
vim-phpunit.vim
File metadata and controls
78 lines (68 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
" ------------------------------------------------------------------------------
" Vim PHPUnit {{{
"
" Author: Walter Dal Mut <walter.dalmut@gmail.com>
"
" Description:
" Run PHPUnit from within Vim. This plugin is based on the joonty's
" vim-phpunitqf but i have removed the quickfix because i don't want to use it.
"
" Requires: Vim 6.0 or newer
"
" Install:
" Put this file and the python file in the vim plugins directory (~/.vim/plugin)
" to load it automatically, or load it manually with :so sauce.vim.
"
" License: MIT
"
" }}}
" ------------------------------------------------------------------------------
" PHPUnit command
if !exists("g:phpunit_cmd")
if filereadable('./bin/phpunit')
let g:phpunit_cmd='./bin/phpunit'
elseif filereadable('./vendor/bin/phpunit')
let g:phpunit_cmd='./vendor/bin/phpunit'
else
let g:phpunit_cmd='phpunit'
endif
endif
" Static arguments passed to the PHPUnit command
if !exists("g:phpunit_args")
let g:phpunit_args=''
endif
" Static arguments passed to the PHPUnit command after the dynamic argument
if !exists("g:phpunit_args_append")
let g:phpunit_args_append=''
endif
" Location of temporary error log
if !exists("g:phpunit_tmpfile")
let g:phpunit_tmpfile="/tmp/vim_phpunit.out"
endif
" Debug enabled
if !exists("g:phpunit_debug")
let g:phpunit_debug=0
endif
" Handle the quickfix feature
if !exists("g:phpunit_quickfix")
let g:phpunit_quickfix=1
endif
if !exists("g:phpunit_callback")
let g:phpunit_callback = ""
endif
command! -nargs=* Test call s:RunPHPUnitTests(<q-args>)
command! TestOutput call s:OpenPHPUnitOutput()
" Run PHPUnit command and python parser
function! s:RunPHPUnitTests(arg)
let s:args = a:arg
if len(g:phpunit_callback) > 0
exe "let s:args = ".g:phpunit_callback."('".s:args."')"
endif
" Truncate current log file
call system("> ".g:phpunit_tmpfile)
exe "!".g:phpunit_cmd." ".g:phpunit_args." ".s:args." ".g:phpunit_args_append." 2>&1 | tee ".g:phpunit_tmpfile
endfunction
" Open the test output
function! s:OpenPHPUnitOutput()
exe "sp ".g:phpunit_tmpfile
endfunction