X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Flegacy%2FApiTest.php;h=fea2bd5f1bf4b07bc5baaec89dca5091ebc759a5;hb=732ef70b8d1b0a8334c1d1444ce1ed376a1760e1;hp=f4a6d3905e0ae3091e96bef00be71f9d145b74d8;hpb=33c8872c657432dcb6840ce30876e64c3fa52b36;p=friendica.git diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index f4a6d3905e..fea2bd5f1b 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -7,19 +7,13 @@ namespace Friendica\Test\legacy; use Friendica\App; 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'; @@ -118,55 +112,6 @@ class ApiTest extends FixtureTest BasicAuth::setCurrentUserID($this->selfUser['id']); } - /** - * Assert that an user array contains expected keys. - * - * @param array $user User array - * - * @return void - */ - private function assertSelfUser(array $user) - { - self::assertEquals($this->selfUser['id'], $user['uid']); - self::assertEquals($this->selfUser['id'], $user['cid']); - self::assertEquals(1, $user['self']); - self::assertEquals('DFRN', $user['location']); - self::assertEquals($this->selfUser['name'], $user['name']); - self::assertEquals($this->selfUser['nick'], $user['screen_name']); - self::assertEquals('dfrn', $user['network']); - self::assertTrue($user['verified']); - } - - /** - * Assert that an user array contains expected keys. - * - * @param array $user User array - * - * @return void - */ - private function assertOtherUser(array $user = []) - { - self::assertEquals($this->otherUser['id'], $user['id']); - self::assertEquals($this->otherUser['id'], $user['id_str']); - self::assertEquals($this->otherUser['name'], $user['name']); - self::assertEquals($this->otherUser['nick'], $user['screen_name']); - self::assertFalse($user['verified']); - } - - /** - * Assert that a status array contains expected keys. - * - * @param array $status Status array - * - * @return void - */ - private function assertStatus(array $status = []) - { - self::assertIsString($status['text'] ?? ''); - self::assertIsInt($status['id'] ?? ''); - // We could probably do more checks here. - } - /** * Assert that a list array contains expected keys. * @@ -198,25 +143,6 @@ class ApiTest extends FixtureTest // We could probably do more checks here. } - /** - * Get the path to a temporary empty PNG image. - * - * @return string Path - */ - private function getTempImage() - { - $tmpFile = tempnam(sys_get_temp_dir(), 'tmp_file'); - file_put_contents( - $tmpFile, - base64_decode( - // Empty 1x1 px PNG image - 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==' - ) - ); - - return $tmpFile; - } - /** * Test the api_user() function. * @@ -998,74 +924,7 @@ class ApiTest extends FixtureTest $this->markTestIncomplete(); } - /** - * Test the \Friendica\Module\Api\Twitter\Media\Upload module. - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testApiMediaUpload() - { - $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), $_SERVER))->run(); - } - - /** - * Test the \Friendica\Module\Api\Twitter\Media\Upload module without an authenticated user. - * - * @return void - */ - public function testApiMediaUploadWithoutAuthenticatedUser() - { - $this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class); - BasicAuth::setCurrentUserID(); - $_SESSION['authenticated'] = false; - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), $_SERVER))->run(); - } - - /** - * Test the \Friendica\Module\Api\Twitter\Media\Upload module with an invalid uploaded media. - * - * @return void - */ - public function testApiMediaUploadWithMedia() - { - $this->expectException(\Friendica\Network\HTTPException\InternalServerErrorException::class); - $_FILES = [ - 'media' => [ - 'id' => 666, - 'tmp_name' => 'tmp_name' - ] - ]; - (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), $_SERVER))->run(); - } - - /** - * Test the \Friendica\Module\Api\Twitter\Media\Upload module with an valid uploaded media. - * - * @return void - */ - public function testApiMediaUploadWithValidMedia() - { - $_FILES = [ - 'media' => [ - 'id' => 666, - 'size' => 666, - 'width' => 666, - 'height' => 666, - 'tmp_name' => $this->getTempImage(), - 'name' => 'spacer.png', - 'type' => 'image/png' - ] - ]; - - $response = (new Upload(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), $_SERVER))->run(); - $media = json_decode($response->getBody(), true); - self::assertEquals('image/png', $media['image']['image_type']); - self::assertEquals(1, $media['image']['w']); - self::assertEquals(1, $media['image']['h']); - self::assertNotEmpty($media['image']['friendica_preview_url']); - } /** * Test the api_statuses_repeat() function.