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

Commit f510f29

Browse files
committed
Check subscription count on pub/sub
1 parent 53d397d commit f510f29

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

spec/Nats/ConnectionSpec.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,43 @@ function it_increases_reconnects_count_on_each_reconnection()
5656
$this->reconnect();
5757
$this->reconnectsCount()->shouldBe(1);
5858
$this->isConnected()->shouldBe(true);
59+
$this->close();
5960
}
6061

6162
function it_a_ping_is_sent_after_a_successful_connection()
6263
{
6364
$this->connect();
6465
$this->pingsCount()->shouldBe(1);
66+
$this->close();
67+
}
68+
69+
function it_increases_pubs_after_publishing_a_message()
70+
{
71+
$this->connect();
72+
$this->publish("foo");
73+
$this->pubsCount()->shouldBe(1);
74+
$this->close();
75+
}
76+
77+
function it_increases_subscriptions_after_subscribing_to_a_topic()
78+
{
79+
$this->connect();
80+
$callback = function($payload) {};
81+
$sid = $this->subscribe("foo", $callback);
82+
$this->subscriptionsCount()->shouldBe(1);
83+
$this->unsubscribe($sid);
84+
$this->close();
85+
}
86+
87+
function it_decreases_subscriptions_after_unsubscribing_to_a_topic()
88+
{
89+
$this->connect();
90+
$callback = function($payload) {};
91+
$sid = $this->subscribe("foo", $callback);
92+
$this->unsubscribe($sid);
93+
$this->subscriptionsCount()->shouldBe(0);
94+
$this->close();
6595
}
96+
97+
6698
}

0 commit comments

Comments
 (0)