aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/UltiSnips/php-phpspec.snippets
blob: 08d84a05326e0e13b49771e2ad736f11f077e0ef (plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Snippets for phpspec, to use add the following to your .vimrc
# `autocmd BufRead,BufNewFile,BufEnter *Spec.php UltiSnipsAddFiletypes php-phpspec`

priority -50

snippet spec "class XYZSpec extends ObjectBehaviour"
<?php

namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
	snip.rv = m.group().replace('/', '\\')
`;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

/**
 * @author `!v g:snips_author`
 */
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends ObjectBehavior
{
	function it_${1}()
	{
		$0
	}
}
endsnippet

snippet it "function it_does_something() { ... }"
function it_${1}()
{
	${0:${VISUAL}}
}
endsnippet

snippet let "function let() { ... }"
function let()
{
	${0:${VISUAL}}
}
endsnippet

snippet letgo "function letgo() { ... }"
function letgo()
{
	${0:${VISUAL}}
}
endsnippet

# Object construction
snippet cw "$this->beConstructedWith($arg)"
$this->beConstructedWith(${1});
endsnippet

snippet ct "$this->beConstructedThrough($methodName, [$arg])"
$this->beConstructedThrough(${1:'methodName'}, [${2:'$arg'}]);
endsnippet

# Identity and comparison matchers
snippet sreturn "$this->XYZ()->shouldReturn('value')"
$this->${1:method}()->shouldReturn(${2:'value'});
endsnippet

snippet snreturn "$this->XYZ()->shouldNotReturn('value')"
$this->${1:method}()->shouldNotReturn(${2:'value'});
endsnippet

snippet sbe "$this->XYZ()->shouldBe('value')"
$this->${1:method}()->shouldBe(${2:'value'});
endsnippet

snippet snbe "$this->XYZ()->shouldNotBe('value')"
$this->${1:method}()->shouldNotBe(${2:'value'});
endsnippet

snippet sequal "$this->XYZ()->shouldEqual('value')"
$this->${1:method}()->shouldEqual(${2:'value'});
endsnippet

snippet snequal "$this->XYZ()->shouldNotEqual('value')"
$this->${1:method}()->shouldNotEqual(${2:'value'});
endsnippet

snippet sbequalto "$this->XYZ()->shouldBeEqualTo('value')"
$this->${1:method}()->shouldBeEqualTo(${2:'value'});
endsnippet

snippet snbequalto "$this->XYZ()->shouldNotBeEqualTo('value')"
$this->${1:method}()->shouldNotBeEqualTo(${2:'value'});
endsnippet

snippet sblike "$this->XYZ()->shouldBeLike('value')"
$this->${1:method}()->shouldBeLike(${2:'value'});
endsnippet

snippet snblike "$this->XYZ()->shouldNotBeLike('value')"
$this->${1:method}()->shouldNotBeLike(${2:'value'});
endsnippet

# Throw matcher
snippet sthrowm "$this->shouldThrow('\Exception')->duringXYZ($arg)"
$this->shouldThrow(${1:'\Exception'})->during${2:Method}(${3:'$arg'});
endsnippet

snippet sthrowi "$this->shouldThrow('\Exception')->duringInstantiation()"
$this->shouldThrow(${1:'\Exception'})->duringInstantiation();
endsnippet

# Type matchers
snippet stype "$this->shouldHaveType('Type')"
$this->shouldHaveType(${1});
endsnippet

snippet sntype "$this->shouldNotHaveType('Type')"
$this->shouldNotHaveType(${1});
endsnippet

snippet srinstance "$this->shouldReturnAnInstanceOf('Type')"
$this->shouldReturnAnInstanceOf(${1});
endsnippet

snippet snrinstance "$this->shouldNotReturnAnInstanceOf('Type')"
$this->shouldNotReturnAnInstanceOf(${1});
endsnippet

snippet sbinstance "$this->shouldBeAnInstanceOf('Type')"
$this->shouldBeAnInstanceOf(${1});
endsnippet

snippet snbinstance "$this->shouldNotBeAnInstanceOf('Type')"
$this->shouldNotBeAnInstanceOf(${1});
endsnippet

snippet simplement "$this->shouldImplement('Type')"
$this->shouldImplement(${1});
endsnippet

snippet snimplement "$this->shouldNotImplement('Type')"
$this->shouldNotImplement(${1});
endsnippet

# Object state matchers
snippet sbstate "$this->shouldBeXYZ()"
$this->shouldBe${1}();
endsnippet

snippet snbstate "$this->shouldNotBeXYZ()"
$this->shouldNotBe${1}();
endsnippet

# Count matchers
snippet scount "$this->XYZ()->shouldHaveCount(7)"
$this->${1:method}()->shouldHaveCount(${2:7});
endsnippet

snippet sncount "$this->XYZ()->shouldNotHaveCount(7)"
$this->${1:method}()->shouldNotHaveCount(${2:7});
endsnippet

# Scalar type matchers
snippet sbscalar "$this->XYZ()->shouldBeString|Array|Bool()"
$this->${1:method}()->shouldBe${2:String|Array|Bool}();
endsnippet

snippet snbscalar "$this->XYZ()->shouldNotBeString|Array|Bool()"
$this->${1:method}()->shouldNotBe${2:String|Array|Bool}();
endsnippet

# Contain matcher
snippet scontain "$this->XYZ()->shouldContain('value')"
$this->${1:method}()->shouldContain(${2:'value'});
endsnippet

snippet sncontain "$this->XYZ()->shouldNotContain('value')"
$this->${1:method}()->shouldNotContain(${2:'value'});
endsnippet

# Array matchers
snippet skey "$this->XYZ()->shouldHaveKey('key')"
$this->${1:method}()->shouldHaveKey(${2:'key'});
endsnippet

snippet snkey "$this->XYZ()->shouldNotHaveKey('key')"
$this->${1:method}()->shouldNotHaveKey(${2:'key'});
endsnippet

snippet skeyvalue "$this->XYZ()->shouldHaveKeyWithValue('key', 'value')"
$this->${1:method}()->shouldHaveKeyWithValue(${2:'key'}, ${3:'value'});
endsnippet

snippet snkeyvalue "$this->XYZ()->shouldNotHaveKeyWithValue('key', 'value')"
$this->${1:method}()->shouldNotHaveKeyWithValue(${2:'key'}, ${3:'value'});
endsnippet

# String matchers
snippet sstart "$this->XYZ()->shouldStartWith('string')"
$this->${1:method}()->shouldStartWith(${2:'string'});
endsnippet

snippet snstart "$this->XYZ()->shouldNotStartWith('string')"
$this->${1:method}()->shouldNotStartWith(${2:'string'});
endsnippet

snippet send "$this->XYZ()->shouldEndWith('string')"
$this->${1:method}()->shouldEndWith(${2:'string'});
endsnippet

snippet snend "$this->XYZ()->shouldNotEndWith('string')"
$this->${1:method}()->shouldNotEndWith(${2:'string'});
endsnippet

snippet smatch "$this->XYZ()->shouldMatch('/wizard/i')"
$this->${1:method}()->shouldMatch(${2:'/wizard/i'});
endsnippet

snippet snmatch "$this->XYZ()->shouldNotMatch('/wizard/i')"
$this->${1:method}()->shouldNotMatch(${2:'/wizard/i'});
endsnippet