mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 09:53:27 +08:00
get/set enabled extensions from test case, not DB
This commit is contained in:
parent
bd613ba70c
commit
5febbf8fb1
@ -22,6 +22,7 @@ class OverrideExtensionManagerForTests implements ExtenderInterface
|
||||
|
||||
public function extend(Container $container, Extension $extension = null)
|
||||
{
|
||||
$container->when(ExtensionManagerIncludeCurrent::class)->needs('$enabledIds')->give($this->extensions);
|
||||
if (count($this->extensions)) {
|
||||
$container->singleton(ExtensionManager::class, ExtensionManagerIncludeCurrent::class);
|
||||
$extensionManager = $container->make(ExtensionManager::class);
|
||||
|
@ -9,16 +9,41 @@
|
||||
|
||||
namespace Flarum\Testing\integration\Extension;
|
||||
|
||||
use Flarum\Database\Migrator;
|
||||
use Flarum\Extension\Extension;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Filesystem\Cloud;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Filesystem\FilesystemAdapter;
|
||||
use Illuminate\Support\Arr;
|
||||
use League\Flysystem\Adapter\Local;
|
||||
use League\Flysystem\Filesystem;
|
||||
use League\Flysystem\Filesystem as FlysystemFilesystem;
|
||||
|
||||
class ExtensionManagerIncludeCurrent extends ExtensionManager
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $enabledIds;
|
||||
|
||||
public function __construct(
|
||||
SettingsRepositoryInterface $config,
|
||||
Paths $paths,
|
||||
Container $container,
|
||||
Migrator $migrator,
|
||||
Dispatcher $dispatcher,
|
||||
Filesystem $filesystem,
|
||||
array $enabledIds
|
||||
) {
|
||||
parent::__construct($config, $paths, $container, $migrator, $dispatcher, $filesystem);
|
||||
|
||||
$this->enabledIds = $enabledIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @{@inheritDoc}
|
||||
*/
|
||||
@ -44,6 +69,21 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
|
||||
return $this->extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* In test cases, enabled extensions are determined by the test case, not the database.
|
||||
*/
|
||||
public function getEnabled()
|
||||
{
|
||||
return $this->enabledIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabled extensions must be specified by the test case, so this should do nothing.
|
||||
*/
|
||||
protected function setEnabledExtensions(array $enabledExtensions)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of the assets filesystem.
|
||||
* This is resolved dynamically because Flarum's filesystem configuration
|
||||
@ -51,6 +91,6 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
|
||||
*/
|
||||
protected function getAssetsFilesystem(): Cloud
|
||||
{
|
||||
return new FilesystemAdapter(new Filesystem(new Local($this->paths->public.'/assets'), ['url' => resolve('flarum.config')->url().'/assets']));
|
||||
return new FilesystemAdapter(new FlysystemFilesystem(new Local($this->paths->public . '/assets'), ['url' => resolve('flarum.config')->url() . '/assets']));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user