1
0
mirror of https://github.com/flarum/core.git synced 2025-08-17 22:01:44 +02:00

feat(em): port extension manager from 1.0 (#3959)

* feat(em): port extension manager from 1.0

* Apply fixes from StyleCI

* chore: phpstan

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Sami Mazouz
2024-01-22 18:58:08 +01:00
committed by GitHub
parent 8f29b7af82
commit 3fbe05fd18
114 changed files with 2003 additions and 636 deletions

View File

@@ -7,7 +7,7 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration;
namespace Flarum\ExtensionManager\Tests\integration;
trait ChangeComposerConfig
{

View File

@@ -7,7 +7,7 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration;
namespace Flarum\ExtensionManager\Tests\integration;
trait DummyExtensions
{

View File

@@ -7,10 +7,10 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration;
namespace Flarum\ExtensionManager\Tests\integration;
use FilesystemIterator;
use Flarum\PackageManager\Composer\ComposerAdapter;
use Flarum\ExtensionManager\Composer\ComposerAdapter;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;

View File

@@ -7,7 +7,7 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration;
namespace Flarum\ExtensionManager\Tests\integration;
use Flarum\Testing\integration\UsesTmpDir;

View File

@@ -7,12 +7,12 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration;
namespace Flarum\ExtensionManager\Tests\integration;
use Flarum\ExtensionManager\Composer\ComposerAdapter;
use Flarum\ExtensionManager\Composer\ComposerJson;
use Flarum\ExtensionManager\Support\Util;
use Flarum\Foundation\Paths;
use Flarum\PackageManager\Composer\ComposerAdapter;
use Flarum\PackageManager\Composer\ComposerJson;
use Flarum\PackageManager\Extension\ExtensionUtils;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Illuminate\Support\Arr;
use Psr\Http\Message\ResponseInterface;
@@ -26,7 +26,7 @@ class TestCase extends \Flarum\Testing\integration\TestCase
{
parent::setUp();
$this->extension('flarum-package-manager', 'flarum-tags');
$this->extension('flarum-extension-manager', 'flarum-tags');
$tmp = realpath($this->tmpDir());
@@ -45,7 +45,7 @@ class TestCase extends \Flarum\Testing\integration\TestCase
return $package['type'] === 'flarum-extension';
});
$installedExtensionIds = array_map(function (string $name) {
return ExtensionUtils::nameToId($name);
return Util::nameToId($name);
}, Arr::pluck($installedExtensions, 'name'));
if ($exists) {

View File

@@ -7,11 +7,11 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api;
namespace Flarum\ExtensionManager\Tests\integration\api;
use Flarum\PackageManager\Tests\integration\ChangeComposerConfig;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Flarum\ExtensionManager\Tests\integration\ChangeComposerConfig;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
use Illuminate\Support\Arr;
class CheckForUpdatesTest extends TestCase
@@ -32,7 +32,7 @@ class CheckForUpdatesTest extends TestCase
]);
$response = $this->send(
$this->request('POST', '/api/package-manager/check-for-updates', [
$this->request('POST', '/api/extension-manager/check-for-updates', [
'authenticatedAs' => 1,
])
);

View File

@@ -7,10 +7,10 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api;
namespace Flarum\ExtensionManager\Tests\integration\api;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
class GlobalUpdateTest extends TestCase
{
@@ -22,7 +22,7 @@ class GlobalUpdateTest extends TestCase
public function can_global_update()
{
$response = $this->send(
$this->request('POST', '/api/package-manager/global-update', [
$this->request('POST', '/api/extension-manager/global-update', [
'authenticatedAs' => 1,
])
);

View File

@@ -7,12 +7,12 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api;
namespace Flarum\ExtensionManager\Tests\integration\api;
use Flarum\PackageManager\Tests\integration\ChangeComposerConfig;
use Flarum\PackageManager\Tests\integration\DummyExtensions;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Flarum\ExtensionManager\Tests\integration\ChangeComposerConfig;
use Flarum\ExtensionManager\Tests\integration\DummyExtensions;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
class MajorUpdateTest extends TestCase
{
@@ -36,7 +36,7 @@ class MajorUpdateTest extends TestCase
]);
$response = $this->send(
$this->request('POST', '/api/package-manager/major-update', [
$this->request('POST', '/api/extension-manager/major-update', [
'authenticatedAs' => 1,
])
);
@@ -61,7 +61,7 @@ class MajorUpdateTest extends TestCase
]);
$lastUpdateCheck = $this->send(
$this->request('POST', '/api/package-manager/check-for-updates', [
$this->request('POST', '/api/extension-manager/check-for-updates', [
'authenticatedAs' => 1,
])
);
@@ -69,7 +69,7 @@ class MajorUpdateTest extends TestCase
$this->forgetComposerApp();
$response = $this->send(
$this->request('POST', '/api/package-manager/major-update', [
$this->request('POST', '/api/extension-manager/major-update', [
'authenticatedAs' => 1,
])
);
@@ -107,13 +107,13 @@ class MajorUpdateTest extends TestCase
]);
$this->send(
$this->request('POST', '/api/package-manager/check-for-updates', [
$this->request('POST', '/api/extension-manager/check-for-updates', [
'authenticatedAs' => 1,
])
);
$response = $this->send(
$this->request('POST', '/api/package-manager/major-update', [
$this->request('POST', '/api/extension-manager/major-update', [
'authenticatedAs' => 1,
])
);

View File

@@ -7,14 +7,14 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api;
namespace Flarum\ExtensionManager\Tests\integration\api;
use Flarum\PackageManager\Event\FlarumUpdated;
use Flarum\PackageManager\Settings\LastUpdateRun;
use Flarum\PackageManager\Tests\integration\ChangeComposerConfig;
use Flarum\PackageManager\Tests\integration\DummyExtensions;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Flarum\ExtensionManager\Event\FlarumUpdated;
use Flarum\ExtensionManager\Settings\LastUpdateRun;
use Flarum\ExtensionManager\Tests\integration\ChangeComposerConfig;
use Flarum\ExtensionManager\Tests\integration\DummyExtensions;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
class MinorUpdateTest extends TestCase
{
@@ -43,7 +43,7 @@ class MinorUpdateTest extends TestCase
]);
$response = $this->send(
$this->request('POST', '/api/package-manager/minor-update', [
$this->request('POST', '/api/extension-manager/minor-update', [
'authenticatedAs' => 1,
])
);
@@ -69,7 +69,7 @@ class MinorUpdateTest extends TestCase
]);
$this->send(
$this->request('POST', '/api/package-manager/check-for-updates', [
$this->request('POST', '/api/extension-manager/check-for-updates', [
'authenticatedAs' => 1,
])
);
@@ -77,7 +77,7 @@ class MinorUpdateTest extends TestCase
$this->forgetComposerApp();
$response = $this->send(
$this->request('POST', '/api/package-manager/minor-update', [
$this->request('POST', '/api/extension-manager/minor-update', [
'authenticatedAs' => 1,
])
);

View File

@@ -7,10 +7,10 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api\extensions;
namespace Flarum\ExtensionManager\Tests\integration\api\extensions;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
class RemoveExtensionTest extends TestCase
{
@@ -30,7 +30,7 @@ class RemoveExtensionTest extends TestCase
public function removing_an_extension_works()
{
$response = $this->send(
$this->request('DELETE', '/api/package-manager/extensions/flarum-tags', [
$this->request('DELETE', '/api/extension-manager/extensions/flarum-tags', [
'authenticatedAs' => 1
])
);
@@ -45,7 +45,7 @@ class RemoveExtensionTest extends TestCase
public function removing_a_non_existant_extension_fails()
{
$response = $this->send(
$this->request('DELETE', '/api/package-manager/extensions/flarum-potato', [
$this->request('DELETE', '/api/extension-manager/extensions/flarum-potato', [
'authenticatedAs' => 1
])
);

View File

@@ -7,10 +7,10 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api\extensions;
namespace Flarum\ExtensionManager\Tests\integration\api\extensions;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
class RequireExtensionTest extends TestCase
{
@@ -30,7 +30,7 @@ class RequireExtensionTest extends TestCase
public function requiring_an_existing_extension_fails()
{
$response = $this->send(
$this->request('POST', '/api/package-manager/extensions', [
$this->request('POST', '/api/extension-manager/extensions', [
'authenticatedAs' => 1,
'json' => [
'data' => [
@@ -49,7 +49,7 @@ class RequireExtensionTest extends TestCase
public function requiring_a_compatible_extension_works()
{
$response = $this->send(
$this->request('POST', '/api/package-manager/extensions', [
$this->request('POST', '/api/extension-manager/extensions', [
'authenticatedAs' => 1,
'json' => [
'data' => [
@@ -69,7 +69,7 @@ class RequireExtensionTest extends TestCase
public function requiring_a_compatible_extension_with_specific_version_works()
{
$response = $this->send(
$this->request('POST', '/api/package-manager/extensions', [
$this->request('POST', '/api/extension-manager/extensions', [
'authenticatedAs' => 1,
'json' => [
'data' => [
@@ -89,7 +89,7 @@ class RequireExtensionTest extends TestCase
public function requiring_an_uncompatible_extension_fails()
{
$response = $this->send(
$this->request('POST', '/api/package-manager/extensions', [
$this->request('POST', '/api/extension-manager/extensions', [
'authenticatedAs' => 1,
'json' => [
'data' => [
@@ -109,7 +109,7 @@ class RequireExtensionTest extends TestCase
public function requiring_an_uncompatible_extension_with_specific_version_fails()
{
$response = $this->send(
$this->request('POST', '/api/package-manager/extensions', [
$this->request('POST', '/api/extension-manager/extensions', [
'authenticatedAs' => 1,
'json' => [
'data' => [

View File

@@ -7,10 +7,10 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager\Tests\integration\api\extensions;
namespace Flarum\ExtensionManager\Tests\integration\api\extensions;
use Flarum\PackageManager\Tests\integration\RefreshComposerSetup;
use Flarum\PackageManager\Tests\integration\TestCase;
use Flarum\ExtensionManager\Tests\integration\RefreshComposerSetup;
use Flarum\ExtensionManager\Tests\integration\TestCase;
class UpdateExtensionTest extends TestCase
{
@@ -30,7 +30,7 @@ class UpdateExtensionTest extends TestCase
public function updating_an_existing_extension_works()
{
$response = $this->send(
$this->request('PATCH', '/api/package-manager/extensions/flarum-tags', [
$this->request('PATCH', '/api/extension-manager/extensions/flarum-tags', [
'authenticatedAs' => 1,
])
);
@@ -45,7 +45,7 @@ class UpdateExtensionTest extends TestCase
public function updating_a_non_existing_extension_fails()
{
$response = $this->send(
$this->request('PATCH', '/api/package-manager/extensions/flarum-potato', [
$this->request('PATCH', '/api/extension-manager/extensions/flarum-potato', [
'authenticatedAs' => 1,
])
);

View File

@@ -7,9 +7,12 @@
* LICENSE file that was distributed with this source code.
*/
use Flarum\PackageManager\Tests\integration\SetupComposer;
use Flarum\ExtensionManager\Tests\integration\SetupComposer;
use Flarum\Testing\integration\Setup\SetupScript;
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
require __DIR__.'/../../vendor/autoload.php';
$setup = new SetupScript();
$setup->run();

View File

@@ -10,7 +10,6 @@
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<include>

View File

@@ -10,7 +10,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
>
<coverage processUncoveredFiles="true">
<include>