]> git.mxchange.org Git - friendica.git/blob - tests/src/Module/Api/Twitter/Statuses/UserTimelineTest.php
Reenable Twitter/Search test
[friendica.git] / tests / src / Module / Api / Twitter / Statuses / UserTimelineTest.php
1 <?php
2
3 namespace Friendica\Test\src\Module\Api\Twitter\Statuses;
4
5 use Friendica\App\Router;
6 use Friendica\Capabilities\ICanCreateResponses;
7 use Friendica\DI;
8 use Friendica\Module\Api\Twitter\Statuses\UserTimeline;
9 use Friendica\Test\src\Module\Api\ApiTest;
10
11 class UserTimelineTest extends ApiTest
12 {
13         /**
14          * Test the api_statuses_user_timeline() function.
15          *
16          * @return void
17          */
18         public function testApiStatusesUserTimeline()
19         {
20                 $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
21
22                 $response = $networkPublicTimeline->run([
23                         'user_id'         => 42,
24                         'max_id'          => 10,
25                         'exclude_replies' => true,
26                         'conversation_id' => 7,
27                 ]);
28
29                 $json = $this->toJson($response);
30
31                 self::assertIsArray($json);
32                 self::assertNotEmpty($json);
33                 foreach ($json as $status) {
34                         self::assertIsString($status->text);
35                         self::assertIsInt($status->id);
36                 }
37         }
38
39         /**
40          * Test the api_statuses_user_timeline() function with a negative page parameter.
41          *
42          * @return void
43          */
44         public function testApiStatusesUserTimelineWithNegativePage()
45         {
46                 $networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
47
48                 $response = $networkPublicTimeline->run([
49                         'user_id' => 42,
50                         'page'    => -2,
51                 ]);
52
53                 $json = $this->toJson($response);
54
55                 self::assertIsArray($json);
56                 self::assertNotEmpty($json);
57                 foreach ($json as $status) {
58                         self::assertIsString($status->text);
59                         self::assertIsInt($status->id);
60                 }
61         }
62
63         /**
64          * Test the api_statuses_user_timeline() function with an RSS result.
65          *
66          * @return void
67          */
68         public function testApiStatusesUserTimelineWithRss()
69         {
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]);
71
72                 $response = $networkPublicTimeline->run();
73
74                 self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
75
76                 self::assertXml((string)$response->getBody(), 'statuses');
77         }
78
79         /**
80          * Test the api_statuses_user_timeline() function with an unallowed user.
81          *
82          * @return void
83          */
84         public function testApiStatusesUserTimelineWithUnallowedUser()
85         {
86                 self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
87
88                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
89                 // BasicAuth::setCurrentUserID();
90                 // api_statuses_user_timeline('json');
91         }
92 }