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;
use Friendica\Test\Util\Database\StaticDatabase;
+use Friendica\Util\Temporal;
use Monolog\Handler\TestHandler;
require_once __DIR__ . '/../../include/api.php';
$this->assertArrayHasKey('friendica:attendmaybe', $result);
}
- /**
- * Test the api_format_items_profiles() function.
- *
- * @return void
- */
- public function testApiFormatItemsProfiles()
- {
- $profile_row = [
- 'id' => 'profile_id',
- 'profile-name' => 'profile_name',
- 'is-default' => true,
- 'hide-friends' => true,
- 'photo' => 'profile_photo',
- 'thumb' => 'profile_thumb',
- 'publish' => true,
- 'net-publish' => true,
- 'pdesc' => 'description',
- 'dob' => 'date_of_birth',
- 'address' => 'address',
- 'locality' => 'city',
- 'region' => 'region',
- 'postal-code' => 'postal_code',
- 'country-name' => 'country',
- 'hometown' => 'hometown',
- 'gender' => 'gender',
- 'marital' => 'marital',
- 'with' => 'marital_with',
- 'howlong' => 'marital_since',
- 'sexual' => 'sexual',
- 'politic' => 'politic',
- 'religion' => 'religion',
- 'pub_keywords' => 'public_keywords',
- 'prv_keywords' => 'private_keywords',
-
- 'likes' => 'likes',
- 'dislikes' => 'dislikes',
- 'about' => 'about',
- 'music' => 'music',
- 'book' => 'book',
- 'tv' => 'tv',
- 'film' => 'film',
- 'interest' => 'interest',
- 'romance' => 'romance',
- 'work' => 'work',
- 'education' => 'education',
- 'contact' => 'social_networks',
- 'homepage' => 'homepage'
- ];
- $result = api_format_items_profiles($profile_row);
- $this->assertEquals(
- [
- 'profile_id' => 'profile_id',
- 'profile_name' => 'profile_name',
- 'is_default' => true,
- 'hide_friends' => true,
- 'profile_photo' => 'profile_photo',
- 'profile_thumb' => 'profile_thumb',
- 'publish' => true,
- 'net_publish' => true,
- 'description' => 'description',
- 'date_of_birth' => 'date_of_birth',
- 'address' => 'address',
- 'city' => 'city',
- 'region' => 'region',
- 'postal_code' => 'postal_code',
- 'country' => 'country',
- 'hometown' => 'hometown',
- 'gender' => 'gender',
- 'marital' => 'marital',
- 'marital_with' => 'marital_with',
- 'marital_since' => 'marital_since',
- 'sexual' => 'sexual',
- 'politic' => 'politic',
- 'religion' => 'religion',
- 'public_keywords' => 'public_keywords',
- 'private_keywords' => 'private_keywords',
-
- 'likes' => 'likes',
- 'dislikes' => 'dislikes',
- 'about' => 'about',
- 'music' => 'music',
- 'book' => 'book',
- 'tv' => 'tv',
- 'film' => 'film',
- 'interest' => 'interest',
- 'romance' => 'romance',
- 'work' => 'work',
- 'education' => 'education',
- 'social_networks' => 'social_networks',
- 'homepage' => 'homepage',
- 'users' => null
- ],
- $result
- );
- }
-
/**
* Test the api_format_items() function.
*
}
/**
- * 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);
}
$this->app->argv = ['api', 'friendica', 'notification'];
$this->app->argc = count($this->app->argv);
$result = api_friendica_notification('xml');
- $this->assertXml($result, 'notes');
+ $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" uri-id="" link="http://localhost/notification/1" iid="4" parent="0" parent-uri-id="" seen="0" verb="" otype="item" name_cache="" 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);
}
/**
- * Test the api_friendica_notification_seen() function.
+ * Test the api_friendica_notification() function with an JSON result.
*
* @return void
*/
- public function testApiFriendicaNotificationSeen()
+ public function testApiFriendicaNotificationWithJsonResult()
{
- $this->markTestIncomplete();
+ $this->app->argv = ['api', 'friendica', 'notification'];
+ $this->app->argc = count($this->app->argv);
+ $result = json_encode(api_friendica_notification('json'));
+ $this->assertJson($result);
}
/**
- * Test the api_friendica_direct_messages_setseen() function.
+ * Test the api_friendica_notification_seen() function.
*
* @return void
*/
- public function testApiFriendicaDirectMessagesSetseen()
+ public function testApiFriendicaNotificationSeen()
{
$this->markTestIncomplete();
}
/**
- * Test the api_friendica_direct_messages_search() function.
+ * Test the api_friendica_direct_messages_setseen() function.
*
* @return void
*/
- public function testApiFriendicaDirectMessagesSearch()
+ public function testApiFriendicaDirectMessagesSetseen()
{
$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.
+ * Test the api_friendica_direct_messages_search() function.
*
* @return void
- * @expectedException Friendica\Network\HTTPException\ForbiddenException
*/
- public function testApiFriendicaProfileShowWithoutAuthenticatedUser()
+ public function testApiFriendicaDirectMessagesSearch()
{
- $_SESSION['authenticated'] = false;
- api_friendica_profile_show('json');
+ $this->markTestIncomplete();
}
/**