| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
Copyright (c) 2009-2010 hamcrest.org
|
|
|
5 |
*/
|
|
|
6 |
|
|
|
7 |
// This file is generated from the static method @factory doctags.
|
|
|
8 |
|
|
|
9 |
namespace Hamcrest;
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* A series of static factories for all hamcrest matchers.
|
|
|
13 |
*/
|
|
|
14 |
class Matchers
|
|
|
15 |
{
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Evaluates to true only if each $matcher[$i] is satisfied by $array[$i].
|
|
|
19 |
*/
|
|
|
20 |
public static function anArray(/* args... */)
|
|
|
21 |
{
|
|
|
22 |
$args = func_get_args();
|
|
|
23 |
return call_user_func_array(array('\Hamcrest\Arrays\IsArray', 'anArray'), $args);
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Evaluates to true if any item in an array satisfies the given matcher.
|
|
|
28 |
*
|
|
|
29 |
* @param mixed $item as a {@link Hamcrest\Matcher} or a value.
|
|
|
30 |
*
|
|
|
31 |
* @return \Hamcrest\Arrays\IsArrayContaining
|
|
|
32 |
*/
|
|
|
33 |
public static function hasItemInArray($item)
|
|
|
34 |
{
|
|
|
35 |
return \Hamcrest\Arrays\IsArrayContaining::hasItemInArray($item);
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Evaluates to true if any item in an array satisfies the given matcher.
|
|
|
40 |
*
|
|
|
41 |
* @param mixed $item as a {@link Hamcrest\Matcher} or a value.
|
|
|
42 |
*
|
|
|
43 |
* @return \Hamcrest\Arrays\IsArrayContaining
|
|
|
44 |
*/
|
|
|
45 |
public static function hasValue($item)
|
|
|
46 |
{
|
|
|
47 |
return \Hamcrest\Arrays\IsArrayContaining::hasItemInArray($item);
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* An array with elements that match the given matchers.
|
|
|
52 |
*/
|
|
|
53 |
public static function arrayContainingInAnyOrder(/* args... */)
|
|
|
54 |
{
|
|
|
55 |
$args = func_get_args();
|
|
|
56 |
return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInAnyOrder', 'arrayContainingInAnyOrder'), $args);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* An array with elements that match the given matchers.
|
|
|
61 |
*/
|
|
|
62 |
public static function containsInAnyOrder(/* args... */)
|
|
|
63 |
{
|
|
|
64 |
$args = func_get_args();
|
|
|
65 |
return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInAnyOrder', 'arrayContainingInAnyOrder'), $args);
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
/**
|
|
|
69 |
* An array with elements that match the given matchers in the same order.
|
|
|
70 |
*/
|
|
|
71 |
public static function arrayContaining(/* args... */)
|
|
|
72 |
{
|
|
|
73 |
$args = func_get_args();
|
|
|
74 |
return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInOrder', 'arrayContaining'), $args);
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* An array with elements that match the given matchers in the same order.
|
|
|
79 |
*/
|
|
|
80 |
public static function contains(/* args... */)
|
|
|
81 |
{
|
|
|
82 |
$args = func_get_args();
|
|
|
83 |
return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInOrder', 'arrayContaining'), $args);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Evaluates to true if any key in an array matches the given matcher.
|
|
|
88 |
*
|
|
|
89 |
* @param mixed $key as a {@link Hamcrest\Matcher} or a value.
|
|
|
90 |
*
|
|
|
91 |
* @return \Hamcrest\Arrays\IsArrayContainingKey
|
|
|
92 |
*/
|
|
|
93 |
public static function hasKeyInArray($key)
|
|
|
94 |
{
|
|
|
95 |
return \Hamcrest\Arrays\IsArrayContainingKey::hasKeyInArray($key);
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
/**
|
|
|
99 |
* Evaluates to true if any key in an array matches the given matcher.
|
|
|
100 |
*
|
|
|
101 |
* @param mixed $key as a {@link Hamcrest\Matcher} or a value.
|
|
|
102 |
*
|
|
|
103 |
* @return \Hamcrest\Arrays\IsArrayContainingKey
|
|
|
104 |
*/
|
|
|
105 |
public static function hasKey($key)
|
|
|
106 |
{
|
|
|
107 |
return \Hamcrest\Arrays\IsArrayContainingKey::hasKeyInArray($key);
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
/**
|
|
|
111 |
* Test if an array has both an key and value in parity with each other.
|
|
|
112 |
*/
|
|
|
113 |
public static function hasKeyValuePair($key, $value)
|
|
|
114 |
{
|
|
|
115 |
return \Hamcrest\Arrays\IsArrayContainingKeyValuePair::hasKeyValuePair($key, $value);
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
/**
|
|
|
119 |
* Test if an array has both an key and value in parity with each other.
|
|
|
120 |
*/
|
|
|
121 |
public static function hasEntry($key, $value)
|
|
|
122 |
{
|
|
|
123 |
return \Hamcrest\Arrays\IsArrayContainingKeyValuePair::hasKeyValuePair($key, $value);
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
/**
|
|
|
127 |
* Does array size satisfy a given matcher?
|
|
|
128 |
*
|
|
|
129 |
* @param \Hamcrest\Matcher|int $size as a {@link Hamcrest\Matcher} or a value.
|
|
|
130 |
*
|
|
|
131 |
* @return \Hamcrest\Arrays\IsArrayWithSize
|
|
|
132 |
*/
|
|
|
133 |
public static function arrayWithSize($size)
|
|
|
134 |
{
|
|
|
135 |
return \Hamcrest\Arrays\IsArrayWithSize::arrayWithSize($size);
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
/**
|
|
|
139 |
* Matches an empty array.
|
|
|
140 |
*/
|
|
|
141 |
public static function emptyArray()
|
|
|
142 |
{
|
|
|
143 |
return \Hamcrest\Arrays\IsArrayWithSize::emptyArray();
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
/**
|
|
|
147 |
* Matches an empty array.
|
|
|
148 |
*/
|
|
|
149 |
public static function nonEmptyArray()
|
|
|
150 |
{
|
|
|
151 |
return \Hamcrest\Arrays\IsArrayWithSize::nonEmptyArray();
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
/**
|
|
|
155 |
* Returns true if traversable is empty.
|
|
|
156 |
*/
|
|
|
157 |
public static function emptyTraversable()
|
|
|
158 |
{
|
|
|
159 |
return \Hamcrest\Collection\IsEmptyTraversable::emptyTraversable();
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
/**
|
|
|
163 |
* Returns true if traversable is not empty.
|
|
|
164 |
*/
|
|
|
165 |
public static function nonEmptyTraversable()
|
|
|
166 |
{
|
|
|
167 |
return \Hamcrest\Collection\IsEmptyTraversable::nonEmptyTraversable();
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
/**
|
|
|
171 |
* Does traversable size satisfy a given matcher?
|
|
|
172 |
*/
|
|
|
173 |
public static function traversableWithSize($size)
|
|
|
174 |
{
|
|
|
175 |
return \Hamcrest\Collection\IsTraversableWithSize::traversableWithSize($size);
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
/**
|
|
|
179 |
* Evaluates to true only if ALL of the passed in matchers evaluate to true.
|
|
|
180 |
*/
|
|
|
181 |
public static function allOf(/* args... */)
|
|
|
182 |
{
|
|
|
183 |
$args = func_get_args();
|
|
|
184 |
return call_user_func_array(array('\Hamcrest\Core\AllOf', 'allOf'), $args);
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
/**
|
|
|
188 |
* Evaluates to true if ANY of the passed in matchers evaluate to true.
|
|
|
189 |
*/
|
|
|
190 |
public static function anyOf(/* args... */)
|
|
|
191 |
{
|
|
|
192 |
$args = func_get_args();
|
|
|
193 |
return call_user_func_array(array('\Hamcrest\Core\AnyOf', 'anyOf'), $args);
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
/**
|
|
|
197 |
* Evaluates to false if ANY of the passed in matchers evaluate to true.
|
|
|
198 |
*/
|
|
|
199 |
public static function noneOf(/* args... */)
|
|
|
200 |
{
|
|
|
201 |
$args = func_get_args();
|
|
|
202 |
return call_user_func_array(array('\Hamcrest\Core\AnyOf', 'noneOf'), $args);
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
/**
|
|
|
206 |
* This is useful for fluently combining matchers that must both pass.
|
|
|
207 |
* For example:
|
|
|
208 |
* <pre>
|
|
|
209 |
* assertThat($string, both(containsString("a"))->andAlso(containsString("b")));
|
|
|
210 |
* </pre>
|
|
|
211 |
*/
|
|
|
212 |
public static function both(\Hamcrest\Matcher $matcher)
|
|
|
213 |
{
|
|
|
214 |
return \Hamcrest\Core\CombinableMatcher::both($matcher);
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
/**
|
|
|
218 |
* This is useful for fluently combining matchers where either may pass,
|
|
|
219 |
* for example:
|
|
|
220 |
* <pre>
|
|
|
221 |
* assertThat($string, either(containsString("a"))->orElse(containsString("b")));
|
|
|
222 |
* </pre>
|
|
|
223 |
*/
|
|
|
224 |
public static function either(\Hamcrest\Matcher $matcher)
|
|
|
225 |
{
|
|
|
226 |
return \Hamcrest\Core\CombinableMatcher::either($matcher);
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
/**
|
|
|
230 |
* Wraps an existing matcher and overrides the description when it fails.
|
|
|
231 |
*/
|
|
|
232 |
public static function describedAs(/* args... */)
|
|
|
233 |
{
|
|
|
234 |
$args = func_get_args();
|
|
|
235 |
return call_user_func_array(array('\Hamcrest\Core\DescribedAs', 'describedAs'), $args);
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
/**
|
|
|
239 |
* @param Matcher $itemMatcher
|
|
|
240 |
* A matcher to apply to every element in an array.
|
|
|
241 |
*
|
|
|
242 |
* @return \Hamcrest\Core\Every
|
|
|
243 |
* Evaluates to TRUE for a collection in which every item matches $itemMatcher
|
|
|
244 |
*/
|
|
|
245 |
public static function everyItem(\Hamcrest\Matcher $itemMatcher)
|
|
|
246 |
{
|
|
|
247 |
return \Hamcrest\Core\Every::everyItem($itemMatcher);
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
/**
|
|
|
251 |
* Does array size satisfy a given matcher?
|
|
|
252 |
*/
|
|
|
253 |
public static function hasToString($matcher)
|
|
|
254 |
{
|
|
|
255 |
return \Hamcrest\Core\HasToString::hasToString($matcher);
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
/**
|
|
|
259 |
* Decorates another Matcher, retaining the behavior but allowing tests
|
|
|
260 |
* to be slightly more expressive.
|
|
|
261 |
*
|
|
|
262 |
* For example: assertThat($cheese, equalTo($smelly))
|
|
|
263 |
* vs. assertThat($cheese, is(equalTo($smelly)))
|
|
|
264 |
*/
|
|
|
265 |
public static function is($value)
|
|
|
266 |
{
|
|
|
267 |
return \Hamcrest\Core\Is::is($value);
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
/**
|
|
|
271 |
* This matcher always evaluates to true.
|
|
|
272 |
*
|
|
|
273 |
* @param string $description A meaningful string used when describing itself.
|
|
|
274 |
*
|
|
|
275 |
* @return \Hamcrest\Core\IsAnything
|
|
|
276 |
*/
|
|
|
277 |
public static function anything($description = 'ANYTHING')
|
|
|
278 |
{
|
|
|
279 |
return \Hamcrest\Core\IsAnything::anything($description);
|
|
|
280 |
}
|
|
|
281 |
|
|
|
282 |
/**
|
|
|
283 |
* Test if the value is an array containing this matcher.
|
|
|
284 |
*
|
|
|
285 |
* Example:
|
|
|
286 |
* <pre>
|
|
|
287 |
* assertThat(array('a', 'b'), hasItem(equalTo('b')));
|
|
|
288 |
* //Convenience defaults to equalTo()
|
|
|
289 |
* assertThat(array('a', 'b'), hasItem('b'));
|
|
|
290 |
* </pre>
|
|
|
291 |
*/
|
|
|
292 |
public static function hasItem(/* args... */)
|
|
|
293 |
{
|
|
|
294 |
$args = func_get_args();
|
|
|
295 |
return call_user_func_array(array('\Hamcrest\Core\IsCollectionContaining', 'hasItem'), $args);
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
/**
|
|
|
299 |
* Test if the value is an array containing elements that match all of these
|
|
|
300 |
* matchers.
|
|
|
301 |
*
|
|
|
302 |
* Example:
|
|
|
303 |
* <pre>
|
|
|
304 |
* assertThat(array('a', 'b', 'c'), hasItems(equalTo('a'), equalTo('b')));
|
|
|
305 |
* </pre>
|
|
|
306 |
*/
|
|
|
307 |
public static function hasItems(/* args... */)
|
|
|
308 |
{
|
|
|
309 |
$args = func_get_args();
|
|
|
310 |
return call_user_func_array(array('\Hamcrest\Core\IsCollectionContaining', 'hasItems'), $args);
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
/**
|
|
|
314 |
* Is the value equal to another value, as tested by the use of the "=="
|
|
|
315 |
* comparison operator?
|
|
|
316 |
*/
|
|
|
317 |
public static function equalTo($item)
|
|
|
318 |
{
|
|
|
319 |
return \Hamcrest\Core\IsEqual::equalTo($item);
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
/**
|
|
|
323 |
* Tests of the value is identical to $value as tested by the "===" operator.
|
|
|
324 |
*/
|
|
|
325 |
public static function identicalTo($value)
|
|
|
326 |
{
|
|
|
327 |
return \Hamcrest\Core\IsIdentical::identicalTo($value);
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
/**
|
|
|
331 |
* Is the value an instance of a particular type?
|
|
|
332 |
* This version assumes no relationship between the required type and
|
|
|
333 |
* the signature of the method that sets it up, for example in
|
|
|
334 |
* <code>assertThat($anObject, anInstanceOf('Thing'));</code>
|
|
|
335 |
*/
|
|
|
336 |
public static function anInstanceOf($theClass)
|
|
|
337 |
{
|
|
|
338 |
return \Hamcrest\Core\IsInstanceOf::anInstanceOf($theClass);
|
|
|
339 |
}
|
|
|
340 |
|
|
|
341 |
/**
|
|
|
342 |
* Is the value an instance of a particular type?
|
|
|
343 |
* This version assumes no relationship between the required type and
|
|
|
344 |
* the signature of the method that sets it up, for example in
|
|
|
345 |
* <code>assertThat($anObject, anInstanceOf('Thing'));</code>
|
|
|
346 |
*/
|
|
|
347 |
public static function any($theClass)
|
|
|
348 |
{
|
|
|
349 |
return \Hamcrest\Core\IsInstanceOf::anInstanceOf($theClass);
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
/**
|
|
|
353 |
* Matches if value does not match $value.
|
|
|
354 |
*/
|
|
|
355 |
public static function not($value)
|
|
|
356 |
{
|
|
|
357 |
return \Hamcrest\Core\IsNot::not($value);
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
/**
|
|
|
361 |
* Matches if value is null.
|
|
|
362 |
*/
|
|
|
363 |
public static function nullValue()
|
|
|
364 |
{
|
|
|
365 |
return \Hamcrest\Core\IsNull::nullValue();
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
/**
|
|
|
369 |
* Matches if value is not null.
|
|
|
370 |
*/
|
|
|
371 |
public static function notNullValue()
|
|
|
372 |
{
|
|
|
373 |
return \Hamcrest\Core\IsNull::notNullValue();
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
/**
|
|
|
377 |
* Creates a new instance of IsSame.
|
|
|
378 |
*
|
|
|
379 |
* @param mixed $object
|
|
|
380 |
* The predicate evaluates to true only when the argument is
|
|
|
381 |
* this object.
|
|
|
382 |
*
|
|
|
383 |
* @return \Hamcrest\Core\IsSame
|
|
|
384 |
*/
|
|
|
385 |
public static function sameInstance($object)
|
|
|
386 |
{
|
|
|
387 |
return \Hamcrest\Core\IsSame::sameInstance($object);
|
|
|
388 |
}
|
|
|
389 |
|
|
|
390 |
/**
|
|
|
391 |
* Is the value a particular built-in type?
|
|
|
392 |
*/
|
|
|
393 |
public static function typeOf($theType)
|
|
|
394 |
{
|
|
|
395 |
return \Hamcrest\Core\IsTypeOf::typeOf($theType);
|
|
|
396 |
}
|
|
|
397 |
|
|
|
398 |
/**
|
|
|
399 |
* Matches if value (class, object, or array) has named $property.
|
|
|
400 |
*/
|
|
|
401 |
public static function set($property)
|
|
|
402 |
{
|
|
|
403 |
return \Hamcrest\Core\Set::set($property);
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
/**
|
|
|
407 |
* Matches if value (class, object, or array) does not have named $property.
|
|
|
408 |
*/
|
|
|
409 |
public static function notSet($property)
|
|
|
410 |
{
|
|
|
411 |
return \Hamcrest\Core\Set::notSet($property);
|
|
|
412 |
}
|
|
|
413 |
|
|
|
414 |
/**
|
|
|
415 |
* Matches if value is a number equal to $value within some range of
|
|
|
416 |
* acceptable error $delta.
|
|
|
417 |
*/
|
|
|
418 |
public static function closeTo($value, $delta)
|
|
|
419 |
{
|
|
|
420 |
return \Hamcrest\Number\IsCloseTo::closeTo($value, $delta);
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
/**
|
|
|
424 |
* The value is not > $value, nor < $value.
|
|
|
425 |
*/
|
|
|
426 |
public static function comparesEqualTo($value)
|
|
|
427 |
{
|
|
|
428 |
return \Hamcrest\Number\OrderingComparison::comparesEqualTo($value);
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
/**
|
|
|
432 |
* The value is > $value.
|
|
|
433 |
*/
|
|
|
434 |
public static function greaterThan($value)
|
|
|
435 |
{
|
|
|
436 |
return \Hamcrest\Number\OrderingComparison::greaterThan($value);
|
|
|
437 |
}
|
|
|
438 |
|
|
|
439 |
/**
|
|
|
440 |
* The value is >= $value.
|
|
|
441 |
*/
|
|
|
442 |
public static function greaterThanOrEqualTo($value)
|
|
|
443 |
{
|
|
|
444 |
return \Hamcrest\Number\OrderingComparison::greaterThanOrEqualTo($value);
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
/**
|
|
|
448 |
* The value is >= $value.
|
|
|
449 |
*/
|
|
|
450 |
public static function atLeast($value)
|
|
|
451 |
{
|
|
|
452 |
return \Hamcrest\Number\OrderingComparison::greaterThanOrEqualTo($value);
|
|
|
453 |
}
|
|
|
454 |
|
|
|
455 |
/**
|
|
|
456 |
* The value is < $value.
|
|
|
457 |
*/
|
|
|
458 |
public static function lessThan($value)
|
|
|
459 |
{
|
|
|
460 |
return \Hamcrest\Number\OrderingComparison::lessThan($value);
|
|
|
461 |
}
|
|
|
462 |
|
|
|
463 |
/**
|
|
|
464 |
* The value is <= $value.
|
|
|
465 |
*/
|
|
|
466 |
public static function lessThanOrEqualTo($value)
|
|
|
467 |
{
|
|
|
468 |
return \Hamcrest\Number\OrderingComparison::lessThanOrEqualTo($value);
|
|
|
469 |
}
|
|
|
470 |
|
|
|
471 |
/**
|
|
|
472 |
* The value is <= $value.
|
|
|
473 |
*/
|
|
|
474 |
public static function atMost($value)
|
|
|
475 |
{
|
|
|
476 |
return \Hamcrest\Number\OrderingComparison::lessThanOrEqualTo($value);
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
/**
|
|
|
480 |
* Matches if value is a zero-length string.
|
|
|
481 |
*/
|
|
|
482 |
public static function isEmptyString()
|
|
|
483 |
{
|
|
|
484 |
return \Hamcrest\Text\IsEmptyString::isEmptyString();
|
|
|
485 |
}
|
|
|
486 |
|
|
|
487 |
/**
|
|
|
488 |
* Matches if value is a zero-length string.
|
|
|
489 |
*/
|
|
|
490 |
public static function emptyString()
|
|
|
491 |
{
|
|
|
492 |
return \Hamcrest\Text\IsEmptyString::isEmptyString();
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
/**
|
|
|
496 |
* Matches if value is null or a zero-length string.
|
|
|
497 |
*/
|
|
|
498 |
public static function isEmptyOrNullString()
|
|
|
499 |
{
|
|
|
500 |
return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString();
|
|
|
501 |
}
|
|
|
502 |
|
|
|
503 |
/**
|
|
|
504 |
* Matches if value is null or a zero-length string.
|
|
|
505 |
*/
|
|
|
506 |
public static function nullOrEmptyString()
|
|
|
507 |
{
|
|
|
508 |
return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString();
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
/**
|
|
|
512 |
* Matches if value is a non-zero-length string.
|
|
|
513 |
*/
|
|
|
514 |
public static function isNonEmptyString()
|
|
|
515 |
{
|
|
|
516 |
return \Hamcrest\Text\IsEmptyString::isNonEmptyString();
|
|
|
517 |
}
|
|
|
518 |
|
|
|
519 |
/**
|
|
|
520 |
* Matches if value is a non-zero-length string.
|
|
|
521 |
*/
|
|
|
522 |
public static function nonEmptyString()
|
|
|
523 |
{
|
|
|
524 |
return \Hamcrest\Text\IsEmptyString::isNonEmptyString();
|
|
|
525 |
}
|
|
|
526 |
|
|
|
527 |
/**
|
|
|
528 |
* Matches if value is a string equal to $string, regardless of the case.
|
|
|
529 |
*/
|
|
|
530 |
public static function equalToIgnoringCase($string)
|
|
|
531 |
{
|
|
|
532 |
return \Hamcrest\Text\IsEqualIgnoringCase::equalToIgnoringCase($string);
|
|
|
533 |
}
|
|
|
534 |
|
|
|
535 |
/**
|
|
|
536 |
* Matches if value is a string equal to $string, regardless of whitespace.
|
|
|
537 |
*/
|
|
|
538 |
public static function equalToIgnoringWhiteSpace($string)
|
|
|
539 |
{
|
|
|
540 |
return \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace($string);
|
|
|
541 |
}
|
|
|
542 |
|
|
|
543 |
/**
|
|
|
544 |
* Matches if value is a string that matches regular expression $pattern.
|
|
|
545 |
*/
|
|
|
546 |
public static function matchesPattern($pattern)
|
|
|
547 |
{
|
|
|
548 |
return \Hamcrest\Text\MatchesPattern::matchesPattern($pattern);
|
|
|
549 |
}
|
|
|
550 |
|
|
|
551 |
/**
|
|
|
552 |
* Matches if value is a string that contains $substring.
|
|
|
553 |
*/
|
|
|
554 |
public static function containsString($substring)
|
|
|
555 |
{
|
|
|
556 |
return \Hamcrest\Text\StringContains::containsString($substring);
|
|
|
557 |
}
|
|
|
558 |
|
|
|
559 |
/**
|
|
|
560 |
* Matches if value is a string that contains $substring regardless of the case.
|
|
|
561 |
*/
|
|
|
562 |
public static function containsStringIgnoringCase($substring)
|
|
|
563 |
{
|
|
|
564 |
return \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase($substring);
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
/**
|
|
|
568 |
* Matches if value contains $substrings in a constrained order.
|
|
|
569 |
*/
|
|
|
570 |
public static function stringContainsInOrder(/* args... */)
|
|
|
571 |
{
|
|
|
572 |
$args = func_get_args();
|
|
|
573 |
return call_user_func_array(array('\Hamcrest\Text\StringContainsInOrder', 'stringContainsInOrder'), $args);
|
|
|
574 |
}
|
|
|
575 |
|
|
|
576 |
/**
|
|
|
577 |
* Matches if value is a string that ends with $substring.
|
|
|
578 |
*/
|
|
|
579 |
public static function endsWith($substring)
|
|
|
580 |
{
|
|
|
581 |
return \Hamcrest\Text\StringEndsWith::endsWith($substring);
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
/**
|
|
|
585 |
* Matches if value is a string that starts with $substring.
|
|
|
586 |
*/
|
|
|
587 |
public static function startsWith($substring)
|
|
|
588 |
{
|
|
|
589 |
return \Hamcrest\Text\StringStartsWith::startsWith($substring);
|
|
|
590 |
}
|
|
|
591 |
|
|
|
592 |
/**
|
|
|
593 |
* Is the value an array?
|
|
|
594 |
*/
|
|
|
595 |
public static function arrayValue()
|
|
|
596 |
{
|
|
|
597 |
return \Hamcrest\Type\IsArray::arrayValue();
|
|
|
598 |
}
|
|
|
599 |
|
|
|
600 |
/**
|
|
|
601 |
* Is the value a boolean?
|
|
|
602 |
*/
|
|
|
603 |
public static function booleanValue()
|
|
|
604 |
{
|
|
|
605 |
return \Hamcrest\Type\IsBoolean::booleanValue();
|
|
|
606 |
}
|
|
|
607 |
|
|
|
608 |
/**
|
|
|
609 |
* Is the value a boolean?
|
|
|
610 |
*/
|
|
|
611 |
public static function boolValue()
|
|
|
612 |
{
|
|
|
613 |
return \Hamcrest\Type\IsBoolean::booleanValue();
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
/**
|
|
|
617 |
* Is the value callable?
|
|
|
618 |
*/
|
|
|
619 |
public static function callableValue()
|
|
|
620 |
{
|
|
|
621 |
return \Hamcrest\Type\IsCallable::callableValue();
|
|
|
622 |
}
|
|
|
623 |
|
|
|
624 |
/**
|
|
|
625 |
* Is the value a float/double?
|
|
|
626 |
*/
|
|
|
627 |
public static function doubleValue()
|
|
|
628 |
{
|
|
|
629 |
return \Hamcrest\Type\IsDouble::doubleValue();
|
|
|
630 |
}
|
|
|
631 |
|
|
|
632 |
/**
|
|
|
633 |
* Is the value a float/double?
|
|
|
634 |
*/
|
|
|
635 |
public static function floatValue()
|
|
|
636 |
{
|
|
|
637 |
return \Hamcrest\Type\IsDouble::doubleValue();
|
|
|
638 |
}
|
|
|
639 |
|
|
|
640 |
/**
|
|
|
641 |
* Is the value an integer?
|
|
|
642 |
*/
|
|
|
643 |
public static function integerValue()
|
|
|
644 |
{
|
|
|
645 |
return \Hamcrest\Type\IsInteger::integerValue();
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
/**
|
|
|
649 |
* Is the value an integer?
|
|
|
650 |
*/
|
|
|
651 |
public static function intValue()
|
|
|
652 |
{
|
|
|
653 |
return \Hamcrest\Type\IsInteger::integerValue();
|
|
|
654 |
}
|
|
|
655 |
|
|
|
656 |
/**
|
|
|
657 |
* Is the value a numeric?
|
|
|
658 |
*/
|
|
|
659 |
public static function numericValue()
|
|
|
660 |
{
|
|
|
661 |
return \Hamcrest\Type\IsNumeric::numericValue();
|
|
|
662 |
}
|
|
|
663 |
|
|
|
664 |
/**
|
|
|
665 |
* Is the value an object?
|
|
|
666 |
*/
|
|
|
667 |
public static function objectValue()
|
|
|
668 |
{
|
|
|
669 |
return \Hamcrest\Type\IsObject::objectValue();
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
/**
|
|
|
673 |
* Is the value an object?
|
|
|
674 |
*/
|
|
|
675 |
public static function anObject()
|
|
|
676 |
{
|
|
|
677 |
return \Hamcrest\Type\IsObject::objectValue();
|
|
|
678 |
}
|
|
|
679 |
|
|
|
680 |
/**
|
|
|
681 |
* Is the value a resource?
|
|
|
682 |
*/
|
|
|
683 |
public static function resourceValue()
|
|
|
684 |
{
|
|
|
685 |
return \Hamcrest\Type\IsResource::resourceValue();
|
|
|
686 |
}
|
|
|
687 |
|
|
|
688 |
/**
|
|
|
689 |
* Is the value a scalar (boolean, integer, double, or string)?
|
|
|
690 |
*/
|
|
|
691 |
public static function scalarValue()
|
|
|
692 |
{
|
|
|
693 |
return \Hamcrest\Type\IsScalar::scalarValue();
|
|
|
694 |
}
|
|
|
695 |
|
|
|
696 |
/**
|
|
|
697 |
* Is the value a string?
|
|
|
698 |
*/
|
|
|
699 |
public static function stringValue()
|
|
|
700 |
{
|
|
|
701 |
return \Hamcrest\Type\IsString::stringValue();
|
|
|
702 |
}
|
|
|
703 |
|
|
|
704 |
/**
|
|
|
705 |
* Wraps <code>$matcher</code> with {@link Hamcrest\Core\IsEqual)
|
|
|
706 |
* if it's not a matcher and the XPath in <code>count()</code>
|
|
|
707 |
* if it's an integer.
|
|
|
708 |
*/
|
|
|
709 |
public static function hasXPath($xpath, $matcher = null)
|
|
|
710 |
{
|
|
|
711 |
return \Hamcrest\Xml\HasXPath::hasXPath($xpath, $matcher);
|
|
|
712 |
}
|
|
|
713 |
}
|