3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Module\Api\Twitter\Statuses;
24 use Friendica\App\Router;
25 use Friendica\Capabilities\ICanCreateResponses;
27 use Friendica\Module\Api\Twitter\Statuses\UserTimeline;
28 use Friendica\Test\src\Module\Api\ApiTest;
30 class UserTimelineTest extends ApiTest
33 * Test the api_statuses_user_timeline() function.
37 public function testApiStatusesUserTimeline()
39 $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
43 'exclude_replies' => true,
44 'conversation_id' => 7,
47 $json = $this->toJson($response);
49 self::assertIsArray($json);
50 self::assertNotEmpty($json);
51 foreach ($json as $status) {
52 self::assertIsString($status->text);
53 self::assertIsInt($status->id);
58 * Test the api_statuses_user_timeline() function with a negative page parameter.
62 public function testApiStatusesUserTimelineWithNegativePage()
64 $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
70 $json = $this->toJson($response);
72 self::assertIsArray($json);
73 self::assertNotEmpty($json);
74 foreach ($json as $status) {
75 self::assertIsString($status->text);
76 self::assertIsInt($status->id);
81 * Test the api_statuses_user_timeline() function with an RSS result.
85 public function testApiStatusesUserTimelineWithRss()
87 $response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], [
88 'extension' => ICanCreateResponses::TYPE_RSS
91 self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
93 self::assertXml((string)$response->getBody(), 'statuses');
97 * Test the api_statuses_user_timeline() function with an unallowed user.
101 public function testApiStatusesUserTimelineWithUnallowedUser()
103 self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
105 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
106 // BasicAuth::setCurrentUserID();
107 // api_statuses_user_timeline('json');