mirror of
https://github.com/flarum/core.git
synced 2025-08-09 18:07:02 +02:00
chore: improve test suite (#3814)
Allows running tests without constantly running `composer install` on each extension.
This commit is contained in:
@@ -73,31 +73,18 @@ class ExtensionManager
|
||||
$composerJsonConfs[$packagePath] = $package;
|
||||
}
|
||||
|
||||
if ($subextPaths = Arr::get($package, 'extra.flarum-subextensions', [])) {
|
||||
foreach ($subextPaths as $subExtPath) {
|
||||
$subPackagePath = "$packagePath/$subExtPath";
|
||||
$conf = json_decode($this->filesystem->get("$subPackagePath/composer.json"), true);
|
||||
|
||||
if (Arr::get($conf, 'type') === 'flarum-extension') {
|
||||
$composerJsonConfs[$subPackagePath] = $conf;
|
||||
}
|
||||
}
|
||||
if ($subExtConfs = $this->subExtensionConfsFromJson($package, $packagePath)) {
|
||||
$composerJsonConfs = array_merge($composerJsonConfs, $subExtConfs);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($composerJsonConfs as $path => $package) {
|
||||
$installedSet[Arr::get($package, 'name')] = true;
|
||||
|
||||
// Instantiates an Extension object using the package path and composer.json file.
|
||||
$extension = new Extension($path, $package);
|
||||
|
||||
// Per default all extensions are installed if they are registered in composer.
|
||||
$extension->setInstalled(true);
|
||||
$extension->setVersion(Arr::get($package, 'version'));
|
||||
|
||||
$extension = $this->extensionFromJson($package, $path);
|
||||
$extensions->put($extension->getId(), $extension);
|
||||
}
|
||||
|
||||
/** @var Extension $extension */
|
||||
foreach ($extensions as $extension) {
|
||||
$extension->calculateDependencies($installedSet);
|
||||
}
|
||||
@@ -472,4 +459,36 @@ class ExtensionManager
|
||||
'circularDependencies' => $circularDependencies
|
||||
];
|
||||
}
|
||||
|
||||
protected function extensionFromJson(array $package, string $path): Extension
|
||||
{
|
||||
// Instantiates an Extension object using the package path and composer.json file.
|
||||
$extension = new Extension($path, $package);
|
||||
|
||||
// Per default all extensions are installed if they are registered in composer.
|
||||
$extension->setInstalled(true);
|
||||
$extension->setVersion(Arr::get($package, 'version', '0.0'));
|
||||
|
||||
return $extension;
|
||||
}
|
||||
|
||||
protected function subExtensionConfsFromJson(array $package, string $packagePath): ?array
|
||||
{
|
||||
if (! ($subExtPaths = Arr::get($package, 'extra.flarum-subextensions', []))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$subExtConfs = [];
|
||||
|
||||
foreach ($subExtPaths as $subExtPath) {
|
||||
$subPackagePath = "$packagePath/$subExtPath";
|
||||
$conf = json_decode($this->filesystem->get("$subPackagePath/composer.json"), true);
|
||||
|
||||
if (Arr::get($conf, 'type') === 'flarum-extension') {
|
||||
$subExtConfs[$subPackagePath] = $conf;
|
||||
}
|
||||
}
|
||||
|
||||
return $subExtConfs;
|
||||
}
|
||||
}
|
||||
|
@@ -7,10 +7,6 @@
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
@@ -10,6 +10,7 @@
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
@@ -10,6 +10,7 @@
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
Reference in New Issue
Block a user