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

Commit 3794c8b

Browse files
author
Raül Pérez
committed
Merge branch 'release/0.0.2'
2 parents 02a8f51 + cc9f3fb commit 3794c8b

5 files changed

Lines changed: 91 additions & 8 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ cs:
1414
./phpcbf.phar tests
1515
./phpcbf.phar examples
1616
./phpcs.phar src tests examples
17+
18+
.PHONY: lint test cs cover

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.1
1+
0.0.2
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use Behat\Behat\Context\ClosuredContextInterface,
4+
Behat\Behat\Context\TranslatedContextInterface,
5+
Behat\Behat\Context\BehatContext,
6+
Behat\Behat\Exception\PendingException;
7+
use Behat\Gherkin\Node\PyStringNode,
8+
Behat\Gherkin\Node\TableNode;
9+
10+
//
11+
// Require 3rd-party libraries here:
12+
//
13+
// require_once 'PHPUnit/Autoload.php';
14+
// require_once 'PHPUnit/Framework/Assert/Functions.php';
15+
//
16+
17+
/**
18+
* Features context.
19+
*/
20+
class FeatureContext extends BehatContext
21+
{
22+
/**
23+
* Initializes context.
24+
* Every scenario gets it's own context object.
25+
*
26+
* @param array $parameters context parameters (set them up through behat.yml)
27+
*/
28+
public function __construct(array $parameters)
29+
{
30+
// Initialize your context here
31+
}
32+
33+
//
34+
// Place your definition and hook methods here:
35+
//
36+
// /**
37+
// * @Given /^I have done something with "([^"]*)"$/
38+
// */
39+
// public function iHaveDoneSomethingWith($argument)
40+
// {
41+
// doSomethingWith($argument);
42+
// }
43+
//
44+
}

src/Connection.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,6 @@ public function wait($quantity = 0)
282282
while (!feof($this->_fp)) {
283283
$line = $this->_receive();
284284

285-
// Debug
286-
if ($line) {
287-
echo ">>>>>>>>> " . $line . PHP_EOL;
288-
}
289-
290285
// PING
291286
if (strpos($line, 'PING') === 0) {
292287
$this->_send("PONG");

tests/Unit/ConnectionTest.php

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public function testPing()
5858
$c->connect();
5959
$c->ping();
6060
$c->ping();
61-
$this->assertGreaterThan(0, $c->pingsCount());
61+
$count = $c->pingsCount();
62+
$this->assertInternalType("int", $count);
63+
$this->assertGreaterThan(0, $count);
6264
$c->close();
6365
}
6466

@@ -72,7 +74,47 @@ public function testPublish()
7274
$c = new Nats\Connection();
7375
$c->connect();
7476
$c->publish("foo", "bar");
75-
$this->assertGreaterThan(0, $c->pubsCount());
77+
$count = $c->pubsCount();
78+
$this->assertInternalType("int", $count);
79+
$this->assertGreaterThan(0, $count);
7680
$c->close();
7781
}
82+
83+
/**
84+
* Test Server reconnection
85+
*
86+
* @return null
87+
*/
88+
public function testReconnect()
89+
{
90+
$c = new Nats\Connection();
91+
$c->connect();
92+
$c->reconnect();
93+
$count = $c->reconnectsCount();
94+
$this->assertInternalType("int", $count);
95+
$this->assertGreaterThan(0, $count);
96+
$c->close();
97+
}
98+
99+
/**
100+
* Test Server subscription
101+
*
102+
* @return null
103+
*/
104+
public function testSubscription()
105+
{
106+
$c = new Nats\Connection();
107+
$c->connect();
108+
$c->subscribe(
109+
"foo", function ($message) {
110+
$this->assertNotNull($message);
111+
}
112+
);
113+
$this->assertGreaterThan(0, $c->subscriptionsCount());
114+
$subscriptions = $c->getSubscriptions();
115+
$this->assertInternalType("array", $subscriptions);
116+
117+
$c->publish("foo", "bar");
118+
$c->wait(1);
119+
}
78120
}

0 commit comments

Comments
 (0)