mirror of
https://github.com/flarum/core.git
synced 2025-08-08 09:26:34 +02:00
test: Updates (#11)
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\PackageManager\Tests\integration;
|
||||
|
||||
use FilesystemIterator;
|
||||
use Flarum\PackageManager\Composer\ComposerAdapter;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
trait RefreshComposerSetup
|
||||
{
|
||||
public function tearDown(): void
|
||||
@@ -9,10 +21,35 @@ trait RefreshComposerSetup
|
||||
$composerSetup = new SetupComposer();
|
||||
@unlink($this->tmpDir().'/composer.lock');
|
||||
|
||||
$this->deleteDummyExtensions();
|
||||
|
||||
$composerSetup->run();
|
||||
|
||||
$this->composer('install');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function deleteDummyExtensions(): void
|
||||
{
|
||||
$dir = $this->tmpDir().'/packages';
|
||||
|
||||
$it = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS);
|
||||
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
foreach($files as $file) {
|
||||
if ($file->isDir()){
|
||||
rmdir($file->getRealPath());
|
||||
} else {
|
||||
unlink($file->getRealPath());
|
||||
}
|
||||
}
|
||||
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
protected function forgetComposerApp(): void
|
||||
{
|
||||
$this->app()->getContainer()->instance(ComposerAdapter::class, null);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user