Skip to content

Commit

Permalink
Merge branch 'release/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tidal committed Oct 1, 2016
2 parents 3198a59 + 386a242 commit ddecd1a
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 60 deletions.
17 changes: 17 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
engines:
duplication:
enabled: true
config:
languages:
- php
fixme:
enabled: true
phpmd:
enabled: true
ratings:
paths:
- "**.php"
exclude_paths:
- tests/
- examples/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

### [0.5.1] - 2016-10-01

* added integration test for subscription monitor
* added configuration for codeclimate
* bug fixes

### [0.5.0] - 2016-09-28

* added DeferredInterface
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ WAMP router meta-events
([registration](https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02#section-13.3.7),
[subscription](https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02#section-13.6.3),
[session](https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02#section-13.7.1))


13 changes: 7 additions & 6 deletions src/Tidal/WampWatch/SubscriptionMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
use Tidal\WampWatch\ClientSessionInterface as ClientSession;

/**
* Description of SessionMonitor.
*
* @author Timo
* Class SubscriptionMonitor.
*/
class SubscriptionMonitor implements MonitorInterface
{
Expand Down Expand Up @@ -138,15 +136,18 @@ protected function getList()

protected function getSubscriptionIdRetrievalCallback()
{
return function ($res) {
$this->setList($res);
return function (\Thruway\CallResult $res) {
/** @var \Thruway\Message\ResultMessage $message */
$message = $res->getResultMessage();
$list = $message->getArguments()[0];
$this->setList($list);
$this->emit('list', [
$this->subscriptionIds->exact,
$this->subscriptionIds->prefix,
$this->subscriptionIds->wildcard,
]);

return $res;
return $list;
};
}
}
75 changes: 75 additions & 0 deletions tests/integration/crossbar/CrossbarTestingTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
*
* * This file is part of the Tidal/WampWatch package.
* * (c) 2016 Timo Michna <timomichna/yahoo.de>
* *
* * For the full copyright and license information, please view the LICENSE
* * file that was distributed with this source code.
*
*/

namespace integration\crossbar;

use Psr\Log\NullLogger;
use Thruway\Logging\Logger;
use Thruway\Connection;
use React\EventLoop\Factory as LoopFactory;
use React\EventLoop\LoopInterface;

trait CrossbarTestingTrait
{
/**
* @var Connection
*/
private $connection;

/**
* @var LoopInterface
*/
private $loop;

/**
* @var int
*/
private $clientSessionId = -1;

/**
* @var int
*/
private $monitoredSessionId = -2;

private function setupConnection()
{

$this->clientSessionId = -1;
$this->monitoredSessionId = -2;

Logger::set(new NullLogger());

$this->loop = LoopFactory::create();

$this->connection = $this->createConnection($this->loop);

}

/**
* @param \React\EventLoop\LoopInterface|null $loop
*
* @return \Thruway\Connection
*/
private function createConnection(LoopInterface $loop = null)
{
if ($loop === null) {
$loop = LoopFactory::create();
}

return new Connection(
[
'realm' => self::REALM_NAME,
'url' => self::ROUTER_URL,
],
$loop
);
}
}
57 changes: 7 additions & 50 deletions tests/integration/crossbar/CrosssbarSessionMonitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,31 @@
namespace integration\crossbar;

require_once realpath(__DIR__ . "/../..") . "/bootstrap.php";
require_once __DIR__ . "/CrossbarTestingTrait.php";


use Psr\Log\NullLogger;
use Thruway\Logging\Logger;
use Thruway\ClientSession;
use Thruway\Connection;
use React\EventLoop\Factory as LoopFactory;
use React\EventLoop\LoopInterface;
use Tidal\WampWatch\SessionMonitor;
use Tidal\WampWatch\Adapter\Thruway\ClientSession as Adapter;

class CrosssbarSessionMonitorTest extends \PHPUnit_Framework_TestCase
{
use CrossbarTestingTrait;

const REALM_NAME = 'realm1';

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

/**
* @var Connection
*/
private $connection;

/**
* @var LoopInterface
*
*/
private $loop;

/**
* @var int
*/
private $clientSessionId = -1;

/**
* @var int
*/
private $monitoredSessionId = -2;

public function setup()
{

$this->clientSessionId = -1;
$this->monitoredSessionId = -2;

Logger::set(new NullLogger());

$this->loop = LoopFactory::create();

$this->connection = $this->createConnection($this->loop);

$this->setupConnection();
}


/**
*
*/
public function test_onstart()
{

Expand Down Expand Up @@ -176,19 +148,4 @@ public function test_onleave()

}

private function createConnection(LoopInterface $loop = null)
{
if ($loop = null) {
$loop = LoopFactory::create();
}

return new Connection(
[
'realm' => self::REALM_NAME,
'url' => self::ROUTER_URL,
],
$loop
);
}

}
Loading

0 comments on commit ddecd1a

Please sign in to comment.