Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 61bf093

Browse filesBrowse files
committed
Add test with vader
1 parent 5804b8b commit 61bf093
Copy full SHA for 61bf093

File tree

4 files changed

+91
-0
lines changed
Filter options

4 files changed

+91
-0
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,12 @@ class Foo {
381381
`<Leader>da` will call your documentation plugin (by default Php Documentor for vim https://github.com/tobyS/pdv) for every uncommented classes, methods, functions and properties.
382382

383383

384+
## Running tests
385+
386+
```
387+
bin/test
388+
```
389+
390+
### How to write tests?
391+
392+
See https://github.com/junegunn/vader.vim

‎bin/test

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! /bin/sh -eu
2+
3+
test -d vendor/vader.vim || {
4+
git clone --depth=1 https://github.com/junegunn/vader.vim.git vendor/vader.vim
5+
}
6+
7+
vim -esNu test/fixtures/vimrc -c 'Vader! test/*'

‎test/extract_variable.vader

Copy file name to clipboard
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Given php (condition on if):
2+
<?php
3+
4+
$sentence = 'Hello';
5+
6+
if ('foo' === $firstName) {
7+
$sentence .= ' ' . $firstName;
8+
}
9+
10+
Do (select the condition and extract variable):
11+
/foo\<CR>
12+
vi(
13+
;ev
14+
firstNameIsValid\<CR>
15+
16+
Expect php (variable is extracted):
17+
<?php
18+
19+
$sentence = 'Hello';
20+
21+
$firstNameIsValid = 'foo' === $firstName;
22+
23+
if ($firstNameIsValid) {
24+
$sentence .= ' ' . $firstName;
25+
}
26+
27+
Given php (condition on if and on function):
28+
<?php
29+
30+
function prepareSentence()
31+
{
32+
$sentence = 'Hello';
33+
34+
if ('foo' === $firstName) {
35+
$sentence .= ' ' . $firstName;
36+
}
37+
38+
return $sentence;
39+
}
40+
41+
Do (select the condition and extract variable):
42+
/foo\<CR>
43+
vi(
44+
;ev
45+
firstNameIsValid\<CR>
46+
47+
Expect php (variable is extracted):
48+
<?php
49+
50+
function prepareSentence()
51+
{
52+
$sentence = 'Hello';
53+
54+
$firstNameIsValid = 'foo' === $firstName;
55+
56+
if ($firstNameIsValid) {
57+
$sentence .= ' ' . $firstName;
58+
}
59+
60+
return $sentence;
61+
}

‎test/fixtures/vimrc

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
" Setup a testing environment that is isolated from the other plugins.
2+
"
3+
filetype off
4+
5+
set rtp+=vendor/vader.vim
6+
set rtp+=.
7+
set rtp+=after
8+
9+
filetype plugin on
10+
filetype indent on
11+
12+
syntax enable
13+
14+
let mapleader = ";"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.