mirror of
https://github.com/friendica/friendica
synced 2025-04-24 00:30:11 +00:00
Reenable Twitter/Media Post tests
This commit is contained in:
parent
f84c696925
commit
204b8b6e49
5 changed files with 135 additions and 117 deletions
|
@ -80,23 +80,4 @@ class UploadTest extends ApiTest
|
|||
self::assertEquals(1, $media->image->h);
|
||||
self::assertNotEmpty($media->image->friendica_preview_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
|
109
tests/src/Module/Api/Twitter/Statuses/UpdateTest.php
Normal file
109
tests/src/Module/Api/Twitter/Statuses/UpdateTest.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Statuses;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Statuses\Update;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class UpdateTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_statuses_update() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesUpdate()
|
||||
{
|
||||
$_FILES = [
|
||||
'media' => [
|
||||
'id' => 666,
|
||||
'size' => 666,
|
||||
'width' => 666,
|
||||
'height' => 666,
|
||||
'tmp_name' => $this->getTempImage(),
|
||||
'name' => 'spacer.png',
|
||||
'type' => 'image/png'
|
||||
]
|
||||
];
|
||||
|
||||
$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,
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
self::assertStatus($json);
|
||||
self::assertContains('Status content #friendica', $json->text);
|
||||
self::assertContains('Status content #', $json->statusnet_html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_update() function with an HTML status.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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>',
|
||||
]);
|
||||
|
||||
$json = $this->toJson($response);
|
||||
|
||||
self::assertStatus($json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_update() function without an authenticated user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesUpdateWithoutAuthenticatedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||
|
||||
/*
|
||||
$this->expectException(\Friendica\Network\HTTPException\UnauthorizedException::class);
|
||||
BasicAuth::setCurrentUserID();
|
||||
$_SESSION['authenticated'] = false;
|
||||
api_statuses_update('json');
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_update() function with a parent status.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesUpdateWithParent()
|
||||
{
|
||||
$this->markTestIncomplete('This triggers an exit() somewhere and kills PHPUnit.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_update() function with a media_ids parameter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesUpdateWithMediaIds()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_update() function with the throttle limit reached.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiStatusesUpdateWithDayThrottleReached()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue