Skip to content

Commit 8e3d065

Browse files
committed
Clean up FactoryTest
1 parent 3a74556 commit 8e3d065

1 file changed

Lines changed: 13 additions & 54 deletions

File tree

tests/FactoryTest.php

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,36 @@
22

33
use React\Socket\ConnectionInterface;
44

5-
use Clue\React\Redis\Server;
6-
7-
use Clue\React\Redis\StreamingClient;
8-
95
use Clue\React\Redis\Factory;
6+
use React\Promise;
107

118
class FactoryTest extends TestCase
129
{
13-
public function setUp()
14-
{
15-
$this->loop = new React\EventLoop\StreamSelectLoop();
16-
$this->factory = new Factory($this->loop);
17-
}
18-
19-
public function testPrequisiteServerAcceptsAnyPassword()
20-
{
21-
$this->markTestSkipped();
22-
}
23-
24-
/**
25-
* @depends testPrequisiteServerAcceptsAnyPassword
26-
*/
27-
public function testClientDefaultSuccess()
28-
{
29-
$promise = $this->factory->createClient();
10+
private $loop;
11+
private $connector;
12+
private $factory;
3013

31-
$this->expectPromiseResolve($promise)->then(function (StreamingClient $client) {
32-
$client->end();
33-
});
34-
35-
$this->loop->run();
36-
}
37-
38-
/**
39-
* @depends testPrequisiteServerAcceptsAnyPassword
40-
*/
41-
public function testClientAuthSelect()
14+
public function setUp()
4215
{
43-
$promise = $this->factory->createClient('tcp://authenticationpassword@127.0.0.1:6379/0');
44-
45-
$this->expectPromiseResolve($promise)->then(function (StreamingClient $client) {
46-
$client->end();
47-
});
48-
49-
$this->loop->run();
16+
$this->loop = $this->getMock('React\EventLoop\LoopInterface');
17+
$this->connector = $this->getMock('React\SocketClient\ConnectorInterface');
18+
$this->factory = new Factory($this->loop, $this->connector);
5019
}
5120

52-
/**
53-
* @depends testPrequisiteServerAcceptsAnyPassword
54-
*/
55-
public function testClientAuthenticationContainsColons()
21+
public function testCtor()
5622
{
57-
$promise = $this->factory->createClient('tcp://authentication:can:contain:colons@127.0.0.1:6379');
58-
59-
$this->expectPromiseResolve($promise)->then(function (StreamingClient $client) {
60-
$client->end();
61-
});
62-
63-
$this->loop->run();
23+
$this->factory = new Factory($this->loop);
6424
}
6525

66-
public function testClientUnconnectableAddress()
26+
public function testWillRejectIfConnectorRejects()
6727
{
28+
$this->connector->expects($this->once())->method('create')->with('127.0.0.1', 2)->willReturn(Promise\reject(new \RuntimeException()));
6829
$promise = $this->factory->createClient('tcp://127.0.0.1:2');
6930

7031
$this->expectPromiseReject($promise);
71-
72-
$this->loop->tick();
7332
}
7433

75-
public function testClientInvalidAddress()
34+
public function testWillRejectIfTargetIsInvalid()
7635
{
7736
$promise = $this->factory->createClient('http://invalid target');
7837

0 commit comments

Comments
 (0)