1
0
Fork 0

Merge remote-tracking branch 'upstream/2021.12-rc' into remove-obsolete

This commit is contained in:
Michael 2021-12-07 07:30:28 +00:00
commit b2042253c4
45 changed files with 495 additions and 343 deletions

View file

@ -221,6 +221,16 @@ class ApiResponse extends Response
$this->addContent($return); $this->addContent($return);
} }
/**
* Wrapper around exit() for JSON only responses
*
* @param array $data
*/
public function exitWithJson(array $data)
{
$this->exit('content', ['content' => $data], static::TYPE_JSON);
}
/** /**
* Quit execution with the message that the endpoint isn't implemented * Quit execution with the message that the endpoint isn't implemented
* *

View file

@ -81,7 +81,7 @@ class Followers extends BaseApi
DBA::close($followers); DBA::close($followers);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($accounts); $accounts = array_reverse($accounts);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -81,7 +81,7 @@ class Following extends BaseApi
DBA::close($followers); DBA::close($followers);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($accounts); $accounts = array_reverse($accounts);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -113,7 +113,7 @@ class Statuses extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -52,6 +52,6 @@ class VerifyCredentials extends BaseApi
// @todo Support the source property, // @todo Support the source property,
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid); $account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
System::jsonExit($account); $this->response->exitWithJson($account->toArray());
} }
} }

View file

@ -81,7 +81,7 @@ class Blocks extends BaseApi
DBA::close($followers); DBA::close($followers);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($accounts); $accounts = array_reverse($accounts);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -77,7 +77,7 @@ class Bookmarks extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -91,7 +91,7 @@ class Conversations extends BaseApi
DBA::close($convs); DBA::close($convs);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($conversations); $conversations = array_reverse($conversations);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -73,7 +73,7 @@ class Favourited extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -100,7 +100,7 @@ class Accounts extends BaseApi
DBA::close($members); DBA::close($members);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($accounts); $accounts = array_reverse($accounts);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -81,7 +81,7 @@ class Mutes extends BaseApi
DBA::close($followers); DBA::close($followers);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($accounts); $accounts = array_reverse($accounts);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -105,7 +105,7 @@ class ScheduledStatuses extends BaseApi
DBA::close($posts); DBA::close($posts);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -167,7 +167,7 @@ class Search extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -75,7 +75,7 @@ class Direct extends BaseApi
} }
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -98,7 +98,7 @@ class Home extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -103,7 +103,7 @@ class ListTimeline extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -109,7 +109,7 @@ class PublicTimeline extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -112,7 +112,7 @@ class Tag extends BaseApi
DBA::close($items); DBA::close($items);
if (!empty($request['min_id'])) { if (!empty($request['min_id'])) {
array_reverse($statuses); $statuses = array_reverse($statuses);
} }
self::setLinkHeader(); self::setLinkHeader();

View file

@ -39,22 +39,22 @@ class UpdateProfile extends BaseApi
$api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray(); $api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray();
if (!empty($_POST['name'])) { if (!empty($request['name'])) {
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $uid]); DBA::update('profile', ['name' => $request['name']], ['uid' => $uid]);
DBA::update('user', ['username' => $_POST['name']], ['uid' => $uid]); DBA::update('user', ['username' => $request['name']], ['uid' => $uid]);
Contact::update(['name' => $_POST['name']], ['uid' => $uid, 'self' => 1]); Contact::update(['name' => $request['name']], ['uid' => $uid, 'self' => 1]);
Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]); Contact::update(['name' => $request['name']], ['id' => $api_user['id']]);
} }
if (isset($_POST['description'])) { if (isset($request['description'])) {
DBA::update('profile', ['about' => $_POST['description']], ['uid' => $uid]); DBA::update('profile', ['about' => $request['description']], ['uid' => $uid]);
Contact::update(['about' => $_POST['description']], ['uid' => $uid, 'self' => 1]); Contact::update(['about' => $request['description']], ['uid' => $uid, 'self' => 1]);
Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]); Contact::update(['about' => $request['description']], ['id' => $api_user['id']]);
} }
Profile::publishUpdate($uid); Profile::publishUpdate($uid);
$skip_status = $_REQUEST['skip_status'] ?? false; $skip_status = $request['skip_status'] ?? false;
$user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray();

View file

@ -79,7 +79,7 @@ class Ids extends ContactEndpoint
DBA::close($contacts); DBA::close($contacts);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($ids); $ids = array_reverse($ids);
} }
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids); $return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);

View file

@ -80,13 +80,13 @@ class Lists extends ContactEndpoint
DBA::close($contacts); DBA::close($contacts);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($ids); $ids = array_reverse($ids);
} }
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities); $return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
self::setLinkHeader(); self::setLinkHeader();
System::jsonExit($return); $this->response->exit('lists', ['lists' => $return]);
} }
} }

View file

@ -84,7 +84,7 @@ class Ids extends ContactEndpoint
DBA::close($followers); DBA::close($followers);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($ids); $ids = array_reverse($ids);
} }
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids); $return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);

View file

@ -85,13 +85,13 @@ class Lists extends ContactEndpoint
DBA::close($followers); DBA::close($followers);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($ids); $ids = array_reverse($ids);
} }
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities); $return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
self::setLinkHeader(); self::setLinkHeader();
System::jsonExit($return); $this->response->exit('lists', ['lists' => $return]);
} }
} }

View file

@ -84,7 +84,7 @@ class Ids extends ContactEndpoint
DBA::close($followers); DBA::close($followers);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($ids); $ids = array_reverse($ids);
} }
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids); $return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);

View file

@ -85,13 +85,13 @@ class Lists extends ContactEndpoint
DBA::close($followers); DBA::close($followers);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($ids); $ids = array_reverse($ids);
} }
$return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities); $return = self::list($ids, $total_count, $uid, $cursor, $count, $skip_status, $include_user_entities);
self::setLinkHeader(); self::setLinkHeader();
System::jsonExit($return); $this->response->exit('lists', ['lists' => $return]);
} }
} }

View file

@ -79,13 +79,13 @@ class Incoming extends ContactEndpoint
DBA::close($contacts); DBA::close($contacts);
if (!empty($min_id)) { if (!empty($min_id)) {
array_reverse($ids); $ids = array_reverse($ids);
} }
$return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids); $return = self::ids($ids, $total_count, $cursor, $count, $stringify_ids);
self::setLinkHeader(); self::setLinkHeader();
System::jsonExit($return); $this->response->exit('incoming', ['incoming' => $return]);
} }
} }

View file

@ -40,23 +40,23 @@ class Statuses extends BaseApi
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
$uid = BaseApi::getCurrentUserID(); $uid = BaseApi::getCurrentUserID();
if (empty($_REQUEST['list_id'])) { if (empty($request['list_id'])) {
throw new BadRequestException('list_id not specified'); throw new BadRequestException('list_id not specified');
} }
// params // params
$count = $_REQUEST['count'] ?? 20; $count = $request['count'] ?? 20;
$page = $_REQUEST['page'] ?? 1; $page = $request['page'] ?? 1;
$since_id = $_REQUEST['since_id'] ?? 0; $since_id = $request['since_id'] ?? 0;
$max_id = $_REQUEST['max_id'] ?? 0; $max_id = $request['max_id'] ?? 0;
$exclude_replies = (!empty($_REQUEST['exclude_replies']) ? 1 : 0); $exclude_replies = (!empty($request['exclude_replies']) ? 1 : 0);
$conversation_id = $_REQUEST['conversation_id'] ?? 0; $conversation_id = $request['conversation_id'] ?? 0;
$start = max(0, ($page - 1) * $count); $start = max(0, ($page - 1) * $count);
$groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => 1]); $groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
$gids = array_column($groups, 'contact-id'); $gids = array_column($groups, 'contact-id');
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'group-id' => $gids]; $condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
$condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]); $condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
if ($max_id > 0) { if ($max_id > 0) {
@ -75,7 +75,7 @@ class Statuses extends BaseApi
$params = ['order' => ['id' => true], 'limit' => [$start, $count]]; $params = ['order' => ['id' => true], 'limit' => [$start, $count]];
$statuses = Post::selectForUser($uid, [], $condition, $params); $statuses = Post::selectForUser($uid, [], $condition, $params);
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); $include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
$items = []; $items = [];
while ($status = DBA::fetch($statuses)) { while ($status = DBA::fetch($statuses)) {

View file

@ -437,6 +437,13 @@ class Transmitter
return []; return [];
} }
$permissions = [
'to' => [],
'cc' => [],
'bto' => [],
'bcc' => [],
];
$activity = json_decode($conversation['source'], true); $activity = json_decode($conversation['source'], true);
$actor = JsonLD::fetchElement($activity, 'actor', 'id'); $actor = JsonLD::fetchElement($activity, 'actor', 'id');

View file

@ -36,7 +36,7 @@ return [
'mail', 'mail',
'post-delivery-data', 'post-delivery-data',
// Base test config to avoid notice messages // Base test config to avoid notice messages
'config' => [ 'config' => [
[ [
'cat' => 'system', 'cat' => 'system',
'k' => 'url', 'k' => 'url',
@ -63,7 +63,7 @@ return [
'v' => '1', 'v' => '1',
], ],
], ],
'user' => [ 'user' => [
[ [
'uid' => 42, 'uid' => 42,
'username' => 'Test user', 'username' => 'Test user',
@ -73,7 +73,7 @@ return [
'theme' => 'frio', 'theme' => 'frio',
], ],
], ],
'item-uri' => [ 'item-uri' => [
[ [
'id' => 1, 'id' => 1,
'uri' => '1', 'uri' => '1',
@ -128,100 +128,149 @@ return [
], ],
'contact' => [ 'contact' => [
[ [
'id' => 42, 'id' => 42,
'uid' => 42, 'uid' => 42,
'uri-id' => 42, 'uri-id' => 42,
'name' => 'Self contact', 'name' => 'Self contact',
'nick' => 'selfcontact', 'nick' => 'selfcontact',
'self' => 1, 'self' => 1,
'nurl' => 'http://localhost/profile/selfcontact', 'nurl' => 'http://localhost/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact', 'url' => 'http://localhost/profile/selfcontact',
'about' => 'User used in tests', 'about' => 'User used in tests',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::FOLLOWER, 'rel' => Contact::FOLLOWER,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
], ],
// Having the same name and nick allows us to test // Having the same name and nick allows us to test
// the fallback to api_get_nick() in api_get_user() // the fallback to api_get_nick() in api_get_user()
[ [
'id' => 43, 'id' => 43,
'uid' => 0, 'uid' => 0,
'uri-id' => 43, 'uri-id' => 43,
'name' => 'othercontact', 'name' => 'othercontact',
'nick' => 'othercontact', 'nick' => 'othercontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/othercontact', 'nurl' => 'http://localhost/profile/othercontact',
'url' => 'http://localhost/profile/othercontact', 'url' => 'http://localhost/profile/othercontact',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::NOTHING, 'rel' => Contact::NOTHING,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
], ],
[ [
'id' => 44, 'id' => 44,
'uid' => 42, 'uid' => 42,
'uri-id' => 44, 'uri-id' => 44,
'name' => 'Friend contact', 'name' => 'Friend contact',
'nick' => 'friendcontact', 'nick' => 'friendcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact', 'nurl' => 'http://localhost/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact', 'url' => 'http://localhost/profile/friendcontact',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::SHARING, 'rel' => Contact::SHARING,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
], ],
[ [
'id' => 45, 'id' => 45,
'uid' => 0, 'uid' => 0,
'uri-id' => 44, 'uri-id' => 44,
'name' => 'Friend contact', 'name' => 'Friend contact',
'nick' => 'friendcontact', 'nick' => 'friendcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/friendcontact', 'nurl' => 'http://localhost/profile/friendcontact',
'url' => 'http://localhost/profile/friendcontact', 'url' => 'http://localhost/profile/friendcontact',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::SHARING, 'rel' => Contact::SHARING,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
], ],
[ [
'id' => 46, 'id' => 46,
'uid' => 42, 'uid' => 42,
'uri-id' => 46, 'uri-id' => 46,
'name' => 'Mutual contact', 'name' => 'Mutual contact',
'nick' => 'mutualcontact', 'nick' => 'mutualcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact', 'nurl' => 'http://localhost/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact', 'url' => 'http://localhost/profile/mutualcontact',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::FRIEND, 'rel' => Contact::FRIEND,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
], ],
[ [
'id' => 47, 'id' => 47,
'uid' => 0, 'uid' => 0,
'uri-id' => 46, 'uri-id' => 46,
'name' => 'Mutual contact', 'name' => 'Mutual contact',
'nick' => 'mutualcontact', 'nick' => 'mutualcontact',
'self' => 0, 'self' => 0,
'nurl' => 'http://localhost/profile/mutualcontact', 'nurl' => 'http://localhost/profile/mutualcontact',
'url' => 'http://localhost/profile/mutualcontact', 'url' => 'http://localhost/profile/mutualcontact',
'pending' => 0, 'pending' => 0,
'blocked' => 0, 'blocked' => 0,
'rel' => Contact::SHARING, 'rel' => Contact::SHARING,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 48,
'uid' => 0,
'uri-id' => 42,
'name' => 'Self contact',
'nick' => 'selfcontact',
'self' => 0,
'nurl' => 'http://localhost/profile/selfcontact',
'url' => 'http://localhost/profile/selfcontact',
'about' => 'User used in tests',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FOLLOWER,
'network' => Protocol::DFRN,
'location' => 'DFRN', 'location' => 'DFRN',
], ],
], ],
'verb' => [ 'apcontact' => [
[
"url" => "http://localhost/profile/selfcontact",
"uri-id" => 1,
"uuid" => "42",
"type" => "Person",
"following" => "http://localhost/following/selfcontact",
"followers" => "http://localhost/followers/selfcontact",
"inbox" => "http://localhost/inbox/selfcontact",
"outbox" => "http://localhost/outbox/selfcontact",
"sharedinbox" => "http://localhost/inbox",
"manually-approve" => 1,
"discoverable" => 0,
"nick" => "selfcontact",
"name" => "Self contact",
"about" => "User used in tests",
"xmpp" => null,
"matrix" => null,
"photo" => "http://localhost/photo/profile/admin.jpeg",
"header" => null,
"addr" => "selfcontact@localhost",
"alias" => null,
"pubkey" => "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzLquDFnFxNYZZFQNbA9f\nkgtUJpC+MPrhxhEsjxme1ivvE4itdPnCueBHifknUkwfmqormyeqr4TdoVbNuKRg\nj2QRBdtaGbUJLQVdbiTKFOmJIYMtV05WIIHEhUW84fwIXmF+6u3kbOw+sIjWY3OW\nwC/2+54HiYS2n8cddfwoZBim6Na8yyQI8pQSKqJ+I4gDfkGuoVex0svNPEv9liLE\nykpQ3PuoeLJV2Wex0Cy6FYPgcfH6xvvUVxh6e8w0w22jC3DJInfDrmbw5H7aUbf+\nMMwV3TVI6/CqTO0cLEOZUjsUwdm6lIV0O0fTsrkjU9G0bc0sLJl7n9i9ICDOKOMf\nCLaK2Pj2sVbpkzXJoufLUDf0oSftdVvN9jR9WYxRdnwsyF8N/xVTw8AsyHhkXawR\n3YDgi6i2uZj5kvG7GPBf7EPZ/MpbGhEZB+/GQuZuyhLdgFDSi/uX8STBmn1jI/zY\nTLZ8JCwMzFKAXAtYaBPklZBbcRyz9O1893MsAXO8d6ODTOkD324gAjRUtuOMscYc\nWV98NZIUSbqQrznmMoJn1fiMNVgx+UXOPkiZuDxnrr1T3vynKnl5LXmadx2YeoAf\nxPeCoDb0eJtCDLcsTZ9qlztaEaohPV+H3HBSpdItea7LgAbccILHPssk9tUgmHVl\na5yV8uFenhKKQ9g93Pt63LsCAwEAAQ==\n-----END PUBLIC KEY-----",
"subscribe" => "/follow?url={uri}",
"baseurl" => null,
"gsid" => null,
"generator" => "Friendica 'Siberian Iris' 2021.12-dev-1443",
"following_count" => 0,
"followers_count" => 0,
"statuses_count" => 0,
"updated" => "2021-11-19 19:17:59",
],
],
'verb' => [
[ [
'id' => 0, 'id' => 0,
'name' => '', 'name' => '',
@ -291,7 +340,7 @@ return [
'plink' => 'http://localhost/display/6', 'plink' => 'http://localhost/display/6',
], ],
], ],
'post' => [ 'post' => [
[ [
'uri-id' => 1, 'uri-id' => 1,
'parent-uri-id' => 1, 'parent-uri-id' => 1,
@ -636,135 +685,135 @@ return [
'wall' => 0, 'wall' => 0,
], ],
], ],
'post-thread' => [ 'post-thread' => [
[ [
'uri-id' => 1, 'uri-id' => 1,
'author-id' => 42, 'author-id' => 42,
'owner-id' => 42, 'owner-id' => 42,
'causer-id' => 42, 'causer-id' => 42,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
], ],
[ [
'uri-id' => 3, 'uri-id' => 3,
'author-id' => 43, 'author-id' => 43,
'owner-id' => 43, 'owner-id' => 43,
'causer-id' => 43, 'causer-id' => 43,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
], ],
[ [
'uri-id' => 6, 'uri-id' => 6,
'author-id' => 44, 'author-id' => 44,
'owner-id' => 44, 'owner-id' => 44,
'causer-id' => 44, 'causer-id' => 44,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
], ],
], ],
'post-thread-user' => [ 'post-thread-user' => [
[ [
'uri-id' => 1, 'uri-id' => 1,
'uid' => 42, 'uid' => 42,
'wall' => 1, 'wall' => 1,
'post-user-id' => 1, 'post-user-id' => 1,
'author-id' => 42, 'author-id' => 42,
'owner-id' => 42, 'owner-id' => 42,
'causer-id' => 42, 'causer-id' => 42,
'contact-id' => 42, 'contact-id' => 42,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'starred' => 1, 'starred' => 1,
'origin' => 1, 'origin' => 1,
], ],
[ [
'uri-id' => 3, 'uri-id' => 3,
'uid' => 42, 'uid' => 42,
'wall' => 1, 'wall' => 1,
'post-user-id' => 3, 'post-user-id' => 3,
'author-id' => 43, 'author-id' => 43,
'owner-id' => 43, 'owner-id' => 43,
'causer-id' => 43, 'causer-id' => 43,
'contact-id' => 43, 'contact-id' => 43,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'starred' => 0, 'starred' => 0,
'origin' => 1, 'origin' => 1,
], ],
[ [
'uri-id' => 6, 'uri-id' => 6,
'uid' => 42, 'uid' => 42,
'wall' => 1, 'wall' => 1,
'post-user-id' => 6, 'post-user-id' => 6,
'author-id' => 44, 'author-id' => 44,
'owner-id' => 44, 'owner-id' => 44,
'causer-id' => 44, 'causer-id' => 44,
'contact-id' => 44, 'contact-id' => 44,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'starred' => 0, 'starred' => 0,
'origin' => 1, 'origin' => 1,
], ],
[ [
'uri-id' => 1, 'uri-id' => 1,
'uid' => 0, 'uid' => 0,
'wall' => 0, 'wall' => 0,
'post-user-id' => 7, 'post-user-id' => 7,
'author-id' => 42, 'author-id' => 42,
'owner-id' => 42, 'owner-id' => 42,
'causer-id' => 42, 'causer-id' => 42,
'contact-id' => 42, 'contact-id' => 42,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'starred' => 0, 'starred' => 0,
'origin' => 0, 'origin' => 0,
], ],
[ [
'uri-id' => 3, 'uri-id' => 3,
'uid' => 0, 'uid' => 0,
'wall' => 0, 'wall' => 0,
'post-user-id' => 9, 'post-user-id' => 9,
'author-id' => 43, 'author-id' => 43,
'owner-id' => 43, 'owner-id' => 43,
'causer-id' => 43, 'causer-id' => 43,
'contact-id' => 43, 'contact-id' => 43,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'starred' => 0, 'starred' => 0,
'origin' => 0, 'origin' => 0,
], ],
[ [
'uri-id' => 6, 'uri-id' => 6,
'uid' => 0, 'uid' => 0,
'wall' => 0, 'wall' => 0,
'post-user-id' => 12, 'post-user-id' => 12,
'author-id' => 44, 'author-id' => 44,
'owner-id' => 44, 'owner-id' => 44,
'causer-id' => 44, 'causer-id' => 44,
'contact-id' => 44, 'contact-id' => 44,
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'starred' => 0, 'starred' => 0,
'origin' => 0, 'origin' => 0,
], ],
], ],
'notify' => [ 'notify' => [
[ [
'id' => 1, 'id' => 1,
'type' => 8, 'type' => 8,
'name' => 'Reply to', 'name' => 'Reply to',
'url' => 'http://localhost/display/1', 'url' => 'http://localhost/display/1',
'photo' => 'http://localhost/', 'photo' => 'http://localhost/',
'date' => '2020-01-01 12:12:02', 'date' => '2020-01-01 12:12:02',
'msg' => 'A test reply from an item', 'msg' => 'A test reply from an item',
'uid' => 42, 'uid' => 42,
'link' => 'http://localhost/notification/1', 'link' => 'http://localhost/notification/1',
'iid' => 4, 'iid' => 4,
'seen' => 0, 'seen' => 0,
'verb' => \Friendica\Protocol\Activity::POST, 'verb' => \Friendica\Protocol\Activity::POST,
'otype' => Notification\ObjectType::ITEM, 'otype' => Notification\ObjectType::ITEM,
'name_cache' => 'Reply to', 'name_cache' => 'Reply to',
'msg_cache' => 'A test reply from an item', 'msg_cache' => 'A test reply from an item',
], ],
], ],
'profile' => [ 'profile' => [
[ [
'id' => 1, 'id' => 1,
'uid' => 42, 'uid' => 42,
], ],
], ],
'group' => [ 'group' => [
[ [
'id' => 1, 'id' => 1,
'uid' => 42, 'uid' => 42,
@ -778,7 +827,14 @@ return [
'name' => 'Private list', 'name' => 'Private list',
], ],
], ],
'search' => [ 'group_member' => [
[
'id' => 1,
'gid' => 1,
'contact-id' => 42,
],
],
'search' => [
[ [
'id' => 1, 'id' => 1,
'term' => 'Saved search', 'term' => 'Saved search',

View file

@ -6,21 +6,14 @@
namespace Friendica\Test\legacy; namespace Friendica\Test\legacy;
use Friendica\App; use Friendica\App;
use Friendica\App\Router;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Post;
use Friendica\Module\Api\ApiResponse; use Friendica\Module\Api\ApiResponse;
use Friendica\Module\Api\Twitter\Media\Upload;
use Friendica\Module\BaseApi; use Friendica\Module\BaseApi;
use Friendica\Network\HTTPException;
use Friendica\Security\BasicAuth; use Friendica\Security\BasicAuth;
use Friendica\Test\FixtureTest; use Friendica\Test\FixtureTest;
use Friendica\Util\Arrays; use Friendica\Util\Arrays;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
use Monolog\Handler\TestHandler; use Monolog\Handler\TestHandler;
require_once __DIR__ . '/../../include/api.php'; require_once __DIR__ . '/../../include/api.php';

View file

@ -2,29 +2,39 @@
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial; namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
use Friendica\App\BaseURL;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\GNUSocial\GNUSocial\Config;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class ConfigTest extends ApiTest class ConfigTest extends ApiTest
{ {
/** /**
* Test the api_statusnet_config() function. * Test the api_statusnet_config() function.
*
* @return void
*/ */
public function testApiStatusnetConfig() public function testApiStatusnetConfig()
{ {
/* DI::config()->set('system', 'ssl_policy', BaseURL::SSL_POLICY_FULL);
$result = api_statusnet_config('json');
self::assertEquals('localhost', $result['config']['site']['server']); $config = new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
self::assertEquals('default', $result['config']['site']['theme']); $response = $config->run();
self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']); $body = (string)$response->getBody();
self::assertTrue($result['config']['site']['fancy']);
self::assertEquals('en', $result['config']['site']['language']); self::assertJson($body);
self::assertEquals('UTC', $result['config']['site']['timezone']);
self::assertEquals(200000, $result['config']['site']['textlimit']); $json = json_decode($body);
self::assertEquals('false', $result['config']['site']['private']);
self::assertEquals('false', $result['config']['site']['ssl']); self::assertEquals(1, 1);
self::assertEquals(30, $result['config']['site']['shorturllength']);
*/ self::assertEquals('localhost', $json->site->server);
self::assertEquals('frio', $json->site->theme);
self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $json->site->logo);
self::assertTrue($json->site->fancy);
self::assertEquals('en', $json->site->language);
self::assertEquals('UTC', $json->site->timezone);
self::assertEquals(200000, $json->site->textlimit);
self::assertFalse($json->site->private);
self::assertEquals('always', $json->site->ssl);
} }
} }

