mirror of
https://github.com/friendica/friendica
synced 2024-11-10 03:02:54 +00:00
Reenable Twitter/Search test
This commit is contained in:
parent
616cf012f9
commit
e10045f13f
2 changed files with 26 additions and 15 deletions
|
@ -42,15 +42,15 @@ class Search extends BaseApi
|
||||||
|
|
||||||
$userlist = [];
|
$userlist = [];
|
||||||
|
|
||||||
if (!empty($_GET['q'])) {
|
if (!empty($request['q'])) {
|
||||||
$contacts = Contact::selectToArray(
|
$contacts = Contact::selectToArray(
|
||||||
['id'],
|
['id'],
|
||||||
[
|
[
|
||||||
'`uid` = 0 AND (`name` = ? OR `nick` = ? OR `url` = ? OR `addr` = ?)',
|
'`uid` = 0 AND (`name` = ? OR `nick` = ? OR `url` = ? OR `addr` = ?)',
|
||||||
$_GET['q'],
|
$request['q'],
|
||||||
$_GET['q'],
|
$request['q'],
|
||||||
$_GET['q'],
|
$request['q'],
|
||||||
$_GET['q'],
|
$request['q'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -63,12 +63,12 @@ class Search extends BaseApi
|
||||||
}
|
}
|
||||||
$userlist = ['users' => $userlist];
|
$userlist = ['users' => $userlist];
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundException('User ' . $_GET['q'] . ' not found.');
|
throw new NotFoundException('User ' . $request['q'] . ' not found.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException('No search term specified.');
|
throw new BadRequestException('No search term specified.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->exit('users', ['user' => $userlist], $this->parameters['extension'] ?? null);
|
$this->response->exit('users', $userlist, $this->parameters['extension'] ?? null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\Twitter\Users;
|
namespace Friendica\Test\src\Module\Api\Twitter\Users;
|
||||||
|
|
||||||
|
use Friendica\App\Router;
|
||||||
|
use Friendica\Capabilities\ICanCreateResponses;
|
||||||
|
use Friendica\DI;
|
||||||
|
use Friendica\Module\Api\Twitter\Users\Search;
|
||||||
|
use Friendica\Network\HTTPException\BadRequestException;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
|
|
||||||
class SearchTest extends ApiTest
|
class SearchTest extends ApiTest
|
||||||
|
@ -13,9 +18,12 @@ class SearchTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiUsersSearch()
|
public function testApiUsersSearch()
|
||||||
{
|
{
|
||||||
// $_GET['q'] = 'othercontact';
|
$search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||||
// $result = api_users_search('json');
|
$respone = $search->run(['q' => static::OTHER_USER['name']]);
|
||||||
// self::assertOtherUser($result['users'][0]);
|
|
||||||
|
$json = $this->toJson($respone);
|
||||||
|
|
||||||
|
self::assertOtherUser($json[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,9 +33,10 @@ class SearchTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiUsersSearchWithXml()
|
public function testApiUsersSearchWithXml()
|
||||||
{
|
{
|
||||||
// $_GET['q'] = 'othercontact';
|
$search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_XML]);
|
||||||
// $result = api_users_search('xml');
|
$respone = $search->run(['q' => static::OTHER_USER['name']]);
|
||||||
// self::assertXml($result, 'users');
|
|
||||||
|
self::assertXml((string)$respone->getBody(), 'users');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +46,9 @@ class SearchTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiUsersSearchWithoutQuery()
|
public function testApiUsersSearchWithoutQuery()
|
||||||
{
|
{
|
||||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
$this->expectException(BadRequestException::class);
|
||||||
// api_users_search('json');
|
|
||||||
|
$search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||||
|
$search->run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue