Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 44bc6eb

Browse files
committed
Decoupled EncodedConnectionTest and JSONEncoderTest
1 parent d66f3ab commit 44bc6eb

2 files changed

Lines changed: 63 additions & 28 deletions

File tree

test/EncodedConnectionTest.php

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
namespace Nats\tests\Unit;
33

44
use Nats;
5+
use Nats\Connection;
56
use Nats\ConnectionOptions;
6-
use Nats\EncodedConnection;
77
use Nats\Encoders\JSONEncoder;
88

99
/**
@@ -29,7 +29,7 @@ public function setUp()
2929
{
3030
$encoder = new JSONEncoder();
3131
$options = new ConnectionOptions();
32-
$this->c = new EncodedConnection($options, $encoder);
32+
$this->c = new Connection($options, $encoder);
3333
$this->c->connect();
3434
}
3535

@@ -88,30 +88,4 @@ function ($res) {
8888
}
8989
);
9090
}
91-
92-
/**
93-
* Test Request command.
94-
*
95-
* @return void
96-
*/
97-
public function testRequestArray()
98-
{
99-
$this->c->subscribe(
100-
'sayhello',
101-
function ($res) {
102-
$res->reply('Hello, '.$res->getBody()[1].' !!!');
103-
}
104-
);
105-
106-
$this->c->request(
107-
'sayhello',
108-
[
109-
'foo',
110-
'McFly',
111-
],
112-
function ($res) {
113-
$this->assertEquals('Hello, McFly !!!', $res->getBody());
114-
}
115-
);
116-
}
11791
}

test/JSONEncoderTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
namespace Nats\tests\Unit;
3+
4+
use Nats;
5+
use Nats\ConnectionOptions;
6+
use Nats\EncodedConnection;
7+
use Nats\Encoders\JSONEncoder;
8+
9+
/**
10+
* Class JSONEncoderTest.
11+
*/
12+
class JSONEncoderTest extends \PHPUnit_Framework_TestCase
13+
{
14+
15+
/**
16+
* Client.
17+
*
18+
* @var Nats\Connection Client
19+
*/
20+
private $c;
21+
22+
23+
/**
24+
* SetUp test suite.
25+
*
26+
* @return void
27+
*/
28+
public function setUp()
29+
{
30+
$encoder = new JSONEncoder();
31+
$options = new ConnectionOptions();
32+
$this->c = new EncodedConnection($options, $encoder);
33+
$this->c->connect();
34+
}
35+
36+
/**
37+
* Test Request command.
38+
*
39+
* @return void
40+
*/
41+
public function testRequestArray()
42+
{
43+
$this->c->subscribe(
44+
'sayhello',
45+
function ($res) {
46+
$res->reply('Hello, '.$res->getBody()[1].' !!!');
47+
}
48+
);
49+
50+
$this->c->request(
51+
'sayhello',
52+
[
53+
'foo',
54+
'McFly',
55+
],
56+
function ($res) {
57+
$this->assertEquals('Hello, McFly !!!', $res->getBody());
58+
}
59+
);
60+
}
61+
}

0 commit comments

Comments
 (0)