1
0
Fork 0

Fix tests

This commit is contained in:
Philipp Holzer 2021-11-17 22:21:03 +01:00
parent ce578a7745
commit f3d7d610e8
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
9 changed files with 27 additions and 20 deletions

View file

@ -54,7 +54,7 @@ class ModuleControllerTest extends DatabaseTest
self::assertModule([ self::assertModule([
'isBackend' => false, 'isBackend' => false,
'name' => App\ModuleController::DEFAULT, 'name' => App\ModuleController::DEFAULT,
'class' => new $defaultClass(), 'class' => null,
], $module); ], $module);
} }
@ -146,28 +146,28 @@ class ModuleControllerTest extends DatabaseTest
'name' => App\ModuleController::DEFAULT, 'name' => App\ModuleController::DEFAULT,
'command' => App\ModuleController::DEFAULT, 'command' => App\ModuleController::DEFAULT,
'privAdd' => false, 'privAdd' => false,
'args' => [], 'args' => [Mockery::mock(L10n::class)],
], ],
'legacy' => [ 'legacy' => [
'assert' => LegacyModule::class, 'assert' => LegacyModule::class,
'name' => 'display', 'name' => 'display',
'command' => 'display/test/it', 'command' => 'display/test/it',
'privAdd' => false, 'privAdd' => false,
'args' => [__DIR__ . '/../../datasets/legacy/legacy.php'], 'args' => [Mockery::mock(L10n::class), __DIR__ . '/../../datasets/legacy/legacy.php'],
], ],
'new' => [ 'new' => [
'assert' => HostMeta::class, 'assert' => HostMeta::class,
'not_required', 'not_required',
'command' => '.well-known/host-meta', 'command' => '.well-known/host-meta',
'privAdd' => false, 'privAdd' => false,
'args' => [], 'args' => [Mockery::mock(L10n::class)],
], ],
'404' => [ '404' => [
'assert' => PageNotFound::class, 'assert' => PageNotFound::class,
'name' => 'invalid', 'name' => 'invalid',
'command' => 'invalid', 'command' => 'invalid',
'privAdd' => false, 'privAdd' => false,
'args' => [], 'args' => [Mockery::mock(L10n::class)],
] ]
]; ];
} }

View file

@ -67,7 +67,7 @@ class NotificationTest extends ApiTest
</notes> </notes>
XML; XML;
$notification = new Notification(['extension' => 'xml']); $notification = new Notification(DI::l10n(), ['extension' => 'xml']);
$notification->rawContent(); $notification->rawContent();
self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput()); self::assertXmlStringEqualsXmlString($assertXml, ApiResponseDouble::getOutput());
@ -75,7 +75,7 @@ XML;
public function testWithJsonResult() public function testWithJsonResult()
{ {
$notification = new Notification(['parameter' => 'json']); $notification = new Notification(DI::l10n(),['parameter' => 'json']);
$notification->rawContent(); $notification->rawContent();
$result = json_encode(ApiResponseDouble::getOutput()); $result = json_encode(ApiResponseDouble::getOutput());

View file

@ -21,6 +21,7 @@
namespace Friendica\Test\src\Module\Api\Friendica\Photo; namespace Friendica\Test\src\Module\Api\Friendica\Photo;
use Friendica\DI;
use Friendica\Module\Api\Friendica\Photo\Delete; use Friendica\Module\Api\Friendica\Photo\Delete;
use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
@ -30,7 +31,7 @@ class DeleteTest extends ApiTest
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete())->rawContent(); (new Delete(DI::l10n()))->rawContent();
} }
public function testWithoutAuthenticatedUser() public function testWithoutAuthenticatedUser()
@ -41,7 +42,7 @@ class DeleteTest extends ApiTest
public function testWrong() public function testWrong()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete(['photo_id' => 1]))->rawContent(); (new Delete(DI::l10n(), ['photo_id' => 1]))->rawContent();
} }
public function testWithCorrectPhotoId() public function testWithCorrectPhotoId()

View file

@ -21,6 +21,7 @@
namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum; namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum;
use Friendica\DI;
use Friendica\Module\Api\Friendica\Photoalbum\Delete; use Friendica\Module\Api\Friendica\Photoalbum\Delete;
use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
@ -30,13 +31,13 @@ class DeleteTest extends ApiTest
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete())->rawContent(); (new Delete(DI::l10n()))->rawContent();
} }
public function testWrong() public function testWrong()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Delete(['album' => 'album_name']))->rawContent(); (new Delete(DI::l10n(), ['album' => 'album_name']))->rawContent();
} }
public function testValid() public function testValid()

View file

