Fork me on GitHub

Vim-Php The intersection between two beautiful communities


Welcome vim-relatedtest

15 Aug 2015 - Tags: php,vim,test - Author: GianArb


This plugin opens a related test file of a given source file (and viceversa).

When you are editing a source file, eg: App.php and you want to open the test file you have to issue tt and the AppTest.php will be opened from your tests folder. If the test file is missing you can create it on the fly.

Install

Bundle 'wdalmut/vim-relatedtest'

Shortcut

You can redefine shortcuts

let g:relatedtest_open_command = '<C-t>'

PHP Filetype configuration

Sometimes you need to set up where sources and tests folders are located, for doing that you can set in your .exrc file for your project.

For example for Symfony2 application you can limit the search operation in your src folder only…

let g:relatedtest_php_src="src/"
let g:relatedtest_php_tests="src/"

In order to exclude always a particular folder like: vendor you can use wildignore flag directly in your .vimrc configuration file.

:set wildignore+=**/vendor/**

Open Strategy

The open strategy comes in help when you want to open the related test in a new window, split, tab etc..

let g:relatedtest_open_strategy = 'vsp'

You can use any vim command as open strategy, the most common are:

  • vsp (open in a vertical split)
  • sp (open in an horizontal split)
  • tabnew (open in a tab)
  • e (open in the current window)

Thanks Walter Dal Mut for your work!