3 namespace Friendica\Test\src\Module\Api\Mastodon;
5 use Friendica\Test\src\Module\Api\ApiTest;
7 class SearchTest extends ApiTest
10 * Test the api_search() function.
14 public function testApiSearch()
16 self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
19 $_REQUEST['q'] = 'reply';
20 $_REQUEST['max_id'] = 10;
21 $result = api_search('json');
22 foreach ($result['status'] as $status) {
23 self::assertStatus($status);
24 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
30 * Test the api_search() function a count parameter.
34 public function testApiSearchWithCount()
36 self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
39 $_REQUEST['q'] = 'reply';
40 $_REQUEST['count'] = 20;
41 $result = api_search('json');
42 foreach ($result['status'] as $status) {
43 self::assertStatus($status);
44 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
50 * Test the api_search() function with an rpp parameter.
54 public function testApiSearchWithRpp()
56 self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
59 $_REQUEST['q'] = 'reply';
60 $_REQUEST['rpp'] = 20;
61 $result = api_search('json');
62 foreach ($result['status'] as $status) {
63 self::assertStatus($status);
64 self::assertStringContainsStringIgnoringCase('reply', $status['text'], '', true);
70 * Test the api_search() function with an q parameter contains hashtag.
71 * @doesNotPerformAssertions
73 public function testApiSearchWithHashtag()
75 self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
78 $_REQUEST['q'] = '%23friendica';
79 $result = api_search('json');
80 foreach ($result['status'] as $status) {
81 self::assertStatus($status);
82 self::assertStringContainsStringIgnoringCase('#friendica', $status['text'], '', true);
88 * Test the api_search() function with an exclude_replies parameter.
89 * @doesNotPerformAssertions
91 public function testApiSearchWithExcludeReplies()
93 self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
96 $_REQUEST['max_id'] = 10;
97 $_REQUEST['exclude_replies'] = true;
98 $_REQUEST['q'] = 'friendica';
99 $result = api_search('json');
100 foreach ($result['status'] as $status) {
101 self::assertStatus($status);
107 * Test the api_search() function without an authenticated user.
111 public function testApiSearchWithUnallowedUser()
113 self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
115 // $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
116 // BasicAuth::setCurrentUserID();
117 // api_search('json');
121 * Test the api_search() function without any GET query parameter.
125 public function testApiSearchWithoutQuery()
127 self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
129 // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
130 // api_search('json');