]> git.mxchange.org Git - friendica.git/commitdiff
Add API test case for notification
authornupplaPhil <admin@philipp.info>
Tue, 28 Jan 2020 21:00:21 +0000 (22:00 +0100)
committernupplaPhil <admin@philipp.info>
Tue, 28 Jan 2020 21:00:21 +0000 (22:00 +0100)
src/Repository/Notify.php
tests/datasets/api.fixture.php
tests/include/ApiTest.php

index ba00d26fa72311efa8956b5bc054223bd77498a2..8c71fc289a1bd830b08515db4b16e1ef0e57896f 100644 (file)
@@ -37,8 +37,6 @@ class Notify extends BaseRepository
        {
                $params['order'] = $params['order'] ?? ['date' => 'DESC'];
 
-               $condition = array_merge($condition, ['uid' => local_user()]);
-
                return parent::select($condition, $params);
        }
 
index 475fa03854a06fb9edd1243e0cac8f9429f5c717..44501d0493f1f5dbed3bbb6b9f0900ffd7744117 100644 (file)
@@ -189,6 +189,25 @@ return [
                        'origin'      => 1,
                ],
        ],
+       'notify' => [
+               [
+                       'id' => 1,
+                       'type' => 8,
+                       'name' => 'Reply to',
+                       'url' => 'http://localhost/display/1',
+                       'photo' => 'http://localhost/',
+                       'date' => '2020-01-01 12:12:02',
+                       'msg' => 'A test reply from an item',
+                       'uid' => 42,
+                       'link' => 'http://localhost/notification/1',
+                       'iid' => 4,
+                       'seen' => 0,
+                       'verb' => '',
+                       'otype' => 'item',
+                       'name_cache' => 'Reply to',
+                       'msg_cache' => 'A test reply from an item',
+               ],
+       ],
        'thread'  => [
                [
                        'iid'        => 1,
index 466248f652e5dbdcaa940bcd517435e39c23c362..3ef64b3171653664f93e0abe2b9f3833099afc03 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Core\Session;
 use Friendica\Core\Session\ISession;
 use Friendica\Core\System;
 use Friendica\Database\Database;
+use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Network\HTTPException;
@@ -3916,14 +3917,15 @@ class ApiTest extends DatabaseTest
        }
 
        /**
-        * Test the api_friendica_notification() function with an argument count.
+        * Test the api_friendica_notification() function with empty result
         *
         * @return void
         */
-       public function testApiFriendicaNotificationWithArgumentCount()
+       public function testApiFriendicaNotificationWithEmptyResult()
        {
                $this->app->argv = ['api', 'friendica', 'notification'];
                $this->app->argc = count($this->app->argv);
+               $_SESSION['uid'] = 41;
                $result          = api_friendica_notification('json');
                $this->assertEquals(['note' => false], $result);
        }
@@ -3938,7 +3940,26 @@ class ApiTest extends DatabaseTest
                $this->app->argv = ['api', 'friendica', 'notification'];
                $this->app->argc = count($this->app->argv);
                $result          = api_friendica_notification('xml');
-               $this->assertXml($result, 'notes');
+               $assertXml=<<<XML
+<?xml version="1.0"?>
+<notes>
+  <note id="1" hash="" type="8" name="Reply to" url="http://localhost/display/1" photo="http://localhost/" date="2020-01-01 12:12:02" msg="A test reply from an item" uid="42" link="http://localhost/notification/1" iid="4" parent="0" seen="0" verb="" otype="item" name_cache="" msg_cache="A test reply from an item" timestamp="1577880722" date_rel="4 weeks ago" msg_html="A test reply from an item" msg_plain="A test reply from an item"/>
+</notes>
+XML;
+               $this->assertXmlStringEqualsXmlString($assertXml, $result);
+       }
+
+       /**
+        * Test the api_friendica_notification() function with an JSON result.
+        *
+        * @return void
+        */
+       public function testApiFriendicaNotificationWithJsonResult()
+       {
+               $this->app->argv = ['api', 'friendica', 'notification'];
+               $this->app->argc = count($this->app->argv);
+               $result          = json_encode(api_friendica_notification('json'));
+               $this->assertJson($result);
        }
 
        /**