Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit1602441

Browse files
Tobias Weichartnicolas-grekas
Tobias Weichart
authored andcommitted
[PhpUnitBridge] added polyfill for assertStringContainsString*()
1 parent42a4de0 commit1602441

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

‎src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV5.php‎

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespaceSymfony\Bridge\PhpUnit\Legacy;
1313

14+
usePHPUnit\Framework\Constraint\StringContains;
1415
usePHPUnit\Framework\MockObject\MockObject;
1516
usePHPUnit\Framework\TestCase;
1617

@@ -51,33 +52,21 @@ protected function tearDown()
5152
self::doTearDown();
5253
}
5354

54-
/**
55-
* @return void
56-
*/
5755
privatestaticfunctiondoSetUpBeforeClass()
5856
{
5957
parent::setUpBeforeClass();
6058
}
6159

62-
/**
63-
* @return void
64-
*/
6560
privatestaticfunctiondoTearDownAfterClass()
6661
{
6762
parent::tearDownAfterClass();
6863
}
6964

70-
/**
71-
* @return void
72-
*/
7365
privatefunctiondoSetUp()
7466
{
7567
parent::setUp();
7668
}
7769

78-
/**
79-
* @return void
80-
*/
8170
privatefunctiondoTearDown()
8271
{
8372
parent::tearDown();
@@ -233,6 +222,32 @@ public static function assertIsIterable($actual, $message = '')
233222
static::assertInternalType('iterable',$actual,$message);
234223
}
235224

225+
/**
226+
* @param string $needle
227+
* @param string $haystack
228+
* @param string $message
229+
*
230+
* @return void
231+
*/
232+
publicstaticfunctionassertStringContainsString($needle,$haystack,$message ='')
233+
{
234+
$constraint =newStringContains($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+
publicstaticfunctionassertStringContainsStringIgnoringCase($needle,$haystack,$message ='')
246+
{
247+
$constraint =newStringContains($needle,true);
248+
static::assertThat($haystack,$constraint,$message);
249+
}
250+
236251
/**
237252
* @param string $message
238253
*
@@ -303,6 +318,8 @@ public function expectException($exception)
303318
}
304319

305320
/**
321+
* @param int|string $code
322+
*
306323
* @return void
307324
*/
308325
publicfunctionexpectExceptionCode($code)
@@ -315,7 +332,7 @@ public function expectExceptionCode($code)
315332

316333
$property =new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ?'PHPUnit_Framework_TestCase' : TestCase::class,'expectedExceptionCode');
317334
$property->setAccessible(true);
318-
$property->setValue($this,$exception);
335+
$property->setValue($this,$code);
319336
}
320337

321338
/**
@@ -333,7 +350,7 @@ public function expectExceptionMessage($message)
333350

334351
$property =new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ?'PHPUnit_Framework_TestCase' : TestCase::class,'expectedExceptionMessage');
335352
$property->setAccessible(true);
336-
$property->setValue($this,$exception);
353+
$property->setValue($this,$message);
337354
}
338355

339356
/**
@@ -351,6 +368,6 @@ public function expectExceptionMessageRegExp($messageRegExp)
351368

352369
$property =new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ?'PHPUnit_Framework_TestCase' : TestCase::class,'expectedExceptionMessageRegExp');
353370
$property->setAccessible(true);
354-
$property->setValue($this,$exception);
371+
$property->setValue($this,$messageRegExp);
355372
}
356373
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp