1
0
mirror of https://github.com/flarum/core.git synced 2025-08-11 19:04:29 +02:00

chore: fix package manager tests (#3407)

This commit is contained in:
Sami Mazouz
2022-04-25 13:31:16 +01:00
committed by GitHub
parent d465fd27bc
commit b14c0780d2
5 changed files with 55 additions and 27 deletions

View File

@@ -15,27 +15,11 @@ class SetupComposer
{
use UsesTmpDir;
private $config = [
'require' => [
'flarum/core' => '1.0.0',
'flarum/tags' => '1.0.3',
'flarum/lang-english' => '*',
],
'config' => [
'preferred-install' => 'dist',
'sort-packages' => true,
],
'repositories' => [
[
'type' => 'path',
'url' => __DIR__.'/tmp/packages/*',
]
]
];
private $config;
public function __construct(array $config = null)
{
$this->config = array_merge($this->config, $config ?? []);
$this->config = $config;
}
public function run()
@@ -44,7 +28,7 @@ class SetupComposer
$composerLock = $this->tmpDir().'/composer.lock';
$packages = $this->tmpDir().'/packages';
file_put_contents($composerJson, json_encode($this->config, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
file_put_contents($composerJson, json_encode($this->getConfig(), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
if (! file_exists($packages)) {
mkdir($packages);
@@ -53,5 +37,28 @@ class SetupComposer
if (file_exists($composerLock)) {
unlink($composerLock);
}
echo 'composer.json created with testing packages directory.';
}
private function getConfig(): array
{
return array_merge([
'require' => [
'flarum/core' => '1.0.0',
'flarum/tags' => '1.0.3',
'flarum/lang-english' => '*',
],
'config' => [
'preferred-install' => 'dist',
'sort-packages' => true,
],
'repositories' => [
[
'type' => 'path',
'url' => realpath($this->tmpDir()).'/packages/*',
]
]
], $this->config ?? []);
}
}

View File

@@ -19,10 +19,7 @@
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>
<exclude>./integration/tmp</exclude>
<exclude>./integration/tmp</exclude>
</testsuite>
</testsuites>
<php>
<env name="FLARUM_TEST_TMP_DIR_LOCAL" value="tests/integration/tmp" force="true" />
</php>
</phpunit>