Merge branch 'refs/heads/easen'

This commit is contained in:
Chris Boden 2014-04-19 10:37:17 -04:00
commit f25e030779
2 changed files with 12 additions and 2 deletions

View File

@ -77,8 +77,11 @@ class TopicManager implements WsServerInterface, WampServerInterface {
public function onClose(ConnectionInterface $conn) { public function onClose(ConnectionInterface $conn) {
$this->app->onClose($conn); $this->app->onClose($conn);
foreach ($this->topicLookup as $topic) { foreach ($this->topicLookup as $topic => $storage) {
$topic->remove($conn); $storage->remove($conn);
if (0 === $storage->count()) {
unset($this->topicLookup[$topic]);
}
} }
} }

View File

@ -166,12 +166,19 @@ class TopicManagerTest extends \PHPUnit_Framework_TestCase {
$method = $class->getMethod('getTopic'); $method = $class->getMethod('getTopic');
$method->setAccessible(true); $method->setAccessible(true);
$attribute = $class->getProperty('topicLookup');
$attribute->setAccessible(true);
$topic = $method->invokeArgs($this->mngr, array($name)); $topic = $method->invokeArgs($this->mngr, array($name));
$this->assertCount(1, $attribute->getValue($this->mngr));
$this->mngr->onSubscribe($this->conn, $name); $this->mngr->onSubscribe($this->conn, $name);
$this->mngr->onClose($this->conn); $this->mngr->onClose($this->conn);
$this->assertFalse($topic->has($this->conn)); $this->assertFalse($topic->has($this->conn));
$this->assertCount(0, $attribute->getValue($this->mngr));
} }
public function testOnErrorBubbles() { public function testOnErrorBubbles() {