ale/test/fixers/test_php_cs_fixer.vader

67 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2018-03-01 14:41:05 +00:00
Before:
Save g:ale_php_cs_fixer_executable
Save g:ale_php_cs_fixer_options
Save g:ale_php_cs_fixer_fix_options
2018-03-01 14:41:05 +00:00
let g:ale_php_cs_fixer_executable = 'php-cs-fixer'
let g:ale_php_cs_fixer_options = ''
let g:ale_php_cs_fixer_fix_options = ''
2018-03-01 14:41:05 +00:00
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(project with php-cs-fixer should use local by default):
call ale#test#SetFilename('../test-files/php/project-with-php-cs-fixer/test.php')
2018-03-01 14:41:05 +00:00
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/php/project-with-php-cs-fixer/vendor/bin/php-cs-fixer'),
2018-03-01 14:41:05 +00:00
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
Execute(use-global should override local detection):
let g:ale_php_cs_fixer_use_global = 1
call ale#test#SetFilename('../test-files/php/project-with-php-cs-fixer/test.php')
2018-03-01 14:41:05 +00:00
AssertEqual
\ 'php-cs-fixer',
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
Execute(project without php-cs-fixer should use global):
call ale#test#SetFilename('../test-files/php/project-without-php-cs-fixer/test.php')
2018-03-01 14:41:05 +00:00
AssertEqual
\ 'php-cs-fixer',
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
Execute(The php-cs-fixer callback should return the correct default values):
call ale#test#SetFilename('../test-files/php/project-without-php-cs-fixer/foo/test.php')
2018-03-01 14:41:05 +00:00
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('php-cs-fixer')
\ . ' ' . g:ale_php_cs_fixer_options
\ . ' fix ' . g:ale_php_cs_fixer_fix_options
\ . ' %t'
\ },
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))
Execute(The php-cs-fixer callback should include custom php-cs-fixer options):
let g:ale_php_cs_fixer_options = '-nq'
let g:ale_php_cs_fixer_fix_options = '--config="$HOME/.php_cs"'
call ale#test#SetFilename('../test-files/php/project-without-php-cs-fixer/test.php')
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_php_cs_fixer_executable)
\ . ' -nq fix --config="$HOME/.php_cs" %t',
\ 'read_temporary_file': 1,
\ },
2018-03-01 14:41:05 +00:00
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))