diff --git a/src/Module/BaseApi.php b/src/Module/BaseApi.php index 5c94bc772..c67671954 100644 --- a/src/Module/BaseApi.php +++ b/src/Module/BaseApi.php @@ -67,6 +67,8 @@ class BaseApi extends BaseModule public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->app = $app; } protected function delete() diff --git a/tests/Util/AppDouble.php b/tests/Util/AppDouble.php new file mode 100644 index 000000000..dc9f635c3 --- /dev/null +++ b/tests/Util/AppDouble.php @@ -0,0 +1,31 @@ +isLoggedIn = $isLoggedIn; + } + + public function isLoggedIn() + { + return $this->isLoggedIn; + } +} diff --git a/tests/src/Module/Api/ApiTest.php b/tests/src/Module/Api/ApiTest.php index c530ace2e..7d8acc37a 100644 --- a/tests/src/Module/Api/ApiTest.php +++ b/tests/src/Module/Api/ApiTest.php @@ -21,12 +21,14 @@ namespace Friendica\Test\src\Module\Api; +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Hook; use Friendica\Database\Database; use Friendica\DI; use Friendica\Security\Authentication; use Friendica\Test\FixtureTest; +use Friendica\Test\Util\AppDouble; use Friendica\Test\Util\AuthenticationDouble; abstract class ApiTest extends FixtureTest @@ -51,9 +53,13 @@ abstract class ApiTest extends FixtureTest parent::setUp(); // TODO: Change the autogenerated stub $this->dice = $this->dice - ->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true]); + ->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true]) + ->addRule(App::class, ['instanceOf' => AppDouble::class, 'shared' => true]); DI::init($this->dice); + // Manual overwrite for API testrs :-) + DI::app()->setIsLoggedIn(true); + $this->installAuthTest(); }