Add feedback - avoid intermediate variables
This commit is contained in:
parent
adf0d7bc95
commit
301ac83ebf
42 changed files with 367 additions and 272 deletions
|
@ -17,8 +17,8 @@ class ActivitiesTest extends FixtureTest
|
|||
{
|
||||
$item = ['uid' => 0, 'uri-id' => 1];
|
||||
|
||||
$friendicaActivitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser());
|
||||
$result = $friendicaActivitiesFac->createFromUriId($item['uri-id'], $item['uid']);
|
||||
$result = (new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()))
|
||||
->createFromUriId($item['uri-id'], $item['uid']);
|
||||
|
||||
self::assertArrayHasKey('like', $result);
|
||||
self::assertArrayHasKey('dislike', $result);
|
||||
|
@ -36,8 +36,8 @@ class ActivitiesTest extends FixtureTest
|
|||
{
|
||||
$item = ['uid' => 0, 'uri-id' => 1];
|
||||
|
||||
$friendicaActivitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser());
|
||||
$result = $friendicaActivitiesFac->createFromUriId($item['uri-id'], $item['uid'], 'xml');
|
||||
$result = (new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()))
|
||||
->createFromUriId($item['uri-id'], $item['uid'], 'xml');
|
||||
|
||||
self::assertArrayHasKey('friendica:like', $result);
|
||||
self::assertArrayHasKey('friendica:dislike', $result);
|
||||
|
|
|
@ -20,9 +20,9 @@ class DirectMessageTest extends FixtureTest
|
|||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id']);
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
$directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()))
|
||||
->createFromMailId($id, ApiTest::SELF_USER['id'])
|
||||
->toArray();
|
||||
|
||||
self::assertEquals('item_title' . "\n" . 'item_body', $directMessage['text']);
|
||||
self::assertIsInt($directMessage['id']);
|
||||
|
@ -43,9 +43,9 @@ class DirectMessageTest extends FixtureTest
|
|||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'html');
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
$directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()))
|
||||
->createFromMailId($id, ApiTest::SELF_USER['id'], 'html')
|
||||
->toArray();
|
||||
|
||||
self::assertEquals('item_title', $directMessage['title']);
|
||||
self::assertEquals('<strong>item_body</strong>', $directMessage['text']);
|
||||
|
@ -62,9 +62,9 @@ class DirectMessageTest extends FixtureTest
|
|||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain');
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
$directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()))
|
||||
->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain')
|
||||
->toArray();
|
||||
|
||||
self::assertEquals('item_title', $directMessage['title']);
|
||||
self::assertEquals('item_body', $directMessage['text']);
|
||||
|
@ -84,9 +84,9 @@ class DirectMessageTest extends FixtureTest
|
|||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain', $$GETUSEROBJECTS$$);
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
$directMessage = (new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser()))
|
||||
->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain', $$GETUSEROBJECTS$$)
|
||||
->toArray();
|
||||
|
||||
self::assertTrue(!isset($directMessage['sender']));
|
||||
self::assertTrue(!isset($directMessage['recipient']));
|
||||
|
|
|
@ -15,6 +15,24 @@ use Friendica\Test\src\Module\Api\ApiTest;
|
|||
|
||||
class StatusTest extends FixtureTest
|
||||
{
|
||||
protected $statusFactory;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->statusFactory = new Status(
|
||||
DI::logger(),
|
||||
DI::dba(),
|
||||
DI::twitterUser(),
|
||||
new Hashtag(DI::logger()),
|
||||
new Media(DI::logger(), DI::baseUrl()),
|
||||
new Url(DI::logger()),
|
||||
new Mention(DI::logger(), DI::baseUrl()),
|
||||
new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser()),
|
||||
new Attachment(DI::logger()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_convert_item() function.
|
||||
*
|
||||
|
@ -22,16 +40,9 @@ class StatusTest extends FixtureTest
|
|||
*/
|
||||
public function testApiConvertItem()
|
||||
{
|
||||
$hashTagFac = new Hashtag(DI::logger());
|
||||
$mediaFac = new Media(DI::logger(), DI::baseUrl());
|
||||
$urlFac = new Url(DI::logger());
|
||||
$mentionFac = new Mention(DI::logger(), DI::baseUrl());
|
||||
$activitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser());
|
||||
$attachmentFac = new Attachment(DI::logger());
|
||||
|
||||
$statusFac = new Status(DI::logger(), DI::dba(), DI::twitterUser(), $hashTagFac, $mediaFac, $urlFac, $mentionFac, $activitiesFac, $attachmentFac);
|
||||
$statusObj = $statusFac->createFromItemId(13, ApiTest::SELF_USER['id']);
|
||||
$status = $statusObj->toArray();
|
||||
$status = $this->statusFactory
|
||||
->createFromItemId(13, ApiTest::SELF_USER['id'])
|
||||
->toArray();
|
||||
|
||||
self::assertStringStartsWith('item_title', $status['text']);
|
||||
self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $status['friendica_html']);
|
||||
|
@ -90,16 +101,9 @@ class StatusTest extends FixtureTest
|
|||
*/
|
||||
public function testApiGetEntititiesWithIncludeEntities()
|
||||
{
|
||||
$hashTagFac = new Hashtag(DI::logger());
|
||||
$mediaFac = new Media(DI::logger(), DI::baseUrl());
|
||||
$urlFac = new Url(DI::logger());
|
||||
$mentionFac = new Mention(DI::logger(), DI::baseUrl());
|
||||
$activitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser());
|
||||
$attachmentFac = new Attachment(DI::logger());
|
||||
|
||||
$statusFac = new Status(DI::logger(), DI::dba(), DI::twitterUser(), $hashTagFac, $mediaFac, $urlFac, $mentionFac, $activitiesFac, $attachmentFac);
|
||||
$statusObj = $statusFac->createFromItemId(13, ApiTest::SELF_USER['id'], true);
|
||||
$status = $statusObj->toArray();
|
||||
$status = $this->statusFactory
|
||||
->createFromItemId(13, ApiTest::SELF_USER['id'], true)
|
||||
->toArray();
|
||||
|
||||
self::assertIsArray($status['entities']);
|
||||
self::assertIsArray($status['extended_entities']);
|
||||
|
@ -114,19 +118,11 @@ class StatusTest extends FixtureTest
|
|||
*/
|
||||
public function testApiFormatItems()
|
||||
{
|
||||
$hashTagFac = new Hashtag(DI::logger());
|
||||
$mediaFac = new Media(DI::logger(), DI::baseUrl());
|
||||
$urlFac = new Url(DI::logger());
|
||||
$mentionFac = new Mention(DI::logger(), DI::baseUrl());
|
||||
$activitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser());
|
||||
$attachmentFac = new Attachment(DI::logger());
|
||||
|
||||
$statusFac = new Status(DI::logger(), DI::dba(), DI::twitterUser(), $hashTagFac, $mediaFac, $urlFac, $mentionFac, $activitiesFac, $attachmentFac);
|
||||
|
||||
$posts = DI::dba()->selectToArray('post-view', ['uri-id']);
|
||||
foreach ($posts as $item) {
|
||||
$statusObj = $statusFac->createFromUriId($item['uri-id'], ApiTest::SELF_USER['id']);
|
||||
$status = $statusObj->toArray();
|
||||
$status = $this->statusFactory
|
||||
->createFromUriId($item['uri-id'], ApiTest::SELF_USER['id'])
|
||||
->toArray();
|
||||
|
||||
self::assertIsInt($status['id']);
|
||||
self::assertIsString($status['text']);
|
||||
|
|
|
@ -31,9 +31,9 @@ class UserTest extends FixtureTest
|
|||
*/
|
||||
public function testApiGetUser()
|
||||
{
|
||||
$userFactory = new User(DI::logger(), DI::twitterStatus());
|
||||
$userObj = $userFactory->createFromUserId(ApiTest::SELF_USER['id']);
|
||||
$user = $userObj->toArray();
|
||||
$user = (new User(DI::logger(), DI::twitterStatus()))
|
||||
->createFromUserId(ApiTest::SELF_USER['id'])
|
||||
->toArray();
|
||||
|
||||
$this->assertSelfUser($user);
|
||||
}
|
||||
|
@ -114,9 +114,9 @@ class UserTest extends FixtureTest
|
|||
*/
|
||||
public function testApiGetUserWithWrongGetId()
|
||||
{
|
||||
$userFactory = new User(DI::logger(), DI::twitterStatus());
|
||||
$userObj = $userFactory->createFromUserId(-1);
|
||||
$user = $userObj->toArray();
|
||||
$user = (new User(DI::logger(), DI::twitterStatus()))
|
||||
->createFromUserId(-1)
|
||||
->toArray();
|
||||
|
||||
self::assertEquals(0, $user['id']);
|
||||
self::assertEquals(0, $user['uid']);
|
||||
|
|
|
@ -34,7 +34,8 @@ class SearchTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))->run();
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -51,8 +52,10 @@ class SearchTest extends ApiTest
|
|||
|
||||
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$search = new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $search->run(['searchstring' => 'item_body']);
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'searchstring' => 'item_body'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -70,8 +73,10 @@ class SearchTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(new NullLogger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$search = new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $search->run(['searchstring' => 'test']);
|
||||
$response = (new Search($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'searchstring' => 'test'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -66,17 +66,20 @@ class NotificationTest extends ApiTest
|
|||
</notes>
|
||||
XML;
|
||||
|
||||
$notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
|
||||
$response = $notification->run();
|
||||
$response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']))
|
||||
->run();
|
||||
|
||||
self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody());
|
||||
self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['text/xml'],
|
||||
ICanCreateResponses::X_HEADER => ['xml']
|
||||
], $response->getHeaders());
|
||||
}
|
||||
|
||||
public function testWithJsonResult()
|
||||
{
|
||||
$notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
|
||||
$response = $notification->run();
|
||||
$response = (new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -88,6 +91,9 @@ XML;
|
|||
self::assertIsString($note->msg);
|
||||
}
|
||||
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['application/json'],
|
||||
ICanCreateResponses::X_HEADER => ['json']
|
||||
], $response->getHeaders());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,10 @@ class DeleteTest extends ApiTest
|
|||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']);
|
||||
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'photo_id' => '709057080661a283a6aa598501504178'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -63,8 +65,10 @@ class DeleteTest extends ApiTest
|
|||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $delete->run(['photo_id' => '709057080661a283a6aa598501504178']);
|
||||
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'photo_id' => '709057080661a283a6aa598501504178'
|
||||
]);
|
||||
|
||||
$responseText = (string)$response->getBody();
|
||||
|
||||
|
|
|
@ -32,22 +32,28 @@ class DeleteTest extends ApiTest
|
|||
public function testEmpty()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
|
||||
}
|
||||
|
||||
public function testWrong()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name']);
|
||||
(new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'album_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testValidWithDelete()
|
||||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$delete = new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $delete->run(['album' => 'test_album']);
|
||||
$response = (new Delete(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'test_album']
|
||||
);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -32,19 +32,27 @@ class UpdateTest extends ApiTest
|
|||
public function testEmpty()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
public function testTooFewArgs()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name']);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'album_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testWrongUpdate()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'album_name', 'album_new' => 'album_name']);
|
||||
(new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'album_name',
|
||||
'album_new' => 'album_name'
|
||||
]);
|
||||
}
|
||||
|
||||
public function testWithoutAuthenticatedUser()
|
||||
|
@ -56,7 +64,11 @@ class UpdateTest extends ApiTest
|
|||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../../datasets/photo/photo.fixture.php', DI::dba());
|
||||
|
||||
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run(['album' => 'test_album', 'album_new' => 'test_album_2']);
|
||||
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'album' => 'test_album',
|
||||
'album_new' => 'test_album_2'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ class ConfigTest extends ApiTest
|
|||
{
|
||||
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();
|
||||
$response = (new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -11,10 +11,13 @@ class VersionTest extends ApiTest
|
|||
{
|
||||
public function test()
|
||||
{
|
||||
$version = new Version(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
|
||||
$response = $version->run();
|
||||
$response = (new Version(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['application/json'],
|
||||
ICanCreateResponses::X_HEADER => ['json']
|
||||
], $response->getHeaders());
|
||||
self::assertEquals('"0.9.7"', $response->getBody());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,21 +11,27 @@ class TestTest extends ApiTest
|
|||
{
|
||||
public function testJson()
|
||||
{
|
||||
$test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
|
||||
$response = $test->run();
|
||||
$response = (new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['application/json'],
|
||||
ICanCreateResponses::X_HEADER => ['json']
|
||||
], $response->getHeaders());
|
||||
self::assertEquals('ok', $json);
|
||||
}
|
||||
|
||||
public function testXml()
|
||||
{
|
||||
$test = new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
|
||||
$response = $test->run();
|
||||
$response = (new Test(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']))
|
||||
->run();
|
||||
|
||||
self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['text/xml'],
|
||||
ICanCreateResponses::X_HEADER => ['xml']
|
||||
], $response->getHeaders());
|
||||
self::assertxml($response->getBody(), 'ok');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ class VerifyCredentialsTest extends ApiTest
|
|||
*/
|
||||
public function testApiAccountVerifyCredentials()
|
||||
{
|
||||
$verifyCredentials = new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $verifyCredentials->run();
|
||||
$response = (new VerifyCredentials(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -12,12 +12,15 @@ class RateLimitStatusTest extends ApiTest
|
|||
{
|
||||
public function testWithJson()
|
||||
{
|
||||
$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();
|
||||
$response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
$result = $this->toJson($response);
|
||||
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['application/json'],
|
||||
ICanCreateResponses::X_HEADER => ['json']
|
||||
], $response->getHeaders());
|
||||
self::assertEquals(150, $result->remaining_hits);
|
||||
self::assertEquals(150, $result->hourly_limit);
|
||||
self::assertIsInt($result->reset_time_in_seconds);
|
||||
|
@ -25,10 +28,13 @@ class RateLimitStatusTest extends ApiTest
|
|||
|
||||
public function testWithXml()
|
||||
{
|
||||
$rateLimitStatus = new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']);
|
||||
$response = $rateLimitStatus->run();
|
||||
$response = (new RateLimitStatus(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']))
|
||||
->run();
|
||||
|
||||
self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders());
|
||||
self::assertEquals([
|
||||
'Content-type' => ['text/xml'],
|
||||
ICanCreateResponses::X_HEADER => ['xml']
|
||||
], $response->getHeaders());
|
||||
self::assertXml($response->getBody(), 'hash');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,11 @@ class UpdateProfileTest extends ApiTest
|
|||
*/
|
||||
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']);
|
||||
$response = (new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => 'json']))
|
||||
->run([
|
||||
'name' => 'new_name',
|
||||
'description' => 'new_description'
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ class ListsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesFWithBlocks()
|
||||
{
|
||||
$lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
$response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ class AllTest extends ApiTest
|
|||
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$destroy = new All($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $destroy->run();
|
||||
$response = (new All($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ class ConversationTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$sent = new Conversation($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $sent->run([
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
$response = (new Conversation($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ class DestroyTest extends ApiTest
|
|||
public function testApiDirectMessagesDestroy()
|
||||
{
|
||||
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
||||
(new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))->run();
|
||||
(new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,10 +29,10 @@ class DestroyTest extends ApiTest
|
|||
*/
|
||||
public function testApiDirectMessagesDestroyWithVerbose()
|
||||
{
|
||||
$destroy = new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $destroy->run([
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
$response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -64,7 +65,10 @@ class DestroyTest extends ApiTest
|
|||
public function testApiDirectMessagesDestroyWithId()
|
||||
{
|
||||
$this->expectException(\Friendica\Network\HTTPException\BadRequestException::class);
|
||||
(new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))->run(['id' => 1]);
|
||||
(new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'id' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,12 +78,12 @@ class DestroyTest extends ApiTest
|
|||
*/
|
||||
public function testApiDirectMessagesDestroyWithIdAndVerbose()
|
||||
{
|
||||
$destroy = new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $destroy->run([
|
||||
'id' => 1,
|
||||
'friendica_parenturi' => 'parent_uri',
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
$response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'id' => 1,
|
||||
'friendica_parenturi' => 'parent_uri',
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -98,11 +102,11 @@ class DestroyTest extends ApiTest
|
|||
$ids = DBA::selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$destroy = new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $destroy->run([
|
||||
'id' => $id,
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
$response = (new Destroy(DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'id' => $id,
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ class InboxTest extends ApiTest
|
|||
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$destroy = new Inbox($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $destroy->run();
|
||||
$response = (new Inbox($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ class NewDMTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$newDm = new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $newDm->run();
|
||||
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
self::assertEmpty((string)$response->getBody());
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ class NewDMTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$newDm = new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $newDm->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 43
|
||||
]);
|
||||
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 43
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -73,11 +73,11 @@ class NewDMTest extends ApiTest
|
|||
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$newDm = new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $newDm->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 44
|
||||
]);
|
||||
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 44
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -97,12 +97,12 @@ class NewDMTest extends ApiTest
|
|||
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$newDm = new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $newDm->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 44,
|
||||
'title' => 'message_title',
|
||||
]);
|
||||
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 44,
|
||||
'title' => 'message_title',
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -123,12 +123,12 @@ class NewDMTest extends ApiTest
|
|||
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$newDm = new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']);
|
||||
$response = $newDm->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 44,
|
||||
'title' => 'message_title',
|
||||
]);
|
||||
$response = (new NewDM($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']))
|
||||
->run([
|
||||
'text' => 'message_text',
|
||||
'user_id' => 44,
|
||||
'title' => 'message_title',
|
||||
]);
|
||||
|
||||
self::assertXml((string)$response->getBody(), 'direct-messages');
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ class SentTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$sent = new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']);
|
||||
$response = $sent->run([
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
$response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'json']))
|
||||
->run([
|
||||
'friendica_verbose' => true,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -39,8 +39,8 @@ class SentTest extends ApiTest
|
|||
{
|
||||
$directMessage = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
|
||||
$sent = new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']);
|
||||
$response = $sent->run();
|
||||
$response = (new Sent($directMessage, DI::dba(), DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']))
|
||||
->run();
|
||||
|
||||
self::assertXml((string)$response->getBody(), 'direct-messages');
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ class CreateTest extends ApiTest
|
|||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$create->run();
|
||||
(new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,8 +31,10 @@ class CreateTest extends ApiTest
|
|||
*/
|
||||
public function testApiFavoritesCreateDestroyWithCreateAction()
|
||||
{
|
||||
$create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $create->run(['id' => 3]);
|
||||
$response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'id' => 3
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -46,8 +48,10 @@ class CreateTest extends ApiTest
|
|||
*/
|
||||
public function testApiFavoritesCreateDestroyWithCreateActionAndRss()
|
||||
{
|
||||
$create = new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => ICanCreateResponses::TYPE_RSS]);
|
||||
$response = $create->run(['id' => 3]);
|
||||
$response = (new Create(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => ICanCreateResponses::TYPE_RSS]))
|
||||
->run([
|
||||
'id' => 3
|
||||
]);
|
||||
|
||||
self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ class DestroyTest extends ApiTest
|
|||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$destroy->run();
|
||||
(new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,8 +30,10 @@ class DestroyTest extends ApiTest
|
|||
*/
|
||||
public function testApiFavoritesCreateDestroyWithDestroyAction()
|
||||
{
|
||||
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $destroy->run(['id' => 3]);
|
||||
$response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'id' => 3
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ class FavoritesTest extends ApiTest
|
|||
*/
|
||||
public function testApiFavorites()
|
||||
{
|
||||
$favorites = new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $favorites->run([
|
||||
'page' => -1,
|
||||
'max_id' => 10,
|
||||
]);
|
||||
$response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'page' => -1,
|
||||
'max_id' => 10,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -37,8 +37,9 @@ class FavoritesTest extends ApiTest
|
|||
*/
|
||||
public function testApiFavoritesWithRss()
|
||||
{
|
||||
$favorites = new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]);
|
||||
$response = $favorites->run();
|
||||
$response = (new Favorites(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [
|
||||
'extension' => ICanCreateResponses::TYPE_RSS
|
||||
]))->run();
|
||||
|
||||
self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ class ListsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesFWithFollowers()
|
||||
{
|
||||
$lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
$response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ class ListsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesFWithFriends()
|
||||
{
|
||||
$lists = new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
$response = (new Lists(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ class IncomingTest extends ApiTest
|
|||
*/
|
||||
public function testApiFriendshipsIncoming()
|
||||
{
|
||||
$lists = new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $lists->run();
|
||||
$response = (new Incoming(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ class StatusesTest extends ApiTest
|
|||
{
|
||||
$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();
|
||||
(new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,8 +28,12 @@ class StatusesTest extends ApiTest
|
|||
*/
|
||||
public function testApiListsStatusesWithListId()
|
||||
{
|
||||
$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]);
|
||||
$response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'list_id' => 1,
|
||||
'page' => -1,
|
||||
'max_id' => 10
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -44,8 +48,10 @@ class StatusesTest extends ApiTest
|
|||
*/
|
||||
public function testApiListsStatusesWithListIdAndRss()
|
||||
{
|
||||
$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]);
|
||||
$response = (new Statuses(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => 'rss']))
|
||||
->run([
|
||||
'list_id' => 1
|
||||
]);
|
||||
|
||||
self::assertXml((string)$response->getBody());
|
||||
}
|
||||
|
|
|
@ -19,8 +19,9 @@ class UploadTest extends ApiTest
|
|||
public function testApiMediaUpload()
|
||||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
$upload = new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$upload->run();
|
||||
|
||||
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,7 +33,9 @@ class UploadTest extends ApiTest
|
|||
{
|
||||
$this->expectException(UnauthorizedException::class);
|
||||
AuthTestConfig::$authenticated = false;
|
||||
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
|
||||
|
||||
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +52,9 @@ class UploadTest extends ApiTest
|
|||
'tmp_name' => 'tmp_name'
|
||||
]
|
||||
];
|
||||
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
|
||||
|
||||
(new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +76,8 @@ class UploadTest extends ApiTest
|
|||
]
|
||||
];
|
||||
|
||||
$response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))->run();
|
||||
$response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
|
||||
$media = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ class SavedSearchesTest extends ApiTest
|
|||
{
|
||||
public function test()
|
||||
{
|
||||
$savedSearch = new SavedSearches(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']);
|
||||
$response = $savedSearch->run();
|
||||
$response = (new SavedSearches(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']))
|
||||
->run();
|
||||
|
||||
$result = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ class DestroyTest extends ApiTest
|
|||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$destroy->run();
|
||||
(new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,8 +45,10 @@ class DestroyTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesDestroyWithId()
|
||||
{
|
||||
$destroy = new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $destroy->run(['id' => 1]);
|
||||
$response = (new Destroy(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'id' => 1
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -17,8 +17,10 @@ class MentionsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesMentions()
|
||||
{
|
||||
$mentions = new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $mentions->run(['max_id' => 10]);
|
||||
$response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'max_id' => 10
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -33,8 +35,10 @@ class MentionsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesMentionsWithNegativePage()
|
||||
{
|
||||
$mentions = new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $mentions->run(['page' => -2]);
|
||||
$response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'page' => -2
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -63,8 +67,10 @@ class MentionsTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesMentionsWithRss()
|
||||
{
|
||||
$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]);
|
||||
$response = $mentions->run(['page' => -2]);
|
||||
$response = (new Mentions(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]))
|
||||
->run([
|
||||
'page' => -2
|
||||
]);
|
||||
|
||||
self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
|
||||
|
||||
|
|
|
@ -17,8 +17,10 @@ class NetworkPublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesNetworkpublicTimeline()
|
||||
{
|
||||
$networkPublicTimeline = new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $networkPublicTimeline->run(['max_id' => 10]);
|
||||
$response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'max_id' => 10
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -37,8 +39,10 @@ class NetworkPublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesNetworkpublicTimelineWithNegativePage()
|
||||
{
|
||||
$networkPublicTimeline = new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $networkPublicTimeline->run(['page' => -2]);
|
||||
$response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'page' => -2
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -71,8 +75,11 @@ class NetworkPublicTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesNetworkpublicTimelineWithRss()
|
||||
{
|
||||
$networkPublicTimeline = new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_RSS]);
|
||||
$response = $networkPublicTimeline->run(['page' => -2]);
|
||||
$response = (new NetworkPublicTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [
|
||||
'extension' => ICanCreateResponses::TYPE_RSS
|
||||
]))->run([
|
||||
'page' => -2
|
||||
]);
|
||||
|
||||
self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ class RetweetTest extends ApiTest
|
|||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$retweet = new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$retweet->run();
|
||||
(new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,8 +45,10 @@ class RetweetTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesRepeatWithId()
|
||||
{
|
||||
$retweet = new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $retweet->run(['id' => 1]);
|
||||
$response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'id' => 1
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -60,8 +62,10 @@ class RetweetTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesRepeatWithSharedId()
|
||||
{
|
||||
$retweet = new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $retweet->run(['id' => 5]);
|
||||
$response = (new Retweet(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'id' => 5
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -19,8 +19,9 @@ class ShowTest extends ApiTest
|
|||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$show->run();
|
||||
|
||||
(new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,8 +31,10 @@ class ShowTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesShowWithId()
|
||||
{
|
||||
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $show->run(['id' => 1]);
|
||||
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'id' => 1
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -46,8 +49,11 @@ class ShowTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesShowWithConversation()
|
||||
{
|
||||
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $show->run(['id' => 1, 'conversation' => 1]);
|
||||
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'id' => 1,
|
||||
'conversation' => 1
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ class UpdateTest extends ApiTest
|
|||
]
|
||||
];
|
||||
|
||||
$show = new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $show->run([
|
||||
'status' => 'Status content #friendica',
|
||||
'in_reply_to_status_id' => 0,
|
||||
'lat' => 48,
|
||||
'long' => 7,
|
||||
]);
|
||||
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'status' => 'Status content #friendica',
|
||||
'in_reply_to_status_id' => 0,
|
||||
'lat' => 48,
|
||||
'long' => 7,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -50,10 +50,10 @@ class UpdateTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesUpdateWithHtml()
|
||||
{
|
||||
$show = new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]);
|
||||
$response = $show->run([
|
||||
'htmlstatus' => '<b>Status content</b>',
|
||||
]);
|
||||
$response = (new Update(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST]))
|
||||
->run([
|
||||
'htmlstatus' => '<b>Status content</b>',
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
|
|
@ -17,14 +17,13 @@ class UserTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesUserTimeline()
|
||||
{
|
||||
$networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
|
||||
$response = $networkPublicTimeline->run([
|
||||
'user_id' => 42,
|
||||
'max_id' => 10,
|
||||
'exclude_replies' => true,
|
||||
'conversation_id' => 7,
|
||||
]);
|
||||
$response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'user_id' => 42,
|
||||
'max_id' => 10,
|
||||
'exclude_replies' => true,
|
||||
'conversation_id' => 7,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -43,12 +42,11 @@ class UserTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesUserTimelineWithNegativePage()
|
||||
{
|
||||
$networkPublicTimeline = new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
|
||||
$response = $networkPublicTimeline->run([
|
||||
'user_id' => 42,
|
||||
'page' => -2,
|
||||
]);
|
||||
$response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'user_id' => 42,
|
||||
'page' => -2,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -67,9 +65,9 @@ class UserTimelineTest extends ApiTest
|
|||
*/
|
||||
public function testApiStatusesUserTimelineWithRss()
|
||||
{
|
||||
$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]);
|
||||
|
||||
$response = $networkPublicTimeline->run();
|
||||
$response = (new UserTimeline(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [
|
||||
'extension' => ICanCreateResponses::TYPE_RSS
|
||||
]))->run();
|
||||
|
||||
self::assertEquals(ICanCreateResponses::TYPE_RSS, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ class LookupTest extends ApiTest
|
|||
{
|
||||
$this->expectException(NotFoundException::class);
|
||||
|
||||
$lookup = new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$lookup->run();
|
||||
(new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,8 +30,10 @@ class LookupTest extends ApiTest
|
|||
*/
|
||||
public function testApiUsersLookupWithUserId()
|
||||
{
|
||||
$lookup = new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$respone = $lookup->run(['user_id' => static::OTHER_USER['id']]);
|
||||
$respone = (new Lookup(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'user_id' => static::OTHER_USER['id']
|
||||
]);
|
||||
|
||||
$json = $this->toJson($respone);
|
||||
|
||||
|
|
|
@ -18,8 +18,10 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiUsersSearch()
|
||||
{
|
||||
$search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$respone = $search->run(['q' => static::OTHER_USER['name']]);
|
||||
$respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run([
|
||||
'q' => static::OTHER_USER['name']
|
||||
]);
|
||||
|
||||
$json = $this->toJson($respone);
|
||||
|
||||
|
@ -33,8 +35,11 @@ class SearchTest extends ApiTest
|
|||
*/
|
||||
public function testApiUsersSearchWithXml()
|
||||
{
|
||||
$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]);
|
||||
$respone = $search->run(['q' => static::OTHER_USER['name']]);
|
||||
$respone = (new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [
|
||||
'extension' => ICanCreateResponses::TYPE_XML
|
||||
]))->run([
|
||||
'q' => static::OTHER_USER['name']
|
||||
]);
|
||||
|
||||
self::assertXml((string)$respone->getBody(), 'users');
|
||||
}
|
||||
|
@ -48,7 +53,7 @@ class SearchTest extends ApiTest
|
|||
{
|
||||
$this->expectException(BadRequestException::class);
|
||||
|
||||
$search = new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$search->run();
|
||||
(new Search(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ class ShowTest extends ApiTest
|
|||
*/
|
||||
public function testApiUsersShow()
|
||||
{
|
||||
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]);
|
||||
$response = $show->run();
|
||||
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET]))
|
||||
->run();
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
|
@ -37,8 +37,9 @@ class ShowTest extends ApiTest
|
|||
*/
|
||||
public function testApiUsersShowWithXml()
|
||||
{
|
||||
$show = new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], ['extension' => ICanCreateResponses::TYPE_XML]);
|
||||
$response = $show->run();
|
||||
$response = (new Show(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::GET], [
|
||||
'extension' => ICanCreateResponses::TYPE_XML
|
||||
]))->run();
|
||||
|
||||
self::assertEquals(ICanCreateResponses::TYPE_XML, $response->getHeaderLine(ICanCreateResponses::X_HEADER));
|
||||
|
||||
|
|
|
@ -14,10 +14,8 @@ class NodeInfoTest extends FixtureTest
|
|||
{
|
||||
public function testNodeInfo110()
|
||||
{
|
||||
$response = new Response();
|
||||
|
||||
$nodeinfo = new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
|
||||
$response = $nodeinfo->run();
|
||||
$response = (new NodeInfo110(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
|
||||
->run();
|
||||
|
||||
self::assertJson($response->getBody());
|
||||
self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
|
@ -37,10 +35,8 @@ class NodeInfoTest extends FixtureTest
|
|||
|
||||
public function testNodeInfo120()
|
||||
{
|
||||
$response = new Response();
|
||||
|
||||
$nodeinfo = new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
|
||||
$response = $nodeinfo->run();
|
||||
$response = (new NodeInfo120(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
|
||||
->run();
|
||||
|
||||
self::assertJson($response->getBody());
|
||||
self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
|
@ -59,10 +55,8 @@ class NodeInfoTest extends FixtureTest
|
|||
|
||||
public function testNodeInfo210()
|
||||
{
|
||||
$response = new Response();
|
||||
|
||||
$nodeinfo = new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), $response, DI::config(), []);
|
||||
$response = $nodeinfo->run();
|
||||
$response = (new NodeInfo210(DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), DI::config(), []))
|
||||
->run();
|
||||
|
||||
self::assertJson($response->getBody());
|
||||
self::assertEquals(['Content-type' => ['application/json; charset=utf-8'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders());
|
||||
|
|
Loading…
Reference in a new issue