11
11
12
12
namespace Symfony \Bridge \PhpUnit \Legacy ;
13
13
14
+ use PHPUnit \Framework \Constraint \StringContains ;
14
15
use PHPUnit \Framework \MockObject \MockObject ;
15
16
use PHPUnit \Framework \TestCase ;
16
17
@@ -51,33 +52,21 @@ protected function tearDown()
51
52
self ::doTearDown ();
52
53
}
53
54
54
- /**
55
- * @return void
56
- */
57
55
private static function doSetUpBeforeClass ()
58
56
{
59
57
parent ::setUpBeforeClass ();
60
58
}
61
59
62
- /**
63
- * @return void
64
- */
65
60
private static function doTearDownAfterClass ()
66
61
{
67
62
parent ::tearDownAfterClass ();
68
63
}
69
64
70
- /**
71
- * @return void
72
- */
73
65
private function doSetUp ()
74
66
{
75
67
parent ::setUp ();
76
68
}
77
69
78
- /**
79
- * @return void
80
- */
81
70
private function doTearDown ()
82
71
{
83
72
parent ::tearDown ();
@@ -233,6 +222,32 @@ public static function assertIsIterable($actual, $message = '')
233
222
static ::assertInternalType ('iterable ' , $ actual , $ message );
234
223
}
235
224
225
+ /**
226
+ * @param string $needle
227
+ * @param string $haystack
228
+ * @param string $message
229
+ *
230
+ * @return void
231
+ */
232
+ public static function assertStringContainsString ($ needle , $ haystack , $ message = '' )
233
+ {
234
+ $ constraint = new StringContains ($ needle , false );
235
+ static ::assertThat ($ haystack , $ constraint , $ message );
236
+ }
237
+
238
+ /**
239
+ * @param string $needle
240
+ * @param string $haystack
241
+ * @param string $message
242
+ *
243
+ * @return void
244
+ */
245
+ public static function assertStringContainsStringIgnoringCase ($ needle , $ haystack , $ message = '' )
246
+ {
247
+ $ constraint = new StringContains ($ needle , true );
248
+ static ::assertThat ($ haystack , $ constraint , $ message );
249
+ }
250
+
236
251
/**
237
252
* @param string $message
238
253
*
@@ -303,6 +318,8 @@ public function expectException($exception)
303
318
}
304
319
305
320
/**
321
+ * @param int|string $code
322
+ *
306
323
* @return void
307
324
*/
308
325
public function expectExceptionCode ($ code )
@@ -315,7 +332,7 @@ public function expectExceptionCode($code)
315
332
316
333
$ property = new \ReflectionProperty (class_exists ('PHPUnit_Framework_TestCase ' ) ? 'PHPUnit_Framework_TestCase ' : TestCase::class, 'expectedExceptionCode ' );
317
334
$ property ->setAccessible (true );
318
- $ property ->setValue ($ this , $ exception );
335
+ $ property ->setValue ($ this , $ code );
319
336
}
320
337
321
338
/**
@@ -333,7 +350,7 @@ public function expectExceptionMessage($message)
333
350
334
351
$ property = new \ReflectionProperty (class_exists ('PHPUnit_Framework_TestCase ' ) ? 'PHPUnit_Framework_TestCase ' : TestCase::class, 'expectedExceptionMessage ' );
335
352
$ property ->setAccessible (true );
336
- $ property ->setValue ($ this , $ exception );
353
+ $ property ->setValue ($ this , $ message );
337
354
}
338
355
339
356
/**
@@ -351,6 +368,6 @@ public function expectExceptionMessageRegExp($messageRegExp)
351
368
352
369
$ property = new \ReflectionProperty (class_exists ('PHPUnit_Framework_TestCase ' ) ? 'PHPUnit_Framework_TestCase ' : TestCase::class, 'expectedExceptionMessageRegExp ' );
353
370
$ property ->setAccessible (true );
354
- $ property ->setValue ($ this , $ exception );
371
+ $ property ->setValue ($ this , $ messageRegExp );
355
372
}
356
373
}
0 commit comments