[tests] Drop TODO and implement type check in utility method.

From feedback to PR #644.
This commit is contained in:
Daniele Alessandri
2020-08-21 11:16:25 +02:00
parent a772f0b16b
commit d4bcf912f4
+8 -2
View File
@@ -204,9 +204,15 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
*/
protected function getMockConnectionOfType($interface, $parameters = null)
{
$connection = $this->getMockBuilder($interface)->getMock();
if (!is_a($interface, '\Predis\Connection\NodeConnectionInterface', true)) {
$method = __METHOD__;
// TODO: verify that $connection is an instance of \Predis\Connection\NodeConnectionInterface
throw new \InvalidArgumentException(
"Argument `\$interface` for $method() expects a type implementing Predis\Connection\NodeConnectionInterface"
);
}
$connection = $this->getMockBuilder($interface)->getMock();
if ($parameters) {
$parameters = Connection\Parameters::create($parameters);