[PhpUnitBridge] added polyfill for assertStringContainsString*()
This commit is contained in:
parent
42a4de07ce
commit
1602441b22
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Constraint\StringContains;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@ -51,33 +52,21 @@ trait ForwardCompatTestTraitForV5
|
|||||||
self::doTearDown();
|
self::doTearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private static function doSetUpBeforeClass()
|
private static function doSetUpBeforeClass()
|
||||||
{
|
{
|
||||||
parent::setUpBeforeClass();
|
parent::setUpBeforeClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private static function doTearDownAfterClass()
|
private static function doTearDownAfterClass()
|
||||||
{
|
{
|
||||||
parent::tearDownAfterClass();
|
parent::tearDownAfterClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function doSetUp()
|
private function doSetUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private function doTearDown()
|
private function doTearDown()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
@ -233,6 +222,32 @@ trait ForwardCompatTestTraitForV5
|
|||||||
static::assertInternalType('iterable', $actual, $message);
|
static::assertInternalType('iterable', $actual, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $needle
|
||||||
|
* @param string $haystack
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function assertStringContainsString($needle, $haystack, $message = '')
|
||||||
|
{
|
||||||
|
$constraint = new StringContains($needle, false);
|
||||||
|
static::assertThat($haystack, $constraint, $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $needle
|
||||||
|
* @param string $haystack
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function assertStringContainsStringIgnoringCase($needle, $haystack, $message = '')
|
||||||
|
{
|
||||||
|
$constraint = new StringContains($needle, true);
|
||||||
|
static::assertThat($haystack, $constraint, $message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*
|
*
|
||||||
@ -303,6 +318,8 @@ trait ForwardCompatTestTraitForV5
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param int|string $code
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function expectExceptionCode($code)
|
public function expectExceptionCode($code)
|
||||||
@ -315,7 +332,7 @@ trait ForwardCompatTestTraitForV5
|
|||||||
|
|
||||||
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionCode');
|
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionCode');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($this, $exception);
|
$property->setValue($this, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -333,7 +350,7 @@ trait ForwardCompatTestTraitForV5
|
|||||||
|
|
||||||
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionMessage');
|
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionMessage');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($this, $exception);
|
$property->setValue($this, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,6 +368,6 @@ trait ForwardCompatTestTraitForV5
|
|||||||
|
|
||||||
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionMessageRegExp');
|
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionMessageRegExp');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($this, $exception);
|
$property->setValue($this, $messageRegExp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user