]> git.mxchange.org Git - friendica.git/blobdiff - tests/include/ApiTest.php
BBCode - fixed syntax error
[friendica.git] / tests / include / ApiTest.php
index d328c4cb5586dd7e6b13985875d6bd871d418972..cf7571073addfdd38397aef30b4377a80948cf1b 100644 (file)
@@ -11,6 +11,8 @@ use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Network\HTTPException;
+use Friendica\Util\LoggerFactory;
+use Monolog\Handler\TestHandler;
 
 require_once __DIR__ . '/../../include/api.php';
 
@@ -22,6 +24,11 @@ require_once __DIR__ . '/../../include/api.php';
  */
 class ApiTest extends DatabaseTest
 {
+       /**
+        * @var TestHandler Can handle log-outputs
+        */
+       protected $logOutput;
+
        /**
         * Create variables used by tests.
         */
@@ -30,6 +37,7 @@ class ApiTest extends DatabaseTest
                parent::setUp();
 
                $this->app = BaseObject::getApp();
+               $this->logOutput = LoggerFactory::enableTest($this->app->getLogger());
 
                // User data that the test database is populated with
                $this->selfUser = [
@@ -1391,34 +1399,48 @@ class ApiTest extends DatabaseTest
        }
 
        /**
-        * Test the api_search() function with friendica_tag 
+        * Test the api_search() function with an rpp parameter.
         * @return void
         */
-       public function testApiSearchWithFriendicaTag()
+       public function testApiSearchWithRpp()
        {
-               $_REQUEST['friendica_tag'] = 'friendica';
+               $_REQUEST['q'] = 'reply';
+               $_REQUEST['rpp'] = 20;
                $result = api_search('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
-                       $this->assertContains('#friendica', $status['text'], null, true);
+                       $this->assertContains('reply', $status['text'], null, true);
                }
        }
 
        /**
-        * Test the api_search() function with an rpp parameter.
+        * Test the api_search() function with an q parameter contains hashtag.
         * @return void
         */
-       public function testApiSearchWithRpp()
+       public function testApiSearchWithHashtag()
        {
-               $_REQUEST['q'] = 'reply';
-               $_REQUEST['rpp'] = 20;
+               $_REQUEST['q'] = '%23friendica';
                $result = api_search('json');
                foreach ($result['status'] as $status) {
                        $this->assertStatus($status);
-                       $this->assertContains('reply', $status['text'], null, true);
+                       $this->assertContains('#friendica', $status['text'], null, true);
                }
        }
 
+       /**
+        * Test the api_search() function with an exclude_replies parameter.
+        * @return void
+        */
+       public function testApiSearchWithExcludeReplies()
+       {
+               $_REQUEST['max_id'] = 10;
+               $_REQUEST['exclude_replies'] = true;
+               $_REQUEST['q'] = 'friendica';
+               $result = api_search('json');
+               foreach ($result['status'] as $status) {
+                       $this->assertStatus($status);
+               }
+       }
 
        /**
         * Test the api_search() function without an authenticated user.