Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-09-30 10:41:22 +0300
committerJoas Schilling <coding@schilljs.com>2020-10-01 15:13:18 +0300
commit938c005d1a6d87a31060d164ff7dbe3edf72510a (patch)
tree734a37b62383e15bd3f44f12f042c26e2dd1183e
parent0e66c054cb851bb198e51dafd780d5f70941f566 (diff)
Add a comment for the array check
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/Push.php3
-rw-r--r--tests/Unit/PushTest.php43
2 files changed, 25 insertions, 21 deletions
diff --git a/lib/Push.php b/lib/Push.php
index 806f1a6..c3f6405 100644
--- a/lib/Push.php
+++ b/lib/Push.php
@@ -22,6 +22,8 @@
namespace OCA\Notifications;
+use GuzzleHttp\Exception\ClientException;
+use GuzzleHttp\Exception\ServerException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\IProvider;
use OC\Security\IdentityProof\Key;
@@ -297,6 +299,7 @@ class Push {
if (is_array($bodyData) && isset($bodyData['unknown'], $bodyData['failed'])) {
if (is_array($bodyData['unknown'])) {
+ // Proxy returns null when the array is empty
foreach ($bodyData['unknown'] as $unknownDevice) {
$this->printInfo('Deleting device because it is unknown by the push server: ' . $unknownDevice);
$this->deletePushTokenByDeviceIdentifier($unknownDevice);
diff --git a/tests/Unit/PushTest.php b/tests/Unit/PushTest.php
index c0a725c..f05be9c 100644
--- a/tests/Unit/PushTest.php
+++ b/tests/Unit/PushTest.php
@@ -23,6 +23,8 @@
namespace OCA\Notifications\Tests\Unit;
+use GuzzleHttp\Exception\ClientException;
+use GuzzleHttp\Exception\ServerException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\IProvider;
use OC\Security\IdentityProof\Key;
@@ -407,7 +409,7 @@ class PushTest extends TestCase {
/** @var INotification|MockObject $notification */
$notification = $this->createMock(INotification::class);
- $notification->expects($this->exactly(3))
+ $notification
->method('getUser')
->willReturn('valid');
@@ -454,10 +456,9 @@ class PushTest extends TestCase {
],
]);
- $this->config->expects($this->exactly(2))
+ $this->config->expects($this->exactly(1))
->method('getSystemValue')
->willReturnMap([
- ['debug', false, $isDebug],
['force_language', false, false],
]);
@@ -506,10 +507,10 @@ class PushTest extends TestCase {
$client->expects($this->at(0))
->method('post')
->with('proxyserver1/notifications', [
- 'body' => [
- 'notifications' => ['["Payload"]', '["Payload"]'],
- ],
- ])
+ 'body' => [
+ 'notifications' => ['["Payload"]', '["Payload"]'],
+ ],
+ ])
->willThrowException($e);
$this->logger->expects($this->at(0))
@@ -533,11 +534,11 @@ class PushTest extends TestCase {
$client->expects($this->at(1))
->method('post')
->with('badrequest/notifications', [
- 'body' => [
- 'notifications' => ['["Payload"]'],
- ],
- ])
- ->willReturn($response1);
+ 'body' => [
+ 'notifications' => ['["Payload"]'],
+ ],
+ ])
+ ->willThrowException($e);
$this->logger->expects($this->at(1))
->method('warning')
@@ -558,11 +559,11 @@ class PushTest extends TestCase {
$client->expects($this->at(2))
->method('post')
->with('unavailable/notifications', [
- 'body' => [
- 'notifications' => ['["Payload"]'],
- ],
- ])
- ->willReturn($response2);
+ 'body' => [
+ 'notifications' => ['["Payload"]'],
+ ],
+ ])
+ ->willThrowException($e);
$this->logger->expects($this->at(2))
->method('debug')
@@ -580,10 +581,10 @@ class PushTest extends TestCase {
$client->expects($this->at(3))
->method('post')
->with('ok/notifications', [
- 'body' => [
- 'notifications' => ['["Payload"]'],
- ],
- ])
+ 'body' => [
+ 'notifications' => ['["Payload"]'],
+ ],
+ ])
->willReturn($response3);
/** @var IResponse|MockObject $response1 */