コード例 #1
0
ファイル: Test_Actions.php プロジェクト: wormling/PAMI
 private function _start(array $write, \PAMI\Message\Action\ActionMessage $action)
 {
     global $mock_stream_socket_client;
     global $mock_stream_set_blocking;
     global $mockTime;
     global $standardAMIStart;
     $mock_stream_socket_client = true;
     $mock_stream_set_blocking = true;
     $options = array('log4php.properties' => RESOURCES_DIR . DIRECTORY_SEPARATOR . 'log4php.properties', 'host' => '2.3.4.5', 'scheme' => 'tcp://', 'port' => 9999, 'username' => 'asd', 'secret' => 'asd', 'connect_timeout' => 10, 'read_timeout' => 10);
     $writeLogin = array("action: Login\r\nactionid: 1432.123\r\nusername: asd\r\nsecret: asd\r\n");
     setFgetsMock($standardAMIStart, $writeLogin);
     $client = new \PAMI\Client\Impl\ClientImpl($options);
     $client->open();
     if ($action instanceof \PAMI\Message\Action\DBGetAction) {
         $event = array('Response: Success', 'EventList: start', 'ActionID: 1432.123', '', 'Event: DBGetResponse', 'ActionID: 1432.123', '');
     } else {
         $event = array('Response: Success', 'ActionID: 1432.123', '');
     }
     setFgetsMock($event, $write);
     $result = $client->send($action);
     $this->assertTrue($result instanceof \PAMI\Message\Response\ResponseMessage);
     return $client;
 }
コード例 #2
0
ファイル: Test_Client.php プロジェクト: wormling/PAMI
 /**
  * @test
  */
 public function can_get_response_events_without_actionid_and_event()
 {
     global $mock_stream_socket_client;
     global $mock_stream_set_blocking;
     global $mockTime;
     global $standardAMIStart;
     $mockTime = true;
     $mock_stream_socket_client = true;
     $mock_stream_set_blocking = true;
     $options = array('log4php.properties' => RESOURCES_DIR . DIRECTORY_SEPARATOR . 'log4php.properties', 'host' => '2.3.4.5', 'scheme' => 'tcp://', 'port' => 9999, 'username' => 'asd', 'secret' => 'asd', 'connect_timeout' => 1000, 'read_timeout' => 1000);
     $write = array("action: Login\r\nactionid: 1432.123\r\nusername: asd\r\nsecret: asd\r\n");
     setFgetsMock($standardAMIStart, $write);
     $client = new \PAMI\Client\Impl\ClientImpl($options);
     $client->registerEventListener(new SomeListenerClass());
     $client->open();
     $event = array('Response: Success', 'ActionID: 1432.123', 'Eventlist: start', 'Message: Channels will follow', '', 'Channel: pepe', 'Count: Blah', '', 'Event: CoreShowChannelsComplete', 'EventList: Complete', 'ListItems: 0', 'ActionID: 1432.123', '');
     $write = array("action: CoreShowChannels\r\nactionid: 1432.123\r\n");
     setFgetsMock($event, $write);
     $result = $client->send(new \PAMI\Message\Action\CoreShowChannelsAction());
     $events = $result->getEvents();
     $this->assertEquals($events[0]->getName(), 'ResponseEvent');
     $this->assertEquals($events[0]->getKey('Channel'), 'pepe');
     $this->assertEquals($events[0]->getKey('Count'), 'Blah');
     $this->assertEquals($events[1]->getName(), 'CoreShowChannelsComplete');
     $this->assertEquals($events[1]->getListItems(), 0);
 }