3 namespace Friendica\Test\src\Module\Api;
6 use Friendica\Core\Addon;
7 use Friendica\Core\Hook;
8 use Friendica\Database\Database;
10 use Friendica\Module\Api\ApiResponse;
11 use Friendica\Security\Authentication;
12 use Friendica\Test\FixtureTest;
13 use Friendica\Test\Util\ApiResponseDouble;
14 use Friendica\Test\Util\AuthenticationDouble;
16 class ApiTest extends FixtureTest
18 protected function setUp(): void
20 parent::setUp(); // TODO: Change the autogenerated stub
22 $this->dice = $this->dice
23 ->addRule(Authentication::class, ['instanceOf' => AuthenticationDouble::class, 'shared' => true])
24 ->addRule(ApiResponse::class, ['instanceOf' => ApiResponseDouble::class, 'shared' => true]);
25 DI::init($this->dice);
27 $this->installAuthTest();
30 protected function tearDown(): void
32 ApiResponseDouble::reset();
42 public function installAuthTest()
45 $addon_file_path = __DIR__ . '/../../../Util/authtest/authtest.php';
46 $t = @filemtime($addon_file_path);
48 @include_once($addon_file_path);
49 if (function_exists($addon . '_install')) {
50 $func = $addon . '_install';
54 /** @var Database $dba */
55 $dba = $this->dice->create(Database::class);
57 $dba->insert('addon', [
61 'plugin_admin' => function_exists($addon . '_addon_admin'),
62 'hidden' => file_exists('addon/' . $addon . '/.hidden')