3 namespace Friendica\Test\src\Module\Api\Twitter\Statuses;
5 use Friendica\App\Router;
6 use Friendica\Capabilities\ICanCreateResponses;
8 use Friendica\Module\Api\Twitter\Statuses\UserTimeline;
9 use Friendica\Test\src\Module\Api\ApiTest;
11 class UserTimelineTest extends ApiTest
14 * Test the api_statuses_user_timeline() function.
18 public function testApiStatusesUserTimeline()
20 $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
22 $response = $networkPublicTimeline->run([
25 'exclude_replies' => true,
26 'conversation_id' => 7,
29 $json = $this->toJson($response);
31 self::assertIsArray($json);
32 self::assertNotEmpty($json);
33 foreach ($json as $status) {
34 self::assertIsString($status->text);
35 self::assertIsInt($status->id);
40 * Test the api_statuses_user_timeline() function with a negative page parameter.
44 public function testApiStatusesUserTimelineWithNegativePage()
46 $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
48 $response = $networkPublicTimeline->run([
53 $json = $this->toJson($response);
55 self::assertIsArray($json);
56 self::assertNotEmpty($json);
57 foreach ($json as $status) {
58 self::assertIsString($status->text);
59 self::assertIsInt($status->id);
64 * Test the api_statuses_user_timeline() function with an RSS result.
68 public function testApiStatusesUserTimelineWithRss()
70 $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]);
72 $response = $networkPublicTimeline->run();
74 self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
76 self::assertXml((string)$response->getBody(), 'statuses');
80 * Test the api_statuses_user_timeline() function with an unallowed user.
84 public function testApiStatusesUserTimelineWithUnallowedUser()
86 self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
88 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
89 // BasicAuth::setCurrentUserID();
90 // api_statuses_user_timeline('json');