- * Test the api_statuses_public_timeline() function with an RSS result.
- *
- * @return void
- */
- public function testApiStatusesPublicTimelineWithRss()
- {
- $result = api_statuses_public_timeline('rss');
- self::assertXml($result, 'statuses');
- }
-
- /**
- * Test the api_statuses_networkpublic_timeline() function.
- *
- * @return void
- */
- public function testApiStatusesNetworkpublicTimeline()
- {
- $_REQUEST['max_id'] = 10;
- $result = api_statuses_networkpublic_timeline('json');
- self::assertNotEmpty($result['status']);
- foreach ($result['status'] as $status) {
- self::assertStatus($status);
- }
- }
-
- /**
- * Test the api_statuses_networkpublic_timeline() function with a negative page parameter.
- *
- * @return void
- */
- public function testApiStatusesNetworkpublicTimelineWithNegativePage()
- {
- $_REQUEST['page'] = -2;
- $result = api_statuses_networkpublic_timeline('json');
- self::assertNotEmpty($result['status']);
- foreach ($result['status'] as $status) {
- self::assertStatus($status);
- }
- }
-
- /**
- * Test the api_statuses_networkpublic_timeline() function with an unallowed user.
- *
- * @return void
- */
- public function testApiStatusesNetworkpublicTimelineWithUnallowedUser()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- $_SESSION['allow_api'] = false;
- $_GET['screen_name'] = $this->selfUser['nick'];
- api_statuses_networkpublic_timeline('json');
- }
-
- /**
- * Test the api_statuses_networkpublic_timeline() function with an RSS result.
- *
- * @return void
- */
- public function testApiStatusesNetworkpublicTimelineWithRss()
- {
- $result = api_statuses_networkpublic_timeline('rss');
- self::assertXml($result, 'statuses');
- }
-
- /**
- * Test the api_statuses_show() function.
- *
- * @return void
- */
- public function testApiStatusesShow()
- {
- $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
- api_statuses_show('json');
- }
-
- /**
- * Test the api_statuses_show() function with an ID.
- *
- * @return void
- */
- public function testApiStatusesShowWithId()
- {
- DI::args()->setArgv(['', '', '', 1]);
- $result = api_statuses_show('json');
- self::assertStatus($result['status']);
- }
-
- /**
- * Test the api_statuses_show() function with the conversation parameter.
- *
- * @return void
- */
- public function testApiStatusesShowWithConversation()
- {
- DI::args()->setArgv(['', '', '', 1]);
- $_REQUEST['conversation'] = 1;
- $result = api_statuses_show('json');
- self::assertNotEmpty($result['status']);
- foreach ($result['status'] as $status) {
- self::assertStatus($status);
- }
- }
-
- /**
- * Test the api_statuses_show() function with an unallowed user.
- *
- * @return void
- */
- public function testApiStatusesShowWithUnallowedUser()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- $_SESSION['allow_api'] = false;
- $_GET['screen_name'] = $this->selfUser['nick'];
- api_statuses_show('json');
- }
-
- /**
- * Test the api_conversation_show() function.
- *
- * @return void
- */
- public function testApiConversationShow()
- {
- $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
- api_conversation_show('json');
- }
-
- /**
- * Test the api_conversation_show() function with an ID.
- *
- * @return void
- */
- public function testApiConversationShowWithId()
- {
- DI::args()->setArgv(['', '', '', 1]);
- $_REQUEST['max_id'] = 10;
- $_REQUEST['page'] = -2;
- $result = api_conversation_show('json');
- self::assertNotEmpty($result['status']);
- foreach ($result['status'] as $status) {
- self::assertStatus($status);
- }
- }
-
- /**
- * Test the api_conversation_show() function with an unallowed user.
- *
- * @return void
- */
- public function testApiConversationShowWithUnallowedUser()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- $_SESSION['allow_api'] = false;
- $_GET['screen_name'] = $this->selfUser['nick'];
- api_conversation_show('json');
- }
-
- /**
- * Test the api_statuses_repeat() function.
- *
- * @return void
- */
- public function testApiStatusesRepeat()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- api_statuses_repeat('json');
- }
-
- /**
- * Test the api_statuses_repeat() function without an authenticated user.
- *
- * @return void
- */
- public function testApiStatusesRepeatWithoutAuthenticatedUser()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- $_SESSION['authenticated'] = false;
- api_statuses_repeat('json');
- }
-
- /**
- * Test the api_statuses_repeat() function with an ID.
- *
- * @return void
- */
- public function testApiStatusesRepeatWithId()
- {
- DI::args()->setArgv(['', '', '', 1]);
- $result = api_statuses_repeat('json');
- self::assertStatus($result['status']);
-
- // Also test with a shared status
- DI::args()->setArgv(['', '', '', 5]);
- $result = api_statuses_repeat('json');
- self::assertStatus($result['status']);
- }
-
- /**
- * Test the api_statuses_destroy() function.
- *
- * @return void
- */
- public function testApiStatusesDestroy()
- {
- $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
- api_statuses_destroy('json');
- }
-
- /**
- * Test the api_statuses_destroy() function without an authenticated user.
- *
- * @return void
- */
- public function testApiStatusesDestroyWithoutAuthenticatedUser()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- $_SESSION['authenticated'] = false;
- api_statuses_destroy('json');
- }
-
- /**
- * Test the api_statuses_destroy() function with an ID.
- *
- * @return void
- */
- public function testApiStatusesDestroyWithId()
- {
- DI::args()->setArgv(['', '', '', 1]);
- $result = api_statuses_destroy('json');
- self::assertStatus($result['status']);
- }
-
- /**
- * Test the api_statuses_mentions() function.
- *
- * @return void
- */
- public function testApiStatusesMentions()
- {
- $this->app->setLoggedInUserNickname($this->selfUser['nick']);
- $_REQUEST['max_id'] = 10;
- $result = api_statuses_mentions('json');
- self::assertEmpty($result['status']);
- // We should test with mentions in the database.
- }
-
- /**
- * Test the api_statuses_mentions() function with a negative page parameter.
- *
- * @return void
- */
- public function testApiStatusesMentionsWithNegativePage()
- {
- $_REQUEST['page'] = -2;
- $result = api_statuses_mentions('json');
- self::assertEmpty($result['status']);
- }
-
- /**
- * Test the api_statuses_mentions() function with an unallowed user.
- *
- * @return void
- */
- public function testApiStatusesMentionsWithUnallowedUser()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- $_SESSION['allow_api'] = false;
- $_GET['screen_name'] = $this->selfUser['nick'];
- api_statuses_mentions('json');
- }
-
- /**
- * Test the api_statuses_mentions() function with an RSS result.
- *
- * @return void
- */
- public function testApiStatusesMentionsWithRss()
- {
- $result = api_statuses_mentions('rss');
- self::assertXml($result, 'statuses');
- }
-
- /**
- * Test the api_statuses_user_timeline() function.
- *
- * @return void
- */
- public function testApiStatusesUserTimeline()
- {
- $_REQUEST['max_id'] = 10;
- $_REQUEST['exclude_replies'] = true;
- $_REQUEST['conversation_id'] = 1;
- $result = api_statuses_user_timeline('json');
- self::assertNotEmpty($result['status']);
- foreach ($result['status'] as $status) {
- self::assertStatus($status);
- }
- }
-
- /**
- * Test the api_statuses_user_timeline() function with a negative page parameter.
- *
- * @return void
- */
- public function testApiStatusesUserTimelineWithNegativePage()
- {
- $_REQUEST['page'] = -2;
- $result = api_statuses_user_timeline('json');
- self::assertNotEmpty($result['status']);
- foreach ($result['status'] as $status) {
- self::assertStatus($status);
- }
- }
-
- /**
- * Test the api_statuses_user_timeline() function with an RSS result.
- *
- * @return void
- */
- public function testApiStatusesUserTimelineWithRss()
- {
- $result = api_statuses_user_timeline('rss');
- self::assertXml($result, 'statuses');
- }
-
- /**
- * Test the api_statuses_user_timeline() function with an unallowed user.
- *
- * @return void
- */
- public function testApiStatusesUserTimelineWithUnallowedUser()
- {
- $this->expectException(\Friendica\Network\HTTPException\ForbiddenException::class);
- $_SESSION['allow_api'] = false;
- $_GET['screen_name'] = $this->selfUser['nick'];
- api_statuses_user_timeline('json');
- }
-
- /**
- * Test the api_favorites_create_destroy() function.
- *
- * @return void
- */
- public function testApiFavoritesCreateDestroy()
- {
- $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
- DI::args()->setArgv(['api', '1.1', 'favorites', 'create']);
- api_favorites_create_destroy('json');
- }
-
- /**
- * Test the api_favorites_create_destroy() function with an invalid ID.
- *
- * @return void
- */
- public function testApiFavoritesCreateDestroyWithInvalidId()
- {
- $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
- DI::args()->setArgv(['api', '1.1', 'favorites', 'create', '12.json']);
- api_favorites_create_destroy('json');
- }
-
- /**
- * Test the api_favorites_create_destroy() function with an invalid action.
- *
- * @return void
- */
- public function testApiFavoritesCreateDestroyWithInvalidAction()
- {
- $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
- DI::args()->setArgv(['api', '1.1', 'favorites', 'change.json']);
- $_REQUEST['id'] = 1;
- api_favorites_create_destroy('json');
- }
-
- /**
- * Test the api_favorites_create_destroy() function with the create action.
- *
- * @return void
- */
- public function testApiFavoritesCreateDestroyWithCreateAction()
- {
- DI::args()->setArgv(['api', '1.1', 'favorites', 'create.json']);
- $_REQUEST['id'] = 3;
- $result = api_favorites_create_destroy('json');
- self::assertStatus($result['status']);
- }
-
- /**
- * Test the api_favorites_create_destroy() function with the create action and an RSS result.