mirror of
https://github.com/predis/predis.git
synced 2026-10-10 05:47:02 +00:00
Instantiate the current class when subclassing Client.
Previously the getClientFor() method in a subclass of Predis\Client returned an instance of Predis\Client instead of a new instance of the subclass. The new behaviour is more correct.
This commit is contained in:
@@ -462,10 +462,22 @@ class ClientTest extends StandardTestCase
|
||||
|
||||
$clientNode02 = $client->getClientFor('node02');
|
||||
|
||||
$this->assertInstanceOf('Predis\Client', $clientNode02);
|
||||
$this->assertSame($node02, $clientNode02->getConnection());
|
||||
$this->assertSame($client->getOptions(), $clientNode02->getOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
public function testGetClientForReturnsInstanceOfSubclass()
|
||||
{
|
||||
$nodes = array('tcp://host1?alias=node01', 'tcp://host2?alias=node02');
|
||||
$client = $this->getMock('Predis\Client', array('dummy'), array($nodes), 'SubclassedClient');
|
||||
|
||||
$this->assertInstanceOf('SubclassedClient', $client->getClientFor('node02'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group disconnected
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user