/** * @param array $args - request arguments, i.e. $_POST * @param RTCStore $store * @return array [ * int $statusCode, * string $statusMsg, * RTCConnection $connection, * string[] $errors * ] * @throws \Exception */ public static function signal(array $args, RTCStore $store = null) { $call = ''; $name = ''; $connection = ''; extract($args, EXTR_IF_EXISTS); if ($store == null) { $store = RTCStore::instance(); } $signal = new Controller($store); switch ($call) { case self::CALL_OFFER: $signal->offer($name, $connection); break; case self::CALL_ANSWER: $signal->answer($name, $connection); break; case self::CALL_FETCH: $signal->fetch($name); break; default: $signal->error('invalid call', ['call' => "'call' parameter must be one of [\"" . implode('", "', self::getCalls()) . '"].']); break; } return $signal->getCallResult(); }
/** * @dataProvider successOfferProvider * @param string $name * @param string $connJson * @param integer $candidateCount - number of candidates to be added */ public function testOfferSuccess($name, $connJson, $candidateCount) { $this->storeMockBuilder->setMethods(['getOffer', 'save', 'addIceCandidate']); $store = $this->storeMockBuilder->getMock(); $store->expects($this->exactly($candidateCount))->method('addIceCandidate'); $this->adapter->expects($this->once())->method('save'); // do the process $this->controller = new Controller($store); $this->controller->offer($name, $connJson); // save succeeded list($code, $m, $conn, $e) = $this->controller->getCallResult(); $this->assertEquals(200, $code); $this->assertInstanceOf('DataFestivus\\RTCStore\\Connection', $conn); }