|
2 | 2 |
|
3 | 3 | use React\Socket\ConnectionInterface; |
4 | 4 |
|
5 | | -use Clue\React\Redis\Server; |
6 | | - |
7 | | -use Clue\React\Redis\StreamingClient; |
8 | | - |
9 | 5 | use Clue\React\Redis\Factory; |
| 6 | +use React\Promise; |
10 | 7 |
|
11 | 8 | class FactoryTest extends TestCase |
12 | 9 | { |
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; |
30 | 13 |
|
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() |
42 | 15 | { |
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); |
50 | 19 | } |
51 | 20 |
|
52 | | - /** |
53 | | - * @depends testPrequisiteServerAcceptsAnyPassword |
54 | | - */ |
55 | | - public function testClientAuthenticationContainsColons() |
| 21 | + public function testCtor() |
56 | 22 | { |
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); |
64 | 24 | } |
65 | 25 |
|
66 | | - public function testClientUnconnectableAddress() |
| 26 | + public function testWillRejectIfConnectorRejects() |
67 | 27 | { |
| 28 | + $this->connector->expects($this->once())->method('create')->with('127.0.0.1', 2)->willReturn(Promise\reject(new \RuntimeException())); |
68 | 29 | $promise = $this->factory->createClient('tcp://127.0.0.1:2'); |
69 | 30 |
|
70 | 31 | $this->expectPromiseReject($promise); |
71 | | - |
72 | | - $this->loop->tick(); |
73 | 32 | } |
74 | 33 |
|
75 | | - public function testClientInvalidAddress() |
| 34 | + public function testWillRejectIfTargetIsInvalid() |
76 | 35 | { |
77 | 36 | $promise = $this->factory->createClient('http://invalid target'); |
78 | 37 |
|
|
0 commit comments