Skip to content

Commit ddecd1a

Browse files
committed
Merge branch 'release/0.5.1'
2 parents 3198a59 + 386a242 commit ddecd1a

File tree

8 files changed

+486
-60
lines changed

8 files changed

+486
-60
lines changed

.codeclimate.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
engines:
3+
duplication:
4+
enabled: true
5+
config:
6+
languages:
7+
- php
8+
fixme:
9+
enabled: true
10+
phpmd:
11+
enabled: true
12+
ratings:
13+
paths:
14+
- "**.php"
15+
exclude_paths:
16+
- tests/
17+
- examples/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11

2+
### [0.5.1] - 2016-10-01
3+
4+
* added integration test for subscription monitor
5+
* added configuration for codeclimate
6+
* bug fixes
7+
28
### [0.5.0] - 2016-09-28
39

410
* added DeferredInterface

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ WAMP router meta-events
1313
([registration](https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02#section-13.3.7),
1414
[subscription](https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02#section-13.6.3),
1515
[session](https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02#section-13.7.1))
16+
1617

src/Tidal/WampWatch/SubscriptionMonitor.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
use Tidal\WampWatch\ClientSessionInterface as ClientSession;
1616

1717
/**
18-
* Description of SessionMonitor.
19-
*
20-
* @author Timo
18+
* Class SubscriptionMonitor.
2119
*/
2220
class SubscriptionMonitor implements MonitorInterface
2321
{
@@ -138,15 +136,18 @@ protected function getList()
138136

139137
protected function getSubscriptionIdRetrievalCallback()
140138
{
141-
return function ($res) {
142-
$this->setList($res);
139+
return function (\Thruway\CallResult $res) {
140+
/** @var \Thruway\Message\ResultMessage $message */
141+
$message = $res->getResultMessage();
142+
$list = $message->getArguments()[0];
143+
$this->setList($list);
143144
$this->emit('list', [
144145
$this->subscriptionIds->exact,
145146
$this->subscriptionIds->prefix,
146147
$this->subscriptionIds->wildcard,
147148
]);
148149

149-
return $res;
150+
return $list;
150151
};
151152
}
152153
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
*
4+
* * This file is part of the Tidal/WampWatch package.
5+
* * (c) 2016 Timo Michna <timomichna/yahoo.de>
6+
* *
7+
* * For the full copyright and license information, please view the LICENSE
8+
* * file that was distributed with this source code.
9+
*
10+
*/
11+
12+
namespace integration\crossbar;
13+
14+
use Psr\Log\NullLogger;
15+
use Thruway\Logging\Logger;
16+
use Thruway\Connection;
17+
use React\EventLoop\Factory as LoopFactory;
18+
use React\EventLoop\LoopInterface;
19+
20+
trait CrossbarTestingTrait
21+
{
22+
/**
23+
* @var Connection
24+
*/
25+
private $connection;
26+
27+
/**
28+
* @var LoopInterface
29+
*/
30+
private $loop;
31+
32+
/**
33+
* @var int
34+
*/
35+
private $clientSessionId = -1;
36+
37+
/**
38+
* @var int
39+
*/
40+
private $monitoredSessionId = -2;
41+
42+
private function setupConnection()
43+
{
44+
45+
$this->clientSessionId = -1;
46+
$this->monitoredSessionId = -2;
47+
48+
Logger::set(new NullLogger());
49+
50+
$this->loop = LoopFactory::create();
51+
52+
$this->connection = $this->createConnection($this->loop);
53+
54+
}
55+
56+
/**
57+
* @param \React\EventLoop\LoopInterface|null $loop
58+
*
59+
* @return \Thruway\Connection
60+
*/
61+
private function createConnection(LoopInterface $loop = null)
62+
{
63+
if ($loop === null) {
64+
$loop = LoopFactory::create();
65+
}
66+
67+
return new Connection(
68+
[
69+
'realm' => self::REALM_NAME,
70+
'url' => self::ROUTER_URL,
71+
],
72+
$loop
73+
);
74+
}
75+
}

tests/integration/crossbar/CrosssbarSessionMonitorTest.php

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,31 @@
33
namespace integration\crossbar;
44

55
require_once realpath(__DIR__ . "/../..") . "/bootstrap.php";
6+
require_once __DIR__ . "/CrossbarTestingTrait.php";
67

7-
8-
use Psr\Log\NullLogger;
9-
use Thruway\Logging\Logger;
108
use Thruway\ClientSession;
11-
use Thruway\Connection;
12-
use React\EventLoop\Factory as LoopFactory;
13-
use React\EventLoop\LoopInterface;
149
use Tidal\WampWatch\SessionMonitor;
1510
use Tidal\WampWatch\Adapter\Thruway\ClientSession as Adapter;
1611

1712
class CrosssbarSessionMonitorTest extends \PHPUnit_Framework_TestCase
1813
{
14+
use CrossbarTestingTrait;
1915

2016
const REALM_NAME = 'realm1';
2117

2218
const ROUTER_URL = 'ws://127.0.0.1:8080/ws';
2319

2420
/**
25-
* @var Connection
26-
*/
27-
private $connection;
28-
29-
/**
30-
* @var LoopInterface
21+
*
3122
*/
32-
private $loop;
33-
34-
/**
35-
* @var int
36-
*/
37-
private $clientSessionId = -1;
38-
39-
/**
40-
* @var int
41-
*/
42-
private $monitoredSessionId = -2;
43-
4423
public function setup()
4524
{
46-
47-
$this->clientSessionId = -1;
48-
$this->monitoredSessionId = -2;
49-
50-
Logger::set(new NullLogger());
51-
52-
$this->loop = LoopFactory::create();
53-
54-
$this->connection = $this->createConnection($this->loop);
55-
25+
$this->setupConnection();
5626
}
5727

58-
28+
/**
29+
*
30+
*/
5931
public function test_onstart()
6032
{
6133

@@ -176,19 +148,4 @@ public function test_onleave()
176148

177149
}
178150

179-
private function createConnection(LoopInterface $loop = null)
180-
{
181-
if ($loop = null) {
182-
$loop = LoopFactory::create();
183-
}
184-
185-
return new Connection(
186-
[
187-
'realm' => self::REALM_NAME,
188-
'url' => self::ROUTER_URL,
189-
],
190-
$loop
191-
);
192-
}
193-
194151
}

0 commit comments

Comments
 (0)