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

test: Updates (#11)

This commit is contained in:
Sami Mazouz
2021-11-24 18:25:43 +01:00
committed by GitHub
parent b2d8f3dd5b
commit 1754313503
14 changed files with 391 additions and 70 deletions

View File

@@ -15,20 +15,43 @@ 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/*',
]
]
];
public function __construct(array $config = null)
{
$this->config = array_merge($this->config, $config ?? []);
}
public function run()
{
$filePath = $this->tmpDir().'/composer.json';
$composerJson = $this->tmpDir().'/composer.json';
$composerLock = $this->tmpDir().'/composer.lock';
$packages = $this->tmpDir().'/packages';
file_put_contents($filePath, json_encode([
'require' => [
'flarum/core' => '1.0.0',
'flarum/tags' => '1.0.3',
'flarum/lang-english' => '*',
],
'config' => [
'preferred-install' => 'dist',
'sort-packages' => true,
],
], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
file_put_contents($composerJson, json_encode($this->config, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
if (! file_exists($packages)) {
mkdir($packages);
}
if (file_exists($composerLock)) {
unlink($composerLock);
}
}
}