robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
6a61c81e31
master
1" Tests for the PHP omni-completion plugin (runtime/autoload/phpcomplete.vim). 2 3" A buffer class name is interpolated into a search() pattern run via 4" win_execute(). Without escaping, "'" closes the string and "|" starts a new 5" Ex command, so the name runs as an Ex command during completion. 6func Test_phpcomplete_no_exec_via_class_name () 7unlet ! g: phpcomplete_injected 8let lines = [ '<?php' , 'class x {}' , '' ] 9let payload = "x')|let g:phpcomplete_injected = 1|call search('" 10 11try 12call phpcomplete#GetClassContentsStructure ( 'x.php' , lines , payload ) 13catch 14endtry 15 16call assert_false ( exists ( 'g:phpcomplete_injected' ), 17 \'class name was executed as an Ex command during completion' ) 18 19unlet ! g: phpcomplete_injected 20endfunc 21 22func Test_phpcomplete_class_lookup_still_works () 23let lines = [ '<?php' , 'class Foo {' , ' public $bar;' , '}' , '' ] 24let result = phpcomplete#GetClassContentsStructure ( 'Foo.php' , lines , 'Foo' ) 25 26call assert_equal ( type ([]), type ( result ), 27 \'GetClassContentsStructure did not return a list' ) 28call assert_true ( len ( result ) > 0 , 'no class structure returned' ) 29call assert_match ( 'class Foo' , result [ 0 ]. content , 30 \'class body missing from returned content' ) 31call assert_match ( 'bar' , result [ 0 ]. content , 32 \'class member missing from returned content' ) 33endfunc 34 35" vim: shiftwidth=2 sts=2 expandtab