View file

@ -2,6 +2,9 @@
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts; namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Mastodon\Accounts\Statuses;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class StatusesTest extends ApiTest class StatusesTest extends ApiTest
@ -11,6 +14,8 @@ class StatusesTest extends ApiTest
*/ */
public function testApiStatusShowWithJson() public function testApiStatusShowWithJson()
{ {
self::markTestIncomplete('Needs Statuses to not set header during call (like at BaseApi::setLinkHeader');
// $result = api_status_show('json', 1); // $result = api_status_show('json', 1);
// self::assertStatus($result['status']); // self::assertStatus($result['status']);
} }
@ -20,6 +25,8 @@ class StatusesTest extends ApiTest
*/ */
public function testApiStatusShowWithXml() public function testApiStatusShowWithXml()
{ {
self::markTestIncomplete('Needs Statuses to not set header during call (like at BaseApi::setLinkHeader');
// $result = api_status_show('xml', 1); // $result = api_status_show('xml', 1);
// self::assertXml($result, 'statuses'); // self::assertXml($result, 'statuses');
} }

View file

@ -2,6 +2,9 @@
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts; namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Mastodon\Accounts\VerifyCredentials;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class VerifyCredentialsTest extends ApiTest class VerifyCredentialsTest extends ApiTest
@ -13,7 +16,18 @@ class VerifyCredentialsTest extends ApiTest
*/ */
public function testApiAccountVerifyCredentials() public function testApiAccountVerifyCredentials()
{ {
// self::assertArrayHasKey('user', api_account_verify_credentials('json')); $verifyCredentials = new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
$response = $verifyCredentials->run();
$body = (string)$response->getBody();
self::assertJson($body);
$json = json_decode($body);
self::assertEquals(48, $json->id);
self::assertIsArray($json->emojis);
self::assertIsArray($json->fields);
} }
/** /**
@ -23,6 +37,8 @@ class VerifyCredentialsTest extends ApiTest
*/ */
public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser() public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
{ {
self::markTestIncomplete('Needs dynamic BasicAuth first');
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
// BasicAuth::setCurrentUserID(); // BasicAuth::setCurrentUserID();
// $_SESSION['authenticated'] = false; // $_SESSION['authenticated'] = false;

View file

@ -13,6 +13,8 @@ class ConversationsTest extends ApiTest
*/ */
public function testApiConversationShow() public function testApiConversationShow()
{ {
self::markTestIncomplete('Needs Conversations to not set header during call (like at BaseApi::setLinkHeader');
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
// api_conversation_show('json'); // api_conversation_show('json');
} }
@ -24,6 +26,8 @@ class ConversationsTest extends ApiTest
*/ */
public function testApiConversationShowWithId() public function testApiConversationShowWithId()
{ {
self::markTestIncomplete('Needs Conversations to not set header during call (like at BaseApi::setLinkHeader');
/* /*
DI::args()->setArgv(['', '', '', 1]); DI::args()->setArgv(['', '', '', 1]);
$_REQUEST['max_id'] = 10; $_REQUEST['max_id'] = 10;
@ -43,6 +47,8 @@ class ConversationsTest extends ApiTest
*/ */
public function testApiConversationShowWithUnallowedUser() public function testApiConversationShowWithUnallowedUser()
{ {
self::markTestIncomplete('Needs Conversations to not set header during call (like at BaseApi::setLinkHeader');
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
// BasicAuth::setCurrentUserID(); // BasicAuth::setCurrentUserID();
// api_conversation_show('json'); // api_conversation_show('json');

View file

@ -13,6 +13,8 @@ class SearchTest extends ApiTest
*/ */
public function testApiSearch() public function testApiSearch()
{ {
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['q'] = 'reply'; $_REQUEST['q'] = 'reply';
$_REQUEST['max_id'] = 10; $_REQUEST['max_id'] = 10;
@ -31,6 +33,8 @@ class SearchTest extends ApiTest
*/ */
public function testApiSearchWithCount() public function testApiSearchWithCount()
{ {
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['q'] = 'reply'; $_REQUEST['q'] = 'reply';
$_REQUEST['count'] = 20; $_REQUEST['count'] = 20;
@ -49,6 +53,8 @@ class SearchTest extends ApiTest
*/ */
public function testApiSearchWithRpp() public function testApiSearchWithRpp()
{ {
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['q'] = 'reply'; $_REQUEST['q'] = 'reply';
$_REQUEST['rpp'] = 20; $_REQUEST['rpp'] = 20;
@ -66,6 +72,8 @@ class SearchTest extends ApiTest
*/ */
public function testApiSearchWithHashtag() public function testApiSearchWithHashtag()
{ {
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['q'] = '%23friendica'; $_REQUEST['q'] = '%23friendica';
$result = api_search('json'); $result = api_search('json');
@ -82,6 +90,8 @@ class SearchTest extends ApiTest
*/ */
public function testApiSearchWithExcludeReplies() public function testApiSearchWithExcludeReplies()
{ {
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['max_id'] = 10; $_REQUEST['max_id'] = 10;
$_REQUEST['exclude_replies'] = true; $_REQUEST['exclude_replies'] = true;
@ -100,6 +110,8 @@ class SearchTest extends ApiTest
*/ */
public function testApiSearchWithUnallowedUser() public function testApiSearchWithUnallowedUser()
{ {
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
// BasicAuth::setCurrentUserID(); // BasicAuth::setCurrentUserID();
// api_search('json'); // api_search('json');
@ -112,6 +124,8 @@ class SearchTest extends ApiTest
*/ */
public function testApiSearchWithoutQuery() public function testApiSearchWithoutQuery()
{ {
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
// api_search('json'); // api_search('json');
} }

View file

@ -13,6 +13,8 @@ class HomeTest extends ApiTest
*/ */
public function testApiStatusesHomeTimeline() public function testApiStatusesHomeTimeline()
{ {
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['max_id'] = 10; $_REQUEST['max_id'] = 10;
$_REQUEST['exclude_replies'] = true; $_REQUEST['exclude_replies'] = true;
@ -32,6 +34,8 @@ class HomeTest extends ApiTest
*/ */
public function testApiStatusesHomeTimelineWithNegativePage() public function testApiStatusesHomeTimelineWithNegativePage()
{ {
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['page'] = -2; $_REQUEST['page'] = -2;
$result = api_statuses_home_timeline('json'); $result = api_statuses_home_timeline('json');
@ -49,6 +53,8 @@ class HomeTest extends ApiTest
*/ */
public function testApiStatusesHomeTimelineWithUnallowedUser() public function testApiStatusesHomeTimelineWithUnallowedUser()
{ {
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
BasicAuth::setCurrentUserID(); BasicAuth::setCurrentUserID();
@ -63,6 +69,8 @@ class HomeTest extends ApiTest
*/ */
public function testApiStatusesHomeTimelineWithRss() public function testApiStatusesHomeTimelineWithRss()
{ {
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
// $result = api_statuses_home_timeline('rss'); // $result = api_statuses_home_timeline('rss');
// self::assertXml($result, 'statuses'); // self::assertXml($result, 'statuses');
} }

View file

@ -13,6 +13,8 @@ class PublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesPublicTimeline() public function testApiStatusesPublicTimeline()
{ {
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['max_id'] = 10; $_REQUEST['max_id'] = 10;
$_REQUEST['conversation_id'] = 1; $_REQUEST['conversation_id'] = 1;
@ -31,6 +33,8 @@ class PublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesPublicTimelineWithExcludeReplies() public function testApiStatusesPublicTimelineWithExcludeReplies()
{ {
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['max_id'] = 10; $_REQUEST['max_id'] = 10;
$_REQUEST['exclude_replies'] = true; $_REQUEST['exclude_replies'] = true;
@ -49,6 +53,8 @@ class PublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesPublicTimelineWithNegativePage() public function testApiStatusesPublicTimelineWithNegativePage()
{ {
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
/* /*
$_REQUEST['page'] = -2; $_REQUEST['page'] = -2;
$result = api_statuses_public_timeline('json'); $result = api_statuses_public_timeline('json');
@ -66,6 +72,8 @@ class PublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesPublicTimelineWithUnallowedUser() public function testApiStatusesPublicTimelineWithUnallowedUser()
{ {
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
// BasicAuth::setCurrentUserID(); // BasicAuth::setCurrentUserID();
// api_statuses_public_timeline('json'); // api_statuses_public_timeline('json');
@ -78,6 +86,8 @@ class PublicTimelineTest extends ApiTest
*/ */
public function testApiStatusesPublicTimelineWithRss() public function testApiStatusesPublicTimelineWithRss()
{ {
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
// $result = api_statuses_public_timeline('rss'); // $result = api_statuses_public_timeline('rss');
// self::assertXml($result, 'statuses'); // self::assertXml($result, 'statuses');
} }

View file

@ -2,6 +2,7 @@
namespace Friendica\Test\src\Module\Api\Twitter\Account; namespace Friendica\Test\src\Module\Api\Twitter\Account;
use Friendica\App\Router;
use Friendica\Capabilities\ICanCreateResponses; use Friendica\Capabilities\ICanCreateResponses;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\Api\Twitter\Account\RateLimitStatus; use Friendica\Module\Api\Twitter\Account\RateLimitStatus;
@ -11,7 +12,7 @@ class RateLimitStatusTest extends ApiTest
{ {
public function testWithJson() public function testWithJson()
{ {
$rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); $rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
$response = $rateLimitStatus->run(); $response = $rateLimitStatus->run();
$result = json_decode($response->getBody()); $result = json_decode($response->getBody());

View file

@ -0,0 +1,29 @@
<?php
namespace Friendica\Test\src\Module\Api\Twitter\Account;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Account\UpdateProfile;
use Friendica\Test\src\Module\Api\ApiTest;
class UpdateProfileTest extends ApiTest
{
/**
* Test the api_account_update_profile() function.
*/
public function testApiAccountUpdateProfile()
{
$updateProfile = new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => 'json']);
$response = $updateProfile->run(['name' => 'new_name', 'description' => 'new_description']);
$body = (string)$response->getBody();
self::assertJson($body);
$json = json_decode($body);
self::assertEquals('new_name', $json->name);
self::assertEquals('new_description', $json->description);
}
}

View file

@ -1,28 +0,0 @@
<?php
namespace Friendica\Test\src\Module\Api\Twitter\Account;
use Friendica\Test\src\Module\Api\ApiTest;
class UpdateTest extends ApiTest
{
/**
* Test the api_account_update_profile() function.
*
* @return void
*/
public function testApiAccountUpdateProfile()
{
/*
$_POST['name'] = 'new_name';
$_POST['description'] = 'new_description';
$result = api_account_update_profile('json');
// We can't use assertSelfUser() here because the user object is missing some properties.
self::assertEquals($this->selfUser['id'], $result['user']['cid']);
self::assertEquals('DFRN', $result['user']['location']);
self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
self::assertEquals('new_name', $result['user']['name']);
self::assertEquals('new_description', $result['user']['description']);
*/
}
}

View file

@ -2,30 +2,28 @@
namespace Friendica\Test\src\Module\Api\Twitter\Blocks; namespace Friendica\Test\src\Module\Api\Twitter\Blocks;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Blocks\Lists;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class ListsTest extends ApiTest class ListsTest extends ApiTest
{ {
/** /**
* Test the api_statuses_f() function. * Test the api_statuses_f() function.
*
* @return void
*/ */
public function testApiStatusesFWithBlocks() public function testApiStatusesFWithBlocks()
{ {
// $result = api_statuses_f('blocks'); $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
// self::assertArrayHasKey('user', $result); $response = $lists->run();
}
/** $body = (string)$response->getBody();
* Test the api_blocks_list() function.
* self::assertJson($body);
* @return void
*/ $json = json_decode($body);
public function testApiBlocksList()
{ self::assertIsArray($json->users);
// $result = api_blocks_list('json');
// self::assertArrayHasKey('user', $result);
} }
/** /**
@ -35,6 +33,8 @@ class ListsTest extends ApiTest
*/ */
public function testApiBlocksListWithUndefinedCursor() public function testApiBlocksListWithUndefinedCursor()
{ {
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
// $_GET['cursor'] = 'undefined'; // $_GET['cursor'] = 'undefined';
// self::assertFalse(api_blocks_list('json')); // self::assertFalse(api_blocks_list('json'));
} }

View file

@ -2,30 +2,28 @@
namespace Friendica\Test\src\Module\Api\Twitter\Followers; namespace Friendica\Test\src\Module\Api\Twitter\Followers;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Followers\Lists;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class ListsTest extends ApiTest class ListsTest extends ApiTest
{ {
/** /**
* Test the api_statuses_f() function. * Test the api_statuses_f() function.
*
* @return void
*/ */
public function testApiStatusesFWithFollowers() public function testApiStatusesFWithFollowers()
{ {
// $result = api_statuses_f('followers'); $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
// self::assertArrayHasKey('user', $result); $response = $lists->run();
}
/** $body = (string)$response->getBody();
* Test the api_statuses_followers() function.
* self::assertJson($body);
* @return void
*/ $json = json_decode($body);
public function testApiStatusesFollowers()
{ self::assertIsArray($json->users);
// $result = api_statuses_followers('json');
// self::assertArrayHasKey('user', $result);
} }
/** /**
@ -35,6 +33,8 @@ class ListsTest extends ApiTest
*/ */
public function testApiStatusesFollowersWithUndefinedCursor() public function testApiStatusesFollowersWithUndefinedCursor()
{ {
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
// $_GET['cursor'] = 'undefined'; // $_GET['cursor'] = 'undefined';
// self::assertFalse(api_statuses_followers('json')); // self::assertFalse(api_statuses_followers('json'));
} }

View file

@ -2,6 +2,9 @@
namespace Friendica\Test\src\Module\Api\Twitter\Friends; namespace Friendica\Test\src\Module\Api\Twitter\Friends;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Friends\Lists;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class ListsTest extends ApiTest class ListsTest extends ApiTest
@ -13,9 +16,16 @@ class ListsTest extends ApiTest
*/ */
public function testApiStatusesFWithFriends() public function testApiStatusesFWithFriends()
{ {
// $_GET['page'] = -1; $lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
// $result = api_statuses_f('friends'); $response = $lists->run();
// self::assertArrayHasKey('user', $result);
$body = (string)$response->getBody();
self::assertJson($body);
$json = json_decode($body);
self::assertIsArray($json->users);
} }
/** /**
@ -25,29 +35,9 @@ class ListsTest extends ApiTest
*/ */
public function testApiStatusesFWithUndefinedCursor() public function testApiStatusesFWithUndefinedCursor()
{ {
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
// $_GET['cursor'] = 'undefined'; // $_GET['cursor'] = 'undefined';
// self::assertFalse(api_statuses_f('friends')); // self::assertFalse(api_statuses_f('friends'));
} }
/**
* Test the api_statuses_friends() function.
*
* @return void
*/
public function testApiStatusesFriends()
{
// $result = api_statuses_friends('json');
// self::assertArrayHasKey('user', $result);
}
/**
* Test the api_statuses_friends() function an undefined cursor GET variable.
*
* @return void
*/
public function testApiStatusesFriendsWithUndefinedCursor()
{
// $_GET['cursor'] = 'undefined';
// self::assertFalse(api_statuses_friends('json'));
}
} }

View file

@ -2,6 +2,9 @@
namespace Friendica\Test\src\Module\Api\Twitter\Friendships; namespace Friendica\Test\src\Module\Api\Twitter\Friendships;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Friendships\Incoming;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class IncomingTest extends ApiTest class IncomingTest extends ApiTest
@ -13,8 +16,16 @@ class IncomingTest extends ApiTest
*/ */
public function testApiFriendshipsIncoming() public function testApiFriendshipsIncoming()
{ {
// $result = api_friendships_incoming('json'); $lists = new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
// self::assertArrayHasKey('id', $result); $response = $lists->run();
$body = (string)$response->getBody();
self::assertJson($body);
$json = json_decode($body);
self::assertIsArray($json->ids);
} }
/** /**
@ -24,6 +35,8 @@ class IncomingTest extends ApiTest
*/ */
public function testApiFriendshipsIncomingWithUndefinedCursor() public function testApiFriendshipsIncomingWithUndefinedCursor()
{ {
self::markTestIncomplete('Needs refactoring of Incoming - replace filter_input() with $request parameter checks');
// $_GET['cursor'] = 'undefined'; // $_GET['cursor'] = 'undefined';
// self::assertFalse(api_friendships_incoming('json')); // self::assertFalse(api_friendships_incoming('json'));
} }

View file

@ -2,6 +2,10 @@
namespace Friendica\Test\src\Module\Api\Twitter\Lists; namespace Friendica\Test\src\Module\Api\Twitter\Lists;
use Friendica\App\Router;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Lists\Statuses;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
class StatusesTest extends ApiTest class StatusesTest extends ApiTest
@ -13,37 +17,41 @@ class StatusesTest extends ApiTest
*/ */
public function testApiListsStatuses() public function testApiListsStatuses()
{ {
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); $this->expectException(BadRequestException::class);
// api_lists_statuses('json');
$lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
$lists->run();
} }
/** /**
* Test the api_lists_statuses() function with a list ID. * Test the api_lists_statuses() function with a list ID.
* @doesNotPerformAssertions
*/ */
public function testApiListsStatusesWithListId() public function testApiListsStatusesWithListId()
{ {
/* $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
$_REQUEST['list_id'] = 1; $response = $lists->run(['list_id' => 1, 'page' => -1, 'max_id' => 10]);
$_REQUEST['page'] = -1;
$_REQUEST['max_id'] = 10; $body = (string)$response->getBody();
$result = api_lists_statuses('json');
foreach ($result['status'] as $status) { self::assertJson($body);
self::assertStatus($status);
$json = json_decode($body);
foreach ($json as $status) {
self::assertIsString($status->text);
self::assertIsInt($status->id);
} }
*/
} }
/** /**
* Test the api_lists_statuses() function with a list ID and a RSS result. * Test the api_lists_statuses() function with a list ID and a RSS result.
*
* @return void
*/ */
public function testApiListsStatusesWithListIdAndRss() public function testApiListsStatusesWithListIdAndRss()
{ {
// $_REQUEST['list_id'] = 1; $lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']);
// $result = api_lists_statuses('rss'); $response = $lists->run(['list_id' => 1]);
// self::assertXml($result, 'statuses');
self::assertXml((string)$response->getBody());
} }
/** /**
@ -53,6 +61,8 @@ class StatusesTest extends ApiTest
*/ */
public function testApiListsStatusesWithUnallowedUser() public function testApiListsStatusesWithUnallowedUser()
{ {
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
// BasicAuth::setCurrentUserID(); // BasicAuth::setCurrentUserID();
// api_lists_statuses('json'); // api_lists_statuses('json');