* @copyright 2014 Fabian Grutschus. All rights reserved. * @license BSD * @link http://github.com/fabiang/xmpp */ namespace Fabiang\Xmpp\Integration; use Behat\Behat\Context\BehatContext; use Behat\Behat\Exception\PendingException; use Fabiang\Xmpp\EventListener\Stream\Session; class SessionContext extends BehatContext { /** * * @var Session */ protected $listener; /** * @Given /^Test response data for session$/ */ public function testResponseDataForSession() { $this->getConnection()->setData(array( "" . "", "", "" )); } /** * @Given /^Test response data for empty session$/ */ public function testResponseDataForEmptySession() { $this->getConnection()->setData(array( "" . "", "", "" )); } /** * @Given /^manipulating id$/ */ public function manipulatingId() { $listeners = $this->getConnection()->getInputStream()->getEventManager()->getEventList(); $listener = array_filter($listeners['{jabber:client}iq'], function ($listener) { return ($listener[0] instanceof Session); }); $this->listener = $listener[0][0]; $this->listener->setId('fabiang_xmpp_1234'); } /** * @Then /^request for session send$/ */ public function requestForSessionSend() { $buffer = $this->getConnection()->getBuffer(); assertRegExp( '#^$#', $buffer[1] ); } /** * @Then /^session listener is not blocking$/ */ public function sessionListenerIsNotBlocking() { assertFalse($this->listener->isBlocking()); } /** * * @return \Fabiang\Xmpp\Connection\Test */ public function getConnection() { return $this->getMainContext()->getConnection(); } }