mirror of
https://github.com/predis/predis.git
synced 2026-09-05 07:16:44 +00:00
[tests] Fix the very few remaining warnings emitted by test suite.
Basically assertMatchesRegularExpression() replaces assertRegExp() which has been deprecated since PHPUnit 9.1 and will be removed in PHPUnit 10, unfortunately we still depend on PHPUnit 8.4 to support PHP 7.2 and this version does not have assertMatchesRegularExpression() so we implemented it in our base testcase class with a fallback to the old assertRegExp() when tests are executed on older versions of PHPUnit.
This commit is contained in:
@@ -442,7 +442,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase
|
||||
$connection->writeRequest($commands->create('rpush', array('foo', 'baz')));
|
||||
|
||||
$this->assertInstanceOf('Predis\Response\Error', $error = $connection->read());
|
||||
$this->assertRegExp('/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,6 +93,21 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
|
||||
$this->assertThat($actual, new ArrayHasSameValuesConstraint($expected), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a string matches a given regular expression.
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
public static function assertMatchesRegularExpression(string $pattern, string $string, $message = ''): void
|
||||
{
|
||||
if (is_callable('parent::' . __FUNCTION__)) {
|
||||
call_user_func('parent::' . __FUNCTION__, $pattern, $string, $message);
|
||||
} else {
|
||||
static::assertRegExp($pattern, $string, $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a named array with default values for connection parameters.
|
||||
*
|
||||
|
||||
@@ -66,7 +66,7 @@ class MONITOR_Test extends PredisCommandTestCase
|
||||
// NOTE: Starting with 2.6 Redis does not return the "MONITOR" message after
|
||||
// +OK to the client that issued the MONITOR command.
|
||||
if ($this->isRedisServerVersion('<=', '2.4.0')) {
|
||||
$this->assertRegExp('/\d+.\d+(\s?\(db \d+\))? "MONITOR"/', $connection->read());
|
||||
$this->assertMatchesRegularExpression('/\d+.\d+(\s?\(db \d+\))? "MONITOR"/', $connection->read());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class OBJECT_Test extends PredisCommandTestCase
|
||||
$redis = $this->getClient();
|
||||
|
||||
$redis->lpush('list:metavars', 'foo', 'bar');
|
||||
$this->assertRegExp('/[zip|quick]list/', $redis->object('ENCODING', 'list:metavars'));
|
||||
$this->assertMatchesRegularExpression('/[zip|quick]list/', $redis->object('ENCODING', 'list:metavars'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user