mirror of
https://github.com/friendica/friendica
synced 2025-04-26 13:50:11 +00:00
Move Api\unsupported tests and remove dependency to System::jsonExit()
This commit is contained in:
parent
c0219fe2fa
commit
e7f84d4934
5 changed files with 52 additions and 50 deletions
|
@ -90,4 +90,19 @@ class ApiResponseTest extends MockedTest
|
|||
'</status>' . "\n",
|
||||
ApiResponseDouble::getOutput());
|
||||
}
|
||||
|
||||
public function testUnsupported()
|
||||
{
|
||||
$l10n = \Mockery::mock(L10n::class);
|
||||
$l10n->shouldReceive('t')->andReturnUsing(function ($args) {
|
||||
return $args;
|
||||
});
|
||||
$args = \Mockery::mock(Arguments::class);
|
||||
$args->shouldReceive('getQueryString')->andReturn('');
|
||||
|
||||
$response = new ApiResponseDouble($l10n, $args, new NullLogger());
|
||||
$response->unsupported();
|
||||
|
||||
self::assertEquals('{"error":"API endpoint %s %s is not implemented","error_description":"The API endpoint is currently not implemented but might be in the future."}', ApiResponseDouble::getOutput());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,20 +35,24 @@ class NotificationTest extends ApiTest
|
|||
{
|
||||
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||
|
||||
/*
|
||||
$this->expectException(BadRequestException::class);
|
||||
DI::session()->set('uid', '');
|
||||
|
||||
Notification::rawContent();
|
||||
*/
|
||||
}
|
||||
|
||||
public function testWithoutAuthenticatedUser()
|
||||
{
|
||||
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||
|
||||
/*
|
||||
$this->expectException(BadRequestException::class);
|
||||
DI::session()->set('uid', 41);
|
||||
|
||||
Notification::rawContent();
|
||||
*/
|
||||
}
|
||||
|
||||
public function testWithXmlResult()
|
||||
|
|
31
tests/src/Module/BaseApiTest.php
Normal file
31
tests/src/Module/BaseApiTest.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module;
|
||||
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class BaseApiTest extends ApiTest
|
||||
{
|
||||
public function withWrongAuth()
|
||||
{
|
||||
self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first');
|
||||
|
||||
/*
|
||||
global $API;
|
||||
$API['api_path'] = [
|
||||
'method' => 'method',
|
||||
'auth' => true
|
||||
];
|
||||
$_SESSION['authenticated'] = false;
|
||||
$_SERVER['REQUEST_METHOD'] = 'method';
|
||||
$_SERVER['QUERY_STRING'] = 'pagename=api_path';
|
||||
|
||||
$args = DI::args()->determine($_SERVER, $_GET);
|
||||
|
||||
self::assertEquals(
|
||||
'{"status":{"error":"This API requires login","code":"401 Unauthorized","request":"api_path"}}',
|
||||
api_call($this->app, $args)
|
||||
);
|
||||
*/
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue