diff options
author | Joachim Bauch <bauch@struktur.de> | 2018-01-30 14:28:43 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-02-02 13:43:00 +0300 |
commit | 2b1bc063427b876e2fa63f546e63feeaf46fdb29 (patch) | |
tree | b54233e505da0fdede61b561ae357edd48148e86 /lib/Signaling | |
parent | 882519342909d516954c601ff112a4c73c08cdca (diff) |
Add tests for "BackendNotifier".
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Diffstat (limited to 'lib/Signaling')
-rw-r--r-- | lib/Signaling/BackendNotifier.php | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index 8e64ec771..99489b75d 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -24,6 +24,7 @@ namespace OCA\Spreed\Signaling; use OCA\Spreed\Config; +use OCA\Spreed\Participant; use OCA\Spreed\Room; use OCP\Http\Client\IClientService; use OCP\ILogger; @@ -56,6 +57,20 @@ class BackendNotifier{ } /** + * Perform actual network request to the signaling backend. + * This can be overridden in tests. + */ + protected function doRequest($url, $params) { + if (defined('PHPUNIT_RUN')) { + // Don't perform network requests when running tests. + return; + } + + $client = $this->clientService->newClient(); + $client->post($url, $params); + } + + /** * Perform a request to the signaling backend. * * @param string $url @@ -77,7 +92,6 @@ class BackendNotifier{ } else if (strpos($url, 'ws://') === 0) { $url = 'http://' . substr($url, 5); } - $client = $this->clientService->newClient(); $body = json_encode($data); $headers = [ 'Content-Type' => 'application/json', @@ -92,10 +106,10 @@ class BackendNotifier{ 'headers' => $headers, 'body' => $body, ]; - if (!$signaling['verify']) { + if (!empty($signaling['verify'])) { $params['verify'] = false; } - $client->post($url, $params); + $this->doRequest($url, $params); } /** @@ -221,6 +235,9 @@ class BackendNotifier{ } } foreach ($participants['guests'] as $participant) { + if (!isset($participant['participantType'])) { + $participant['participantType'] = Participant::GUEST; + } if ($participant['inCall']) { $users[] = $participant; } |