Merge pull request #11069 from nupplaphil/feat/reenable_tests
Some Fixings & Reenabling some tests
This commit is contained in:
commit
e6a07832dd
|
@ -221,6 +221,16 @@ class ApiResponse extends Response
|
|||
$this->addContent($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around exit() for JSON only responses
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function exitWithJson(array $data)
|
||||
{
|
||||
$this->exit('content', ['content' => $data], static::TYPE_JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quit execution with the message that the endpoint isn't implemented
|
||||
*
|
||||
|
|
|
@ -52,6 +52,6 @@ class VerifyCredentials extends BaseApi
|
|||
|
||||
// @todo Support the source property,
|
||||
$account = DI::mstdnAccount()->createFromContactId($cdata['user'], $uid);
|
||||
System::jsonExit($account);
|
||||
$this->response->exitWithJson($account->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,22 +39,22 @@ class UpdateProfile extends BaseApi
|
|||
|
||||
$api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray();
|
||||
|
||||
if (!empty($_POST['name'])) {
|
||||
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $uid]);
|
||||
DBA::update('user', ['username' => $_POST['name']], ['uid' => $uid]);
|
||||
Contact::update(['name' => $_POST['name']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]);
|
||||
if (!empty($request['name'])) {
|
||||
DBA::update('profile', ['name' => $request['name']], ['uid' => $uid]);
|
||||
DBA::update('user', ['username' => $request['name']], ['uid' => $uid]);
|
||||
Contact::update(['name' => $request['name']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['name' => $request['name']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
if (isset($_POST['description'])) {
|
||||
DBA::update('profile', ['about' => $_POST['description']], ['uid' => $uid]);
|
||||
Contact::update(['about' => $_POST['description']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]);
|
||||
if (isset($request['description'])) {
|
||||
DBA::update('profile', ['about' => $request['description']], ['uid' => $uid]);
|
||||
Contact::update(['about' => $request['description']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['about' => $request['description']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
Profile::publishUpdate($uid);
|
||||
|
||||
$skip_status = $_REQUEST['skip_status'] ?? false;
|
||||
$skip_status = $request['skip_status'] ?? false;
|
||||
|
||||
$user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray();
|
||||
|
||||
|
|
|
@ -87,6 +87,6 @@ class Lists extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,6 @@ class Lists extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,6 @@ class Lists extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('lists', ['lists' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,6 @@ class Incoming extends ContactEndpoint
|
|||
|
||||
self::setLinkHeader();
|
||||
|
||||
System::jsonExit($return);
|
||||
$this->response->exit('incoming', ['incoming' => $return]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,23 +40,23 @@ class Statuses extends BaseApi
|
|||
BaseApi::checkAllowedScope(BaseApi::SCOPE_READ);
|
||||
$uid = BaseApi::getCurrentUserID();
|
||||
|
||||
if (empty($_REQUEST['list_id'])) {
|
||||
if (empty($request['list_id'])) {
|
||||
throw new BadRequestException('list_id not specified');
|
||||
}
|
||||
|
||||
// params
|
||||
$count = $_REQUEST['count'] ?? 20;
|
||||
$page = $_REQUEST['page'] ?? 1;
|
||||
$since_id = $_REQUEST['since_id'] ?? 0;
|
||||
$max_id = $_REQUEST['max_id'] ?? 0;
|
||||
$exclude_replies = (!empty($_REQUEST['exclude_replies']) ? 1 : 0);
|
||||
$conversation_id = $_REQUEST['conversation_id'] ?? 0;
|
||||
$count = $request['count'] ?? 20;
|
||||
$page = $request['page'] ?? 1;
|
||||
$since_id = $request['since_id'] ?? 0;
|
||||
$max_id = $request['max_id'] ?? 0;
|
||||
$exclude_replies = (!empty($request['exclude_replies']) ? 1 : 0);
|
||||
$conversation_id = $request['conversation_id'] ?? 0;
|
||||
|
||||
$start = max(0, ($page - 1) * $count);
|
||||
|
||||
$groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => 1]);
|
||||
$groups = DBA::selectToArray('group_member', ['contact-id'], ['gid' => $request['list_id']]);
|
||||
$gids = array_column($groups, 'contact-id');
|
||||
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'group-id' => $gids];
|
||||
$condition = ['uid' => $uid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'contact-id' => $gids];
|
||||
$condition = DBA::mergeConditions($condition, ["`id` > ?", $since_id]);
|
||||
|
||||
if ($max_id > 0) {
|
||||
|
@ -75,7 +75,7 @@ class Statuses extends BaseApi
|
|||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Post::selectForUser($uid, [], $condition, $params);
|
||||
|
||||
$include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true');
|
||||
$include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true');
|
||||
|
||||
$items = [];
|
||||
while ($status = DBA::fetch($statuses)) {
|
||||
|
|
|
@ -220,6 +220,55 @@ return [
|
|||
'network' => Protocol::DFRN,
|
||||
'location' => 'DFRN',
|
||||
],
|
||||
[
|
||||
'id' => 48,
|
||||
'uid' => 0,
|
||||
'uri-id' => 42,
|
||||
'name' => 'Self contact',
|
||||
'nick' => 'selfcontact',
|
||||
'self' => 0,
|
||||
'nurl' => 'http://localhost/profile/selfcontact',
|
||||
'url' => 'http://localhost/profile/selfcontact',
|
||||
'about' => 'User used in tests',
|
||||
'pending' => 0,
|
||||
'blocked' => 0,
|
||||
'rel' => Contact::FOLLOWER,
|
||||
'network' => Protocol::DFRN,
|
||||
'location' => 'DFRN',
|
||||
],
|
||||
],
|
||||
'apcontact' => [
|
||||
[
|
||||
"url" => "http://localhost/profile/selfcontact",
|
||||
"uri-id" => 1,
|
||||
"uuid" => "42",
|
||||
"type" => "Person",
|
||||
"following" => "http://localhost/following/selfcontact",
|
||||
"followers" => "http://localhost/followers/selfcontact",
|
||||
"inbox" => "http://localhost/inbox/selfcontact",
|
||||
"outbox" => "http://localhost/outbox/selfcontact",
|
||||
"sharedinbox" => "http://localhost/inbox",
|
||||
"manually-approve" => 1,
|
||||
"discoverable" => 0,
|
||||
"nick" => "selfcontact",
|
||||
"name" => "Self contact",
|
||||
"about" => "User used in tests",
|
||||
"xmpp" => null,
|
||||
"matrix" => null,
|
||||
"photo" => "http://localhost/photo/profile/admin.jpeg",
|
||||
"header" => null,
|
||||
"addr" => "selfcontact@localhost",
|
||||
"alias" => null,
|
||||
"pubkey" => "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzLquDFnFxNYZZFQNbA9f\nkgtUJpC+MPrhxhEsjxme1ivvE4itdPnCueBHifknUkwfmqormyeqr4TdoVbNuKRg\nj2QRBdtaGbUJLQVdbiTKFOmJIYMtV05WIIHEhUW84fwIXmF+6u3kbOw+sIjWY3OW\nwC/2+54HiYS2n8cddfwoZBim6Na8yyQI8pQSKqJ+I4gDfkGuoVex0svNPEv9liLE\nykpQ3PuoeLJV2Wex0Cy6FYPgcfH6xvvUVxh6e8w0w22jC3DJInfDrmbw5H7aUbf+\nMMwV3TVI6/CqTO0cLEOZUjsUwdm6lIV0O0fTsrkjU9G0bc0sLJl7n9i9ICDOKOMf\nCLaK2Pj2sVbpkzXJoufLUDf0oSftdVvN9jR9WYxRdnwsyF8N/xVTw8AsyHhkXawR\n3YDgi6i2uZj5kvG7GPBf7EPZ/MpbGhEZB+/GQuZuyhLdgFDSi/uX8STBmn1jI/zY\nTLZ8JCwMzFKAXAtYaBPklZBbcRyz9O1893MsAXO8d6ODTOkD324gAjRUtuOMscYc\nWV98NZIUSbqQrznmMoJn1fiMNVgx+UXOPkiZuDxnrr1T3vynKnl5LXmadx2YeoAf\nxPeCoDb0eJtCDLcsTZ9qlztaEaohPV+H3HBSpdItea7LgAbccILHPssk9tUgmHVl\na5yV8uFenhKKQ9g93Pt63LsCAwEAAQ==\n-----END PUBLIC KEY-----",
|
||||
"subscribe" => "/follow?url={uri}",
|
||||
"baseurl" => null,
|
||||
"gsid" => null,
|
||||
"generator" => "Friendica 'Siberian Iris' 2021.12-dev-1443",
|
||||
"following_count" => 0,
|
||||
"followers_count" => 0,
|
||||
"statuses_count" => 0,
|
||||
"updated" => "2021-11-19 19:17:59",
|
||||
],
|
||||
],
|
||||
'verb' => [
|
||||
[
|
||||
|
@ -778,6 +827,13 @@ return [
|
|||
'name' => 'Private list',
|
||||
],
|
||||
],
|
||||
'group_member' => [
|
||||
[
|
||||
'id' => 1,
|
||||
'gid' => 1,
|
||||
'contact-id' => 42,
|
||||
],
|
||||
],
|
||||
'search' => [
|
||||
[
|
||||
'id' => 1,
|
||||
|
|
|
@ -6,21 +6,14 @@
|
|||
namespace Friendica\Test\legacy;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\App\Router;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Module\Api\ApiResponse;
|
||||
use Friendica\Module\Api\Twitter\Media\Upload;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Security\BasicAuth;
|
||||
use Friendica\Test\FixtureTest;
|
||||
use Friendica\Util\Arrays;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Temporal;
|
||||
use Monolog\Handler\TestHandler;
|
||||
|
||||
require_once __DIR__ . '/../../include/api.php';
|
||||
|
|
|
@ -2,29 +2,39 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
|
||||
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\GNUSocial\GNUSocial\Config;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class ConfigTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_statusnet_config() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusnetConfig()
|
||||
{
|
||||
/*
|
||||
$result = api_statusnet_config('json');
|
||||
self::assertEquals('localhost', $result['config']['site']['server']);
|
||||
self::assertEquals('default', $result['config']['site']['theme']);
|
||||
self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $result['config']['site']['logo']);
|
||||
self::assertTrue($result['config']['site']['fancy']);
|
||||
self::assertEquals('en', $result['config']['site']['language']);
|
||||
self::assertEquals('UTC', $result['config']['site']['timezone']);
|
||||
self::assertEquals(200000, $result['config']['site']['textlimit']);
|
||||
self::assertEquals('false', $result['config']['site']['private']);
|
||||
self::assertEquals('false', $result['config']['site']['ssl']);
|
||||
self::assertEquals(30, $result['config']['site']['shorturllength']);
|
||||
*/
|
||||
DI::config()->set('system', 'ssl_policy', BaseURL::SSL_POLICY_FULL);
|
||||
|
||||
$config = new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $config->run();
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertEquals(1, 1);
|
||||
|
||||
self::assertEquals('localhost', $json->site->server);
|
||||
self::assertEquals('frio', $json->site->theme);
|
||||
self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $json->site->logo);
|
||||
self::assertTrue($json->site->fancy);
|
||||
self::assertEquals('en', $json->site->language);
|
||||
self::assertEquals('UTC', $json->site->timezone);
|
||||
self::assertEquals(200000, $json->site->textlimit);
|
||||
self::assertFalse($json->site->private);
|
||||
self::assertEquals('always', $json->site->ssl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Mastodon\Accounts\Statuses;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class StatusesTest extends ApiTest
|
||||
|
@ -11,6 +14,8 @@ class StatusesTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusShowWithJson()
|
||||
{
|
||||
self::markTestIncomplete('Needs Statuses to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $result = api_status_show('json', 1);
|
||||
// self::assertStatus($result['status']);
|
||||
}
|
||||
|
@ -20,6 +25,8 @@ class StatusesTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusShowWithXml()
|
||||
{
|
||||
self::markTestIncomplete('Needs Statuses to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $result = api_status_show('xml', 1);
|
||||
// self::assertXml($result, 'statuses');
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Mastodon\Accounts;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Mastodon\Accounts\VerifyCredentials;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class VerifyCredentialsTest extends ApiTest
|
||||
|
@ -13,7 +16,18 @@ class VerifyCredentialsTest extends ApiTest
|
|||
*/
|
||||
public function testApiAccountVerifyCredentials()
|
||||
{
|
||||
// self::assertArrayHasKey('user', api_account_verify_credentials('json'));
|
||||
$verifyCredentials = new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $verifyCredentials->run();
|
||||
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertEquals(48, $json->id);
|
||||
self::assertIsArray($json->emojis);
|
||||
self::assertIsArray($json->fields);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,6 +37,8 @@ class VerifyCredentialsTest extends ApiTest
|
|||
*/
|
||||
public function testApiAccountVerifyCredentialsWithoutAuthenticatedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs dynamic BasicAuth first');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
// BasicAuth::setCurrentUserID();
|
||||
// $_SESSION['authenticated'] = false;
|
||||
|
|
|
@ -13,6 +13,8 @@ class ConversationsTest extends ApiTest
|
|||
*/
|
||||
public function testApiConversationShow()
|
||||
{
|
||||
self::markTestIncomplete('Needs Conversations to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
||||
// api_conversation_show('json');
|
||||
}
|
||||
|
@ -24,6 +26,8 @@ class ConversationsTest extends ApiTest
|
|||
*/
|
||||
public function testApiConversationShowWithId()
|
||||
{
|
||||
self::markTestIncomplete('Needs Conversations to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
DI::args()->setArgv(['', '', '', 1]);
|
||||
$_REQUEST['max_id'] = 10;
|
||||
|
@ -43,6 +47,8 @@ class ConversationsTest extends ApiTest
|
|||
*/
|
||||
public function testApiConversationShowWithUnallowedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs Conversations to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
// BasicAuth::setCurrentUserID();
|
||||
// api_conversation_show('json');
|
||||
|
|
|
@ -13,6 +13,8 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiSearch()
|
||||
{
|
||||
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['q'] = 'reply';
|
||||
$_REQUEST['max_id'] = 10;
|
||||
|
@ -31,6 +33,8 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiSearchWithCount()
|
||||
{
|
||||
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['q'] = 'reply';
|
||||
$_REQUEST['count'] = 20;
|
||||
|
@ -49,6 +53,8 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiSearchWithRpp()
|
||||
{
|
||||
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['q'] = 'reply';
|
||||
$_REQUEST['rpp'] = 20;
|
||||
|
@ -66,6 +72,8 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiSearchWithHashtag()
|
||||
{
|
||||
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['q'] = '%23friendica';
|
||||
$result = api_search('json');
|
||||
|
@ -82,6 +90,8 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiSearchWithExcludeReplies()
|
||||
{
|
||||
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['max_id'] = 10;
|
||||
$_REQUEST['exclude_replies'] = true;
|
||||
|
@ -100,6 +110,8 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiSearchWithUnallowedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
// BasicAuth::setCurrentUserID();
|
||||
// api_search('json');
|
||||
|
@ -112,6 +124,8 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiSearchWithoutQuery()
|
||||
{
|
||||
self::markTestIncomplete('Needs Search to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
||||
// api_search('json');
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ class HomeTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesHomeTimeline()
|
||||
{
|
||||
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['max_id'] = 10;
|
||||
$_REQUEST['exclude_replies'] = true;
|
||||
|
@ -32,6 +34,8 @@ class HomeTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesHomeTimelineWithNegativePage()
|
||||
{
|
||||
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['page'] = -2;
|
||||
$result = api_statuses_home_timeline('json');
|
||||
|
@ -49,6 +53,8 @@ class HomeTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesHomeTimelineWithUnallowedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
BasicAuth::setCurrentUserID();
|
||||
|
@ -63,6 +69,8 @@ class HomeTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesHomeTimelineWithRss()
|
||||
{
|
||||
self::markTestIncomplete('Needs Home to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $result = api_statuses_home_timeline('rss');
|
||||
// self::assertXml($result, 'statuses');
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ class PublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesPublicTimeline()
|
||||
{
|
||||
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['max_id'] = 10;
|
||||
$_REQUEST['conversation_id'] = 1;
|
||||
|
@ -31,6 +33,8 @@ class PublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesPublicTimelineWithExcludeReplies()
|
||||
{
|
||||
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['max_id'] = 10;
|
||||
$_REQUEST['exclude_replies'] = true;
|
||||
|
@ -49,6 +53,8 @@ class PublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesPublicTimelineWithNegativePage()
|
||||
{
|
||||
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
/*
|
||||
$_REQUEST['page'] = -2;
|
||||
$result = api_statuses_public_timeline('json');
|
||||
|
@ -66,6 +72,8 @@ class PublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesPublicTimelineWithUnallowedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
// BasicAuth::setCurrentUserID();
|
||||
// api_statuses_public_timeline('json');
|
||||
|
@ -78,6 +86,8 @@ class PublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesPublicTimelineWithRss()
|
||||
{
|
||||
self::markTestIncomplete('Needs PublicTimeline to not set header during call (like at BaseApi::setLinkHeader');
|
||||
|
||||
// $result = api_statuses_public_timeline('rss');
|
||||
// self::assertXml($result, 'statuses');
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\Capabilities\ICanCreateResponses;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Account\RateLimitStatus;
|
||||
|
@ -11,7 +12,7 @@ class RateLimitStatusTest extends ApiTest
|
|||
{
|
||||
public function testWithJson()
|
||||
{
|
||||
$rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
|
||||
$rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $rateLimitStatus->run();
|
||||
|
||||
$result = json_decode($response->getBody());
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Account\UpdateProfile;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class UpdateProfileTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_account_update_profile() function.
|
||||
*/
|
||||
public function testApiAccountUpdateProfile()
|
||||
{
|
||||
$updateProfile = new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => 'json']);
|
||||
$response = $updateProfile->run(['name' => 'new_name', 'description' => 'new_description']);
|
||||
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertEquals('new_name', $json->name);
|
||||
self::assertEquals('new_description', $json->description);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
||||
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class UpdateTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_account_update_profile() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiAccountUpdateProfile()
|
||||
{
|
||||
/*
|
||||
$_POST['name'] = 'new_name';
|
||||
$_POST['description'] = 'new_description';
|
||||
$result = api_account_update_profile('json');
|
||||
// We can't use assertSelfUser() here because the user object is missing some properties.
|
||||
self::assertEquals($this->selfUser['id'], $result['user']['cid']);
|
||||
self::assertEquals('DFRN', $result['user']['location']);
|
||||
self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
|
||||
self::assertEquals('new_name', $result['user']['name']);
|
||||
self::assertEquals('new_description', $result['user']['description']);
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -2,30 +2,28 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Blocks;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Blocks\Lists;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class ListsTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_statuses_f() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesFWithBlocks()
|
||||
{
|
||||
// $result = api_statuses_f('blocks');
|
||||
// self::assertArrayHasKey('user', $result);
|
||||
}
|
||||
$lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
|
||||
/**
|
||||
* Test the api_blocks_list() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiBlocksList()
|
||||
{
|
||||
// $result = api_blocks_list('json');
|
||||
// self::assertArrayHasKey('user', $result);
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertIsArray($json->users);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,6 +33,8 @@ class ListsTest extends ApiTest
|
|||
*/
|
||||
public function testApiBlocksListWithUndefinedCursor()
|
||||
{
|
||||
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
|
||||
|
||||
// $_GET['cursor'] = 'undefined';
|
||||
// self::assertFalse(api_blocks_list('json'));
|
||||
}
|
||||
|
|
|
@ -2,30 +2,28 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Followers;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Followers\Lists;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class ListsTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_statuses_f() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesFWithFollowers()
|
||||
{
|
||||
// $result = api_statuses_f('followers');
|
||||
// self::assertArrayHasKey('user', $result);
|
||||
}
|
||||
$lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
|
||||
/**
|
||||
* Test the api_statuses_followers() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesFollowers()
|
||||
{
|
||||
// $result = api_statuses_followers('json');
|
||||
// self::assertArrayHasKey('user', $result);
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertIsArray($json->users);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,6 +33,8 @@ class ListsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesFollowersWithUndefinedCursor()
|
||||
{
|
||||
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
|
||||
|
||||
// $_GET['cursor'] = 'undefined';
|
||||
// self::assertFalse(api_statuses_followers('json'));
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Friends;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Friends\Lists;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class ListsTest extends ApiTest
|
||||
|
@ -13,9 +16,16 @@ class ListsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesFWithFriends()
|
||||
{
|
||||
// $_GET['page'] = -1;
|
||||
// $result = api_statuses_f('friends');
|
||||
// self::assertArrayHasKey('user', $result);
|
||||
$lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertIsArray($json->users);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,29 +35,9 @@ class ListsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesFWithUndefinedCursor()
|
||||
{
|
||||
self::markTestIncomplete('Needs refactoring of Lists - replace filter_input() with $request parameter checks');
|
||||
|
||||
// $_GET['cursor'] = 'undefined';
|
||||
// self::assertFalse(api_statuses_f('friends'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_friends() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesFriends()
|
||||
{
|
||||
// $result = api_statuses_friends('json');
|
||||
// self::assertArrayHasKey('user', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_friends() function an undefined cursor GET variable.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesFriendsWithUndefinedCursor()
|
||||
{
|
||||
// $_GET['cursor'] = 'undefined';
|
||||
// self::assertFalse(api_statuses_friends('json'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Friendships;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Friendships\Incoming;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class IncomingTest extends ApiTest
|
||||
|
@ -13,8 +16,16 @@ class IncomingTest extends ApiTest
|
|||
*/
|
||||
public function testApiFriendshipsIncoming()
|
||||
{
|
||||
// $result = api_friendships_incoming('json');
|
||||
// self::assertArrayHasKey('id', $result);
|
||||
$lists = new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertIsArray($json->ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +35,8 @@ class IncomingTest extends ApiTest
|
|||
*/
|
||||
public function testApiFriendshipsIncomingWithUndefinedCursor()
|
||||
{
|
||||
self::markTestIncomplete('Needs refactoring of Incoming - replace filter_input() with $request parameter checks');
|
||||
|
||||
// $_GET['cursor'] = 'undefined';
|
||||
// self::assertFalse(api_friendships_incoming('json'));
|
||||
}
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Lists;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Lists\Statuses;
|
||||
use Friendica\Network\HTTPException\BadRequestException;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class StatusesTest extends ApiTest
|
||||
|
@ -13,37 +17,41 @@ class StatusesTest extends ApiTest
|
|||
*/
|
||||
public function testApiListsStatuses()
|
||||
{
|
||||
// $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
||||
// api_lists_statuses('json');
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$lists->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_lists_statuses() function with a list ID.
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testApiListsStatusesWithListId()
|
||||
{
|
||||
/*
|
||||
$_REQUEST['list_id'] = 1;
|
||||
$_REQUEST['page'] = -1;
|
||||
$_REQUEST['max_id'] = 10;
|
||||
$result = api_lists_statuses('json');
|
||||
foreach ($result['status'] as $status) {
|
||||
self::assertStatus($status);
|
||||
$lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run(['list_id' => 1, 'page' => -1, 'max_id' => 10]);
|
||||
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
foreach ($json as $status) {
|
||||
self::assertIsString($status->text);
|
||||
self::assertIsInt($status->id);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_lists_statuses() function with a list ID and a RSS result.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiListsStatusesWithListIdAndRss()
|
||||
{
|
||||
// $_REQUEST['list_id'] = 1;
|
||||
// $result = api_lists_statuses('rss');
|
||||
// self::assertXml($result, 'statuses');
|
||||
$lists = new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']);
|
||||
$response = $lists->run(['list_id' => 1]);
|
||||
|
||||
self::assertXml((string)$response->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,6 +61,8 @@ class StatusesTest extends ApiTest
|
|||
*/
|
||||
public function testApiListsStatusesWithUnallowedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||
|
||||
// $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
// BasicAuth::setCurrentUserID();
|
||||
// api_lists_statuses('json');
|
||||
|
|
Loading…
Reference in New Issue
Block a user