]> git.mxchange.org Git - friendica.git/blob - tests/src/Module/Api/Twitter/Statuses/MentionsTest.php
Reenable Twitter/Mentions tests
[friendica.git] / tests / src / Module / Api / Twitter / Statuses / MentionsTest.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\Mentions;
9 use Friendica\Test\src\Module\Api\ApiTest;
10
11 class MentionsTest extends ApiTest
12 {
13         /**
14          * Test the api_statuses_mentions() function.
15          *
16          * @return void
17          */
18         public function testApiStatusesMentions()
19         {
20                 $mentions = new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
21                 $response = $mentions->run(['max_id' => 10]);
22
23                 $json = $this->toJson($response);
24
25                 self::assertEmpty($json);
26                 // We should test with mentions in the database.
27         }
28
29         /**
30          * Test the api_statuses_mentions() function with a negative page parameter.
31          *
32          * @return void
33          */
34         public function testApiStatusesMentionsWithNegativePage()
35         {
36                 $mentions = new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
37                 $response = $mentions->run(['page' => -2]);
38
39                 $json = $this->toJson($response);
40
41                 self::assertEmpty($json);
42                 // We should test with mentions in the database.
43         }
44
45         /**
46          * Test the api_statuses_mentions() function with an unallowed user.
47          *
48          * @return void
49          */
50         public function testApiStatusesMentionsWithUnallowedUser()
51         {
52                 self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
53
54                 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
55                 // BasicAuth::setCurrentUserID();
56                 // api_statuses_mentions('json');
57         }
58
59         /**
60          * Test the api_statuses_mentions() function with an RSS result.
61          *
62          * @return void
63          */
64         public function testApiStatusesMentionsWithRss()
65         {
66                 $mentions = new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]);
67                 $response = $mentions->run(['page' => -2]);
68
69                 self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
70
71                 self::assertXml((string)$response->getBody(), 'statuses');
72         }
73 }