Hopefully making the tests to work

This commit is contained in:
Michael 2021-07-25 14:27:13 +00:00
parent 4e6dc34d6e
commit 540ddb9265
5 changed files with 82 additions and 83 deletions

View file

@ -545,10 +545,10 @@ function api_get_user(App $a, $contact_id = null)
} }
// $called_api is the API path exploded on / and is expected to have at least 2 elements // $called_api is the API path exploded on / and is expected to have at least 2 elements
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) { if (is_null($user) && (DI::args()->getArgc() > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api); $argid = count($called_api);
if (!empty($a->argv[$argid])) { if (!empty(DI::args()->getArgv()[$argid])) {
$data = explode(".", $a->argv[$argid]); $data = explode(".", DI::args()->getArgv()[$argid]);
if (count($data) > 1) { if (count($data) > 1) {
list($user, $null) = $data; list($user, $null) = $data;
} }
@ -1021,7 +1021,7 @@ function api_statuses_mediap($type)
} }
$txt = HTML::toBBCode($txt); $txt = HTML::toBBCode($txt);
$a->argv[1] = $user_info['screen_name']; //should be set to username? DI::args()->getArgv()[1] = $user_info['screen_name']; //should be set to username?
$picture = wall_upload_post($a, false); $picture = wall_upload_post($a, false);
@ -1883,7 +1883,7 @@ function api_statuses_show($type)
} }
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) { if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0); $id = intval($_REQUEST['id'] ?? 0);
@ -1891,7 +1891,7 @@ function api_statuses_show($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { if ($id == 0) {
$id = intval($a->argv[4] ?? 0); $id = intval(DI::args()->getArgv()[4] ?? 0);
} }
Logger::log('API: api_statuses_show: ' . $id); Logger::log('API: api_statuses_show: ' . $id);
@ -1962,7 +1962,7 @@ function api_conversation_show($type)
} }
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
$since_id = intval($_REQUEST['since_id'] ?? 0); $since_id = intval($_REQUEST['since_id'] ?? 0);
$max_id = intval($_REQUEST['max_id'] ?? 0); $max_id = intval($_REQUEST['max_id'] ?? 0);
$count = intval($_REQUEST['count'] ?? 20); $count = intval($_REQUEST['count'] ?? 20);
@ -1976,7 +1976,7 @@ function api_conversation_show($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { if ($id == 0) {
$id = intval($a->argv[4] ?? 0); $id = intval(DI::args()->getArgv()[4] ?? 0);
} }
Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]); Logger::info(API_LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]);
@ -2045,7 +2045,7 @@ function api_statuses_repeat($type)
api_get_user($a); api_get_user($a);
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) { if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0); $id = intval($_REQUEST['id'] ?? 0);
@ -2053,7 +2053,7 @@ function api_statuses_repeat($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { if ($id == 0) {
$id = intval($a->argv[4] ?? 0); $id = intval(DI::args()->getArgv()[4] ?? 0);
} }
Logger::log('API: api_statuses_repeat: '.$id); Logger::log('API: api_statuses_repeat: '.$id);
@ -2128,7 +2128,7 @@ function api_statuses_destroy($type)
api_get_user($a); api_get_user($a);
// params // params
$id = intval($a->argv[3] ?? 0); $id = intval(DI::args()->getArgv()[3] ?? 0);
if ($id == 0) { if ($id == 0) {
$id = intval($_REQUEST['id'] ?? 0); $id = intval($_REQUEST['id'] ?? 0);
@ -2136,7 +2136,7 @@ function api_statuses_destroy($type)
// Hotot workaround // Hotot workaround
if ($id == 0) { if ($id == 0) {
$id = intval($a->argv[4] ?? 0); $id = intval(DI::args()->getArgv()[4] ?? 0);
} }
Logger::log('API: api_statuses_destroy: '.$id); Logger::log('API: api_statuses_destroy: '.$id);
@ -2329,16 +2329,16 @@ function api_favorites_create_destroy($type)
// for versioned api. // for versioned api.
/// @TODO We need a better global soluton /// @TODO We need a better global soluton
$action_argv_id = 2; $action_argv_id = 2;
if (count($a->argv) > 1 && $a->argv[1] == "1.1") { if (count(DI::args()->getArgv()) > 1 && DI::args()->getArgv()[1] == "1.1") {
$action_argv_id = 3; $action_argv_id = 3;
} }
if ($a->argc <= $action_argv_id) { if (DI::args()->getArgc() <= $action_argv_id) {
throw new BadRequestException("Invalid request."); throw new BadRequestException("Invalid request.");
} }
$action = str_replace("." . $type, "", $a->argv[$action_argv_id]); $action = str_replace("." . $type, "", DI::args()->getArgv()[$action_argv_id]);
if ($a->argc == $action_argv_id + 2) { if (DI::args()->getArgc() == $action_argv_id + 2) {
$itemid = intval($a->argv[$action_argv_id + 1] ?? 0); $itemid = intval(DI::args()->getArgv()[$action_argv_id + 1] ?? 0);
} else { } else {
$itemid = intval($_REQUEST['id'] ?? 0); $itemid = intval($_REQUEST['id'] ?? 0);
} }
@ -5616,7 +5616,7 @@ function api_friendica_activity($type)
if (api_user() === false) { if (api_user() === false) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
$verb = strtolower($a->argv[3]); $verb = strtolower(DI::args()->getArgv()[3]);
$verb = preg_replace("|\..*$|", "", $verb); $verb = preg_replace("|\..*$|", "", $verb);
$id = $_REQUEST['id'] ?? 0; $id = $_REQUEST['id'] ?? 0;
@ -5664,7 +5664,7 @@ function api_friendica_notification($type)
if (api_user() === false) { if (api_user() === false) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
if ($a->argc!==3) { if (DI::args()->getArgc()!==3) {
throw new BadRequestException("Invalid argument count"); throw new BadRequestException("Invalid argument count");
} }
@ -5709,7 +5709,7 @@ function api_friendica_notification_seen($type)
if (api_user() === false || $user_info === false) { if (api_user() === false || $user_info === false) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
if ($a->argc !== 4) { if (DI::args()->getArgc() !== 4) {
throw new BadRequestException("Invalid argument count"); throw new BadRequestException("Invalid argument count");
} }

View file

@ -38,14 +38,14 @@ function message_init(App $a)
{ {
$tabs = ''; $tabs = '';
if ($a->argc > 1 && is_numeric($a->argv[1])) { if (DI::args()->getArgc() > 1 && is_numeric(DI::args()->getArgv()[1])) {
$tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl'); $tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl');
} }
$new = [ $new = [
'label' => DI::l10n()->t('New Message'), 'label' => DI::l10n()->t('New Message'),
'url' => 'message/new', 'url' => 'message/new',
'sel' => $a->argc > 1 && $a->argv[1] == 'new', 'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
'accesskey' => 'm', 'accesskey' => 'm',
]; ];
@ -96,8 +96,7 @@ function message_post(App $a)
// fake it to go back to the input form if no recipient listed // fake it to go back to the input form if no recipient listed
if ($norecip) { if ($norecip) {
$a->argc = 2; DI::args()->setArgv(['message', 'new']);
$a->argv[1] = 'new';
} else { } else {
DI::baseUrl()->redirect(DI::args()->getCommand() . '/' . $ret); DI::baseUrl()->redirect(DI::args()->getCommand() . '/' . $ret);
} }
@ -116,7 +115,7 @@ function message_content(App $a)
$myprofile = DI::baseUrl() . '/profile/' . $a->user['nickname']; $myprofile = DI::baseUrl() . '/profile/' . $a->user['nickname'];
$tpl = Renderer::getMarkupTemplate('mail_head.tpl'); $tpl = Renderer::getMarkupTemplate('mail_head.tpl');
if ($a->argc > 1 && $a->argv[1] == 'new') { if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') {
$button = [ $button = [
'label' => DI::l10n()->t('Discard'), 'label' => DI::l10n()->t('Discard'),
'url' => '/message', 'url' => '/message',
@ -135,20 +134,20 @@ function message_content(App $a)
'$button' => $button, '$button' => $button,
]); ]);
if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop' || DI::args()->getArgv()[1] === 'dropconv')) {
if (!intval($a->argv[2])) { if (!intval(DI::args()->getArgv()[2])) {
return; return;
} }
$cmd = $a->argv[1]; $cmd = DI::args()->getArgv()[1];
if ($cmd === 'drop') { if ($cmd === 'drop') {
$message = DBA::selectFirst('mail', ['convid'], ['id' => $a->argv[2], 'uid' => local_user()]); $message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
if(!DBA::isResult($message)){ if(!DBA::isResult($message)){
notice(DI::l10n()->t('Conversation not found.')); notice(DI::l10n()->t('Conversation not found.'));
DI::baseUrl()->redirect('message'); DI::baseUrl()->redirect('message');
} }
if (!DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) { if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => local_user()])) {
notice(DI::l10n()->t('Message was not deleted.')); notice(DI::l10n()->t('Message was not deleted.'));
} }
@ -160,7 +159,7 @@ function message_content(App $a)
DI::baseUrl()->redirect('message/' . $conversation['id'] ); DI::baseUrl()->redirect('message/' . $conversation['id'] );
} else { } else {
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[2]), intval(DI::args()->getArgv()[2]),
intval(local_user()) intval(local_user())
); );
if (DBA::isResult($r)) { if (DBA::isResult($r)) {
@ -174,7 +173,7 @@ function message_content(App $a)
} }
} }
if (($a->argc > 1) && ($a->argv[1] === 'new')) { if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'new')) {
$o .= $header; $o .= $header;
$tpl = Renderer::getMarkupTemplate('msg-header.tpl'); $tpl = Renderer::getMarkupTemplate('msg-header.tpl');
@ -184,7 +183,7 @@ function message_content(App $a)
'$linkurl' => DI::l10n()->t('Please enter a link URL:') '$linkurl' => DI::l10n()->t('Please enter a link URL:')
]); ]);
$recipientId = $a->argv[2] ?? null; $recipientId = DI::args()->getArgv()[2] ?? null;
$select = ACL::getMessageContactSelectHTML($recipientId); $select = ACL::getMessageContactSelectHTML($recipientId);
@ -210,7 +209,7 @@ function message_content(App $a)
$_SESSION['return_path'] = DI::args()->getQueryString(); $_SESSION['return_path'] = DI::args()->getQueryString();
if ($a->argc == 1) { if (DI::args()->getArgc() == 1) {
// List messages // List messages
@ -241,7 +240,7 @@ function message_content(App $a)
return $o; return $o;
} }
if (($a->argc > 1) && (intval($a->argv[1]))) { if ((DI::args()->getArgc() > 1) && (intval(DI::args()->getArgv()[1]))) {
$o .= $header; $o .= $header;
@ -252,7 +251,7 @@ function message_content(App $a)
WHERE `mail`.`uid` = ? AND `mail`.`id` = ? WHERE `mail`.`uid` = ? AND `mail`.`id` = ?
LIMIT 1", LIMIT 1",
local_user(), local_user(),
$a->argv[1] DI::args()->getArgv()[1]
); );
if (DBA::isResult($message)) { if (DBA::isResult($message)) {
$contact_id = $message['contact-id']; $contact_id = $message['contact-id'];
@ -345,7 +344,7 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('mail_display.tpl'); $tpl = Renderer::getMarkupTemplate('mail_display.tpl');
$o = Renderer::replaceMacros($tpl, [ $o = Renderer::replaceMacros($tpl, [
'$thread_id' => $a->argv[1], '$thread_id' => DI::args()->getArgv()[1],
'$thread_subject' => $message['title'], '$thread_subject' => $message['title'],
'$thread_seen' => $seen, '$thread_seen' => $seen,
'$delete' => DI::l10n()->t('Delete conversation'), '$delete' => DI::l10n()->t('Delete conversation'),

View file

@ -43,9 +43,9 @@ function wall_upload_post(App $a, $desktopmode = true)
$r_json = (!empty($_GET['response']) && $_GET['response'] == 'json'); $r_json = (!empty($_GET['response']) && $_GET['response'] == 'json');
$album = trim($_GET['album'] ?? ''); $album = trim($_GET['album'] ?? '');
if ($a->argc > 1) { if (DI::args()->getArgc() > 1) {
if (empty($_FILES['media'])) { if (empty($_FILES['media'])) {
$nick = $a->argv[1]; $nick = DI::args()->getArgv()[1];
$user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]); $user = DBA::selectFirst('owner-view', ['id', 'uid', 'nickname', 'page-flags'], ['nickname' => $nick, 'blocked' => false]);
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
if ($r_json) { if ($r_json) {

View file

@ -87,6 +87,17 @@ class Arguments
return $this->argc; return $this->argc;
} }
public function setArgv(array $argv)
{
$this->argv = $argv;
$this->argc = count($argv);
}
public function setArgc(int $argc)
{
$this->argc = $argc;
}
/** /**
* Returns the value of a argv key * Returns the value of a argv key
* @todo there are a lot of $a->argv usages in combination with ?? which can be replaced with this method * @todo there are a lot of $a->argv usages in combination with ?? which can be replaced with this method

View file

@ -76,8 +76,7 @@ class ApiTest extends FixtureTest
/** @var App app */ /** @var App app */
$this->app = DI::app(); $this->app = DI::app();
$this->app->argc = 1; DI::args()->setArgc(1);
$this->app->argv = [''];
// User data that the test database is populated with // User data that the test database is populated with
$this->selfUser = [ $this->selfUser = [
@ -925,7 +924,7 @@ class ApiTest extends FixtureTest
{ {
global $called_api; global $called_api;
$called_api = ['api_path']; $called_api = ['api_path'];
$this->app->argv[1] = $this->otherUser['id'] . '.json'; DI::args()->setArgv(['', $this->otherUser['id'] . '.json']);
self::assertOtherUser(api_get_user($this->app)); self::assertOtherUser(api_get_user($this->app));
} }
@ -1198,7 +1197,7 @@ class ApiTest extends FixtureTest
*/ */
public function testApiStatusesMediap() public function testApiStatusesMediap()
{ {
$this->app->argc = 2; DI::args()->setArgc(2);
$_FILES = [ $_FILES = [
'media' => [ 'media' => [
@ -1370,7 +1369,7 @@ class ApiTest extends FixtureTest
] ]
]; ];
$app = DI::app(); $app = DI::app();
$app->argc = 2; DI::args()->setArgc(2);
$result = api_media_upload(); $result = api_media_upload();
self::assertEquals('image/png', $result['media']['image']['image_type']); self::assertEquals('image/png', $result['media']['image']['image_type']);
@ -1793,8 +1792,8 @@ class ApiTest extends FixtureTest
*/ */
public function testApiStatusesShowWithId() public function testApiStatusesShowWithId()
{ {
$this->app->argv[3] = 1; DI::args()->setArgv(['', '', '', 1]);
$result = api_statuses_show('json'); $result = api_statuses_show('json');
self::assertStatus($result['status']); self::assertStatus($result['status']);
} }
@ -1805,7 +1804,7 @@ class ApiTest extends FixtureTest
*/ */
public function testApiStatusesShowWithConversation() public function testApiStatusesShowWithConversation()
{ {
$this->app->argv[3] = 1; DI::args()->setArgv(['', '', '', 1]);
$_REQUEST['conversation'] = 1; $_REQUEST['conversation'] = 1;
$result = api_statuses_show('json'); $result = api_statuses_show('json');
self::assertNotEmpty($result['status']); self::assertNotEmpty($result['status']);
@ -1845,7 +1844,7 @@ class ApiTest extends FixtureTest
*/ */
public function testApiConversationShowWithId() public function testApiConversationShowWithId()
{ {
$this->app->argv[3] = 1; DI::args()->setArgv(['', '', '', 1]);
$_REQUEST['max_id'] = 10; $_REQUEST['max_id'] = 10;
$_REQUEST['page'] = -2; $_REQUEST['page'] = -2;
$result = api_conversation_show('json'); $result = api_conversation_show('json');
@ -1898,13 +1897,13 @@ class ApiTest extends FixtureTest
*/ */
public function testApiStatusesRepeatWithId() public function testApiStatusesRepeatWithId()
{ {
$this->app->argv[3] = 1; DI::args()->setArgv(['', '', '', 1]);
$result = api_statuses_repeat('json'); $result = api_statuses_repeat('json');
self::assertStatus($result['status']); self::assertStatus($result['status']);
// Also test with a shared status // Also test with a shared status
$this->app->argv[3] = 5; DI::args()->setArgv(['', '', '', 5]);
$result = api_statuses_repeat('json'); $result = api_statuses_repeat('json');
self::assertStatus($result['status']); self::assertStatus($result['status']);
} }
@ -1938,8 +1937,8 @@ class ApiTest extends FixtureTest
*/ */
public function testApiStatusesDestroyWithId() public function testApiStatusesDestroyWithId()
{ {
$this->app->argv[3] = 1; DI::args()->setArgv(['', '', '', 1]);
$result = api_statuses_destroy('json'); $result = api_statuses_destroy('json');
self::assertStatus($result['status']); self::assertStatus($result['status']);
} }
@ -2057,8 +2056,7 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroy() public function testApiFavoritesCreateDestroy()
{ {
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'create']; DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
$this->app->argc = count($this->app->argv);
api_favorites_create_destroy('json'); api_favorites_create_destroy('json');
} }
@ -2070,8 +2068,7 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroyWithInvalidId() public function testApiFavoritesCreateDestroyWithInvalidId()
{ {
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'create', '12.json']; DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
$this->app->argc = count($this->app->argv);
api_favorites_create_destroy('json'); api_favorites_create_destroy('json');
} }
@ -2083,9 +2080,8 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroyWithInvalidAction() public function testApiFavoritesCreateDestroyWithInvalidAction()
{ {
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'change.json']; DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
$this->app->argc = count($this->app->argv); $_REQUEST['id'] = 1;
$_REQUEST['id'] = 1;
api_favorites_create_destroy('json'); api_favorites_create_destroy('json');
} }
@ -2096,10 +2092,9 @@ class ApiTest extends FixtureTest
*/ */
public function testApiFavoritesCreateDestroyWithCreateAction() public function testApiFavoritesCreateDestroyWithCreateAction()
{ {
$this->app->argv = ['api', '1.1', 'favorites', 'create.json']; DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
$this->app->argc = count($this->app->argv); $_REQUEST['id'] = 3;
$_REQUEST['id'] = 3; $result = api_favorites_create_destroy('json');
$result = api_favorites_create_destroy('json');
self::assertStatus($result['status']); self::assertStatus($result['status']);
} }
@ -2110,10 +2105,9 @@ class ApiTest extends FixtureTest
*/ */
public function testApiFavoritesCreateDestroyWithCreateActionAndRss() public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
{ {
$this->app->argv = ['api', '1.1', 'favorites', 'create.rss']; DI::args()->setArgv(['api', '1.1', 'favorites', 'create.rss']);
$this->app->argc = count($this->app->argv); $_REQUEST['id'] = 3;
$_REQUEST['id'] = 3; $result = api_favorites_create_destroy('rss');
$result = api_favorites_create_destroy('rss');
self::assertXml($result, 'status'); self::assertXml($result, 'status');
} }
@ -2124,10 +2118,9 @@ class ApiTest extends FixtureTest
*/ */
public function testApiFavoritesCreateDestroyWithDestroyAction() public function testApiFavoritesCreateDestroyWithDestroyAction()
{ {
$this->app->argv = ['api', '1.1', 'favorites', 'destroy.json']; DI::args()->setArgv(['api', '1.1', 'favorites', 'destroy.json']);
$this->app->argc = count($this->app->argv); $_REQUEST['id'] = 3;
$_REQUEST['id'] = 3; $result = api_favorites_create_destroy('json');
$result = api_favorites_create_destroy('json');
self::assertStatus($result['status']); self::assertStatus($result['status']);
} }
@ -2139,8 +2132,7 @@ class ApiTest extends FixtureTest
public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser() public function testApiFavoritesCreateDestroyWithoutAuthenticatedUser()
{ {
$this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class); $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
$this->app->argv = ['api', '1.1', 'favorites', 'create.json']; DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
$this->app->argc = count($this->app->argv);
$_SESSION['authenticated'] = false; $_SESSION['authenticated'] = false;
api_favorites_create_destroy('json'); api_favorites_create_destroy('json');
} }
@ -3719,8 +3711,7 @@ class ApiTest extends FixtureTest
*/ */
public function testApiFriendicaNotificationWithEmptyResult() public function testApiFriendicaNotificationWithEmptyResult()
{ {
$this->app->argv = ['api', 'friendica', 'notification']; DI::args()->setArgv(['api', 'friendica', 'notification']);
$this->app->argc = count($this->app->argv);
$_SESSION['uid'] = 41; $_SESSION['uid'] = 41;
$result = api_friendica_notification('json'); $result = api_friendica_notification('json');
self::assertEquals(['note' => false], $result); self::assertEquals(['note' => false], $result);
@ -3733,9 +3724,8 @@ class ApiTest extends FixtureTest
*/ */
public function testApiFriendicaNotificationWithXmlResult() public function testApiFriendicaNotificationWithXmlResult()
{ {
$this->app->argv = ['api', 'friendica', 'notification']; DI::args()->setArgv(['api', 'friendica', 'notification']);
$this->app->argc = count($this->app->argv); $result = api_friendica_notification('xml');
$result = api_friendica_notification('xml');
$dateRel = Temporal::getRelativeDate('2020-01-01 12:12:02'); $dateRel = Temporal::getRelativeDate('2020-01-01 12:12:02');
$assertXml=<<<XML $assertXml=<<<XML
<?xml version="1.0"?> <?xml version="1.0"?>
@ -3753,9 +3743,8 @@ XML;
*/ */
public function testApiFriendicaNotificationWithJsonResult() public function testApiFriendicaNotificationWithJsonResult()
{ {
$this->app->argv = ['api', 'friendica', 'notification']; DI::args()->setArgv(['api', 'friendica', 'notification']);
$this->app->argc = count($this->app->argv); $result = json_encode(api_friendica_notification('json'));
$result = json_encode(api_friendica_notification('json'));
self::assertJson($result); self::assertJson($result);
} }