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

Commit 7c33f61

Browse files
committed
Added tests for PHP Encoder
1 parent fdef757 commit 7c33f61

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

test/Encoders/PHPEncoderTest.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\Encoders\Unit;
3+
4+
use Nats;
5+
use Nats\ConnectionOptions;
6+
use Nats\EncodedConnection;
7+
use Nats\Encoders\PHPEncoder;
8+
9+
/**
10+
* Class PHPEncoderTest.
11+
*/
12+
class PHPEncoderTest 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 PHPEncoder();
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)