]> git.mxchange.org Git - friendica.git/blobdiff - tests/include/ApiTest.php
Fix faulty test expectation in ApiTest->testApiFriendicaNotificationWithXmlResult
[friendica.git] / tests / include / ApiTest.php
index 6920ea2bf2f45272f218ddf418c0e9c38d101d69..a65283b2f1dd360972e188247026d44b767a4a0c 100644 (file)
@@ -12,13 +12,13 @@ use Friendica\Core\PConfig\IPConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\Session;
 use Friendica\Core\Session\ISession;
-use Friendica\Core\System;
 use Friendica\Database\Database;
-use Friendica\Database\DBA;
+use Friendica\Database\DBStructure;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Network\HTTPException;
 use Friendica\Test\Util\Database\StaticDatabase;
+use Friendica\Util\Temporal;
 use Monolog\Handler\TestHandler;
 
 require_once __DIR__ . '/../../include/api.php';
@@ -70,6 +70,10 @@ class ApiTest extends DatabaseTest
                /** @var Database $dba */
                $dba = $this->dice->create(Database::class);
 
+               $dba->setTestmode(true);
+
+               DBStructure::checkInitialValues();
+
                /** @var IConfig $config */
                $this->config = $this->dice->create(IConfig::class);
 
@@ -3844,10 +3848,11 @@ class ApiTest extends DatabaseTest
                $this->app->argv = ['api', 'friendica', 'notification'];
                $this->app->argc = count($this->app->argv);
                $result          = api_friendica_notification('xml');
+               $dateRel = Temporal::getRelativeDate('2020-01-01 12:12:02');
                $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"/>
+  <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" uri-id="" link="http://localhost/notification/1" iid="4" parent="0" parent-uri-id="" seen="0" verb="" otype="item" name_cache="Reply to" msg_cache="A test reply from an item" timestamp="1577880722" date_rel="{$dateRel}" msg_html="A test reply from an item" msg_plain="A test reply from an item"/>
 </notes>
 XML;
                $this->assertXmlStringEqualsXmlString($assertXml, $result);
@@ -3896,58 +3901,6 @@ XML;
                $this->markTestIncomplete();
        }
 
-       /**
-        * Test the api_friendica_profile_show() function.
-        *
-        * @return void
-        */
-       public function testApiFriendicaProfileShow()
-       {
-               $result = api_friendica_profile_show('json');
-               // We can't use assertSelfUser() here because the user object is missing some properties.
-               $this->assertEquals($this->selfUser['id'], $result['$result']['friendica_owner']['cid']);
-               $this->assertEquals('DFRN', $result['$result']['friendica_owner']['location']);
-               $this->assertEquals($this->selfUser['name'], $result['$result']['friendica_owner']['name']);
-               $this->assertEquals($this->selfUser['nick'], $result['$result']['friendica_owner']['screen_name']);
-               $this->assertEquals('dfrn', $result['$result']['friendica_owner']['network']);
-               $this->assertTrue($result['$result']['friendica_owner']['verified']);
-               $this->assertFalse($result['$result']['multi_profiles']);
-       }
-
-       /**
-        * Test the api_friendica_profile_show() function with a profile ID.
-        *
-        * @return void
-        */
-       public function testApiFriendicaProfileShowWithProfileId()
-       {
-               $this->markTestIncomplete('We need to add a dataset for this.');
-       }
-
-       /**
-        * Test the api_friendica_profile_show() function with a wrong profile ID.
-        *
-        * @return void
-        * @expectedException Friendica\Network\HTTPException\BadRequestException
-        */
-       public function testApiFriendicaProfileShowWithWrongProfileId()
-       {
-               $_REQUEST['profile_id'] = 666;
-               api_friendica_profile_show('json');
-       }
-
-       /**
-        * Test the api_friendica_profile_show() function without an authenticated user.
-        *
-        * @return void
-        * @expectedException Friendica\Network\HTTPException\ForbiddenException
-        */
-       public function testApiFriendicaProfileShowWithoutAuthenticatedUser()
-       {
-               $_SESSION['authenticated'] = false;
-               api_friendica_profile_show('json');
-       }
-
        /**
         * Test the api_saved_searches_list() function.
         *