@ -21,6 +21,7 @@
namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum; namespace Friendica\Test\src\Module\Api\Friendica\Photoalbum;
use Friendica\DI;
use Friendica\Module\Api\Friendica\Photoalbum\Update; use Friendica\Module\Api\Friendica\Photoalbum\Update;
use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
@ -30,19 +31,19 @@ class UpdateTest extends ApiTest
public function testEmpty() public function testEmpty()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Update())->rawContent(); (new Update(DI::l10n()))->rawContent();
} }
public function testTooFewArgs() public function testTooFewArgs()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Update(['album' => 'album_name']))->rawContent(); (new Update(DI::l10n(), ['album' => 'album_name']))->rawContent();
} }
public function testWrongUpdate() public function testWrongUpdate()
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
(new Update(['album' => 'album_name', 'album_new' => 'album_name']))->rawContent(); (new Update(DI::l10n(), ['album' => 'album_name', 'album_new' => 'album_name']))->rawContent();
} }
public function testWithoutAuthenticatedUser() public function testWithoutAuthenticatedUser()

View file

@ -2,6 +2,7 @@
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial; namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
use Friendica\DI;
use Friendica\Module\Api\GNUSocial\GNUSocial\Version; use Friendica\Module\Api\GNUSocial\GNUSocial\Version;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
use Friendica\Test\Util\ApiResponseDouble; use Friendica\Test\Util\ApiResponseDouble;
@ -10,7 +11,7 @@ class VersionTest extends ApiTest
{ {
public function test() public function test()
{ {
$version = new Version(['extension' => 'json']); $version = new Version(DI::l10n(), ['extension' => 'json']);
$version->rawContent(); $version->rawContent();
$result = json_decode(ApiResponseDouble::getOutput()); $result = json_decode(ApiResponseDouble::getOutput());

View file

@ -2,6 +2,7 @@
namespace Friendica\Test\src\Module\Api\GnuSocial\Help; namespace Friendica\Test\src\Module\Api\GnuSocial\Help;
use Friendica\DI;
use Friendica\Module\Api\GNUSocial\Help\Test; use Friendica\Module\Api\GNUSocial\Help\Test;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
use Friendica\Test\Util\ApiResponseDouble; use Friendica\Test\Util\ApiResponseDouble;
@ -10,7 +11,7 @@ class TestTest extends ApiTest
{ {
public function testJson() public function testJson()
{ {
$test = new Test(['extension' => 'json']); $test = new Test(DI::l10n(), ['extension' => 'json']);
$test->rawContent(); $test->rawContent();
self::assertEquals('"ok"', ApiResponseDouble::getOutput()); self::assertEquals('"ok"', ApiResponseDouble::getOutput());
@ -18,7 +19,7 @@ class TestTest extends ApiTest
public function testXml() public function testXml()
{ {
$test = new Test(['extension' => 'xml']); $test = new Test(DI::l10n(), ['extension' => 'xml']);
$test->rawContent(); $test->rawContent();
self::assertxml(ApiResponseDouble::getOutput(), 'ok'); self::assertxml(ApiResponseDouble::getOutput(), 'ok');

View file

@ -2,6 +2,7 @@
namespace Friendica\Test\src\Module\Api\Twitter\Account; namespace Friendica\Test\src\Module\Api\Twitter\Account;
use Friendica\DI;
use Friendica\Module\Api\Twitter\Account\RateLimitStatus; use Friendica\Module\Api\Twitter\Account\RateLimitStatus;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
use Friendica\Test\Util\ApiResponseDouble; use Friendica\Test\Util\ApiResponseDouble;
@ -10,7 +11,7 @@ class RateLimitStatusTest extends ApiTest
{ {
public function testWithJson() public function testWithJson()
{ {
$rateLimitStatus = new RateLimitStatus(['extension' => 'json']); $rateLimitStatus = new RateLimitStatus(DI::l10n(), ['extension' => 'json']);
$rateLimitStatus->rawContent(); $rateLimitStatus->rawContent();
$result = json_decode(ApiResponseDouble::getOutput()); $result = json_decode(ApiResponseDouble::getOutput());
@ -22,7 +23,7 @@ class RateLimitStatusTest extends ApiTest
public function testWithXml() public function testWithXml()
{ {
$rateLimitStatus = new RateLimitStatus(['extension' => 'xml']); $rateLimitStatus = new RateLimitStatus(DI::l10n(),['extension' => 'xml']);
$rateLimitStatus->rawContent(); $rateLimitStatus->rawContent();
self::assertXml(ApiResponseDouble::getOutput(), 'hash'); self::assertXml(ApiResponseDouble::getOutput(), 'hash');

View file

@ -2,6 +2,7 @@
namespace Friendica\Test\src\Module\Api\Twitter; namespace Friendica\Test\src\Module\Api\Twitter;
use Friendica\DI;
use Friendica\Module\Api\Twitter\SavedSearches; use Friendica\Module\Api\Twitter\SavedSearches;
use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Test\src\Module\Api\ApiTest;
use Friendica\Test\Util\ApiResponseDouble; use Friendica\Test\Util\ApiResponseDouble;
@ -10,7 +11,7 @@ class SavedSearchesTest extends ApiTest
{ {
public function test() public function test()
{ {
$savedSearch = new SavedSearches(['extension' => 'json']); $savedSearch = new SavedSearches(DI::l10n(), ['extension' => 'json']);
$savedSearch->rawContent(); $savedSearch->rawContent();
$result = json_decode(ApiResponseDouble::getOutput()); $result = json_decode(ApiResponseDouble::getOutput());