Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Smith committed Nov 25, 2015
1 parent 7620710 commit dc30be7
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/wormling/phparia/Tests/Functional/Api/AriClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace {

use phparia\Events\StasisStart;
use phparia\Tests\Functional\PhpariaTestCase;
use React\EventLoop\LoopInterface;
use Zend\Log\LoggerInterface;
Expand All @@ -26,5 +27,48 @@ public function canGetLogger()
$wsClient = $this->client->getAriClient()->getLogger();

$this->assertTrue($wsClient instanceof LoggerInterface);
} }
}

/**
* @test
*/
public function canCallOnHandshake()
{
$success = false;
$this->client->onStasisStart(function (StasisStart $event) use (&$success) {
$event->getChannel()->answer();
$this->client->stop();
});
$this->client->getAriClient()->onHandshake(function() use (&$success) {
$success = true;
});
$this->client->getAriClient()->onConnect(function () {
$this->client->channels()->createChannel($this->dialString, null, null, null, null,
$this->client->getStasisApplicationName());
});
$this->client->run();
$this->assertTrue($success);
}

/**
* @test
*/
public function canCallOnRequest()
{
$success = false;
$this->client->onStasisStart(function (StasisStart $event) use (&$success) {
$event->getChannel()->answer();
$this->client->stop();
});
$this->client->getAriClient()->onRequest(function() use (&$success) {
$success = true;
});
$this->client->getAriClient()->onConnect(function () {
$this->client->channels()->createChannel($this->dialString, null, null, null, null,
$this->client->getStasisApplicationName());
});
$this->client->run();
$this->assertTrue($success);
}
}
}

0 comments on commit dc30be7

Please sign in to comment.