示例#1
0
 /**
  * @test
  */
 public function can_example_mock()
 {
     $mock = new PAGI\Client\Impl\MockedClientImpl($this->_properties);
     $mock->assert('waitDigit', array(1000))->assert('streamFile', array('blah', '01234567890*#'))->assert('getData', array('blah', 123, '#'))->assert('sayDateTime', array('asd', 123))->assert('setVariable', array('asd', 'asd'))->assert('setCallerId', array('name', 'number'))->assert('playBusyTone')->assert('playDialTone')->assert('playCongestionTone')->assert('stopPlayingTones')->assert('playTone', array('some'))->assert('playCustomTones', array(1, 2, 3))->assert('amd', array())->onAnswer(true)->onWaitDigit(false)->onWaitDigit(true, '*')->onStreamFile(false)->onStreamFile(true, '#')->onGetData(false)->onGetData(true, '44449*#')->onSayDate(true, '#')->onSayTime(true, '#')->onSayDateTime(true, '#')->onSayAlpha(true, '#')->onSayPhonetic(true, '#')->onSayNumber(true, '#')->onSayDigits(true, '#')->onAmd('status', 'cause')->onHangup(true)->onChannelStatus(PAGI\Client\ChannelStatus::LINE_UP);
     $mock->answer();
     $mock->waitDigit(1000);
     $mock->waitDigit(1000);
     $mock->streamFile('blah', '01234567890*#');
     $mock->streamFile('blah', '01234567890*#');
     $mock->getData('blah', 123, '#');
     $mock->getData('blah', 123, '#');
     $mock->sayDate('asd', time());
     $mock->sayTime('asd', time());
     $mock->sayDateTime('asd', 123);
     $mock->sayAlpha('asd');
     $mock->sayPhonetic('asd');
     $mock->sayNumber(123);
     $mock->sayDigits(123);
     $mock->amd();
     $mock->hangup();
     $mock->channelStatus();
     $mock->setCallerId('name', 'number');
     $mock->playBusyTone();
     $mock->playDialTone();
     $mock->playCongestionTone();
     $mock->stopPlayingTones();
     $mock->playTone('some');
     $mock->playCustomTones(array(1, 2, 3));
     $mock->consoleLog("blah");
     $mock->log("blah");
     $mock->setVariable('asd', 'asd');
     $mock->setContext('context');
     $mock->setExtension('extension');
     $mock->setPriority(1);
     $mock->setMusic(true);
 }
示例#2
0
<?php

require_once 'PAGI/Autoloader/Autoloader.php';
PAGI\Autoloader\Autoloader::register();
require_once __DIR__ . '/../quickstart/MyPAGIApplication.php';
$variables = array('request' => 'request.php', 'channel' => 'SIP/blah-00803890', 'language' => 'ar', 'type' => 'SIP', 'uniqueid' => '1330012581.77', 'version' => '1.6.0.9', 'callerid' => '40', 'calleridname' => 'Admin', 'callingpres' => '1', 'callingani2' => '0', 'callington' => '0', 'callingtns' => '0', 'dnid' => '55555555', 'rdnis' => 'unknown', 'context' => 'default', 'extension' => '55555555', 'priority' => '1', 'enhanced' => '0.0', 'accountcode' => '', 'threadid' => '1095317840');
$mock = new PAGI\Client\Impl\MockedClientImpl(array('log4php.properties' => __DIR__ . '/../quickstart/log4php.properties', 'variables' => $variables));
$mock->assert('sayDigits', array('12345', '12#'))->assert('sayNumber', array('12345', '12#'))->onSayDigits(true, '1')->onSayNumber(true, '2')->onGetData(false)->onGetOption(true, '4')->onStreamFile(true, '#')->onChannelStatus(PAGI\Client\ChannelStatus::LINE_UP)->onChannelStatus(PAGI\Client\ChannelStatus::LINE_BUSY)->onGetVariable(true, 123)->onGetFullVariable(true, 456)->onGetFullVariable(true, 789)->onGetFullVariable(true, 'asd')->onGetFullVariable(true, '1')->onGetFullVariable(true, '2')->onGetFullVariable(true, '3')->onGetFullVariable(true, '4')->onGetFullVariable(true, '5')->onGetFullVariable(true, '6')->onGetFullVariable(true, '1')->onGetFullVariable(true, '2')->onGetFullVariable(true, '3')->onGetFullVariable(true, '4')->onGetFullVariable(true, '5')->onGetFullVariable(true, '6')->onGetFullVariable(true, '1')->onGetFullVariable(true, '2')->onGetFullVariable(true, '3')->onGetFullVariable(true, '4')->onGetFullVariable(true, '5')->onDial(true, 'name', 'number', '20', 'ANSWER', '#asd')->onSayPhonetic(true, '2')->onSayAlpha(true, '3')->onSayTime(true, '4')->onSayDateTime(true, '5')->onSayDate(true, '6')->onWaitDigit(true, '7')->onWaitDigit(true, '7')->onRecord(true, false, '#', 1000);
$app = new MyPAGIApplication(array('pagiClient' => $mock));
$app->init();
$app->run();
$app->shutdown();
示例#3
0
<?php

require __DIR__ . implode(DIRECTORY_SEPARATOR, array('', '..', '..', '..', 'vendor', 'autoload.php'));
$variables = array('request' => 'request.php', 'channel' => 'SIP/blah-00803890', 'language' => 'ar', 'type' => 'SIP', 'uniqueid' => '1330012581.77', 'version' => '1.6.0.9', 'callerid' => '40', 'calleridname' => 'Admin', 'callingpres' => '1', 'callingani2' => '0', 'callington' => '0', 'callingtns' => '0', 'dnid' => '55555555', 'rdnis' => 'unknown', 'context' => 'default', 'extension' => '55555555', 'priority' => '1', 'enhanced' => '0.0', 'accountcode' => '', 'threadid' => '1095317840');
$mock = new PAGI\Client\Impl\MockedClientImpl();
$mock->assert('waitDigit', array(1000))->assert('streamFile', array('blah', '01234567890*#'))->assert('dial', array('SIP/blah', array(60, 'tH')))->assert('getData', array('blah', 123, '#'))->assert('sayDateTime', array('asd', 123))->assert('setVariable', array('asd', 'asd'))->onAnswer(true)->onWaitDigit(false)->onWaitDigit(true, '*')->onStreamFile(false)->onStreamFile(true, '#')->onGetData(false)->onGetData(true, '44449*#')->onSayDate(true, '#')->onSayTime(true, '#')->onSayDateTime(true, '#')->onSayAlpha(true, '#')->onSayPhonetic(true, '#')->onSayNumber(true, '#')->onSayDigits(true, '#')->onDial(true, 'name', '01151992266', 20, 'ANSWER', '#blah')->onHangup(true);
var_dump($mock->answer());
var_dump($mock->setVariable('asd', 'asd'));
var_dump($mock->waitDigit(1000));
var_dump($mock->waitDigit(1000));
var_dump($mock->streamFile('blah', '01234567890*#'));
var_dump($mock->streamFile('blah', '01234567890*#'));
var_dump($mock->getData('blah', 123, '#'));
var_dump($mock->getData('blah', 123, '#'));
var_dump($mock->sayDate('asd', time()));
var_dump($mock->sayTime('asd', time()));
var_dump($mock->sayDateTime('asd', 123));
var_dump($mock->sayAlpha('asd'));
var_dump($mock->sayPhonetic('asd'));
var_dump($mock->sayNumber(123));
var_dump($mock->sayDigits(123));
var_dump($mock->dial('SIP/blah', array(60, 'tH')));
var_dump($mock->hangup());