Skip to content

Commit 32665df

Browse files
committed
Fix passing internal protocol factory to Factory class
1 parent 2b3fef6 commit 32665df

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Factory
2525
/**
2626
* @param ?LoopInterface $loop
2727
* @param ?ConnectorInterface $connector
28-
* @param ?ProtocolFactory $protocol
28+
* @param ?ProtocolFactory $protocol (internal, should not usually be passed)
2929
*/
3030
public function __construct($loop = null, $connector = null, $protocol = null)
3131
{
@@ -35,7 +35,7 @@ public function __construct($loop = null, $connector = null, $protocol = null)
3535
if ($connector !== null && !$connector instanceof ConnectorInterface) { // manual type check to support legacy PHP < 7.1
3636
throw new \InvalidArgumentException('Argument #2 ($connector) expected null|React\Socket\ConnectorInterface');
3737
}
38-
if ($protocol !== null && !$protocol instanceof LoopInterface) { // manual type check to support legacy PHP < 7.1
38+
if ($protocol !== null && !$protocol instanceof ProtocolFactory) { // manual type check to support legacy PHP < 7.1
3939
throw new \InvalidArgumentException('Argument #3 ($protocol) expected null|Clue\Redis\Protocol\Factory');
4040
}
4141

tests/FactoryLazyClientTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ public function testConstructWithoutLoopAssignsLoopAutomatically()
3232
$this->assertInstanceOf('React\EventLoop\LoopInterface', $loop);
3333
}
3434

35+
public function testConstructWithProtocolFactoryAssignsGivenProtocolFactory()
36+
{
37+
$protocol = $this->getMockBuilder('Clue\Redis\Protocol\Factory')->getMock();
38+
39+
$factory = new Factory(null, null, $protocol);
40+
41+
$ref = new \ReflectionProperty($factory, 'protocol');
42+
$ref->setAccessible(true);
43+
44+
$this->assertSame($protocol, $ref->getValue($factory));
45+
}
46+
3547
public function testContructorThrowsExceptionForInvalidLoop()
3648
{
3749
$this->setExpectedException('InvalidArgumentException', 'Argument #1 ($loop) expected null|React\EventLoop\LoopInterface');